Package yum :: Module config :: Class Option
[hide private]
[frames] | no frames]

Class Option

source code


This class handles a single Yum configuration file option. Create subclasses for each type of supported configuration option.

Python descriptor foo (__get__ and __set__) is used to make option definition easy and consise.

Instance Methods [hide private]
 
__init__(self, default=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_setattrname(self)
Calculate the internal attribute name used to store option state in configuration instances.
source code
 
__get__(self, obj, objtype)
Called when the option is read (via the descriptor protocol).
source code
 
__set__(self, obj, value)
Called when the option is set (via the descriptor protocol).
source code
 
setup(self, obj, name)
Initialise the option for a config instance.
source code
 
clone(self)
Return a safe copy of this Option instance
source code
 
parse(self, s)
Parse the string value to the Option's native value.
source code
 
tostring(self, value)
Convert the Option's native value to a string value.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  __slotnames__ = []
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, default=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__get__(self, obj, objtype)

source code 

Called when the option is read (via the descriptor protocol).

Parameters:
  • obj - The configuration instance to modify.
  • objtype - The type of the config instance (not used).
Returns:
The parsed option value or the default value if the value wasn't set in the configuration file.

__set__(self, obj, value)

source code 

Called when the option is set (via the descriptor protocol).

Parameters:
  • obj - The configuration instance to modify.
  • value - The value to set the option to.
Returns:
Nothing.

setup(self, obj, name)

source code 

Initialise the option for a config instance. This must be called before the option can be set or retrieved.

Parameters:
  • obj - BaseConfig (or subclass) instance.
  • name - Name of the option.

parse(self, s)

source code 

Parse the string value to the Option's native value.

Parameters:
  • s - Raw string value to parse.
Returns:
Validated native value.

Will raise ValueError if there was a problem parsing the string. Subclasses should override this.

tostring(self, value)

source code 

Convert the Option's native value to a string value.

Parameters:
  • value - Native option value.
Returns:
String representation of input.

This does the opposite of the parse() method above. Subclasses should override this.