Package bitten :: Package build :: Module config :: Class Configuration

Class Configuration

object --+
         |
        Configuration

Encapsulates the configuration of a build machine.

Configuration values can be provided through a configuration file (in INI format) or through command-line parameters (properties). In addition to explicitly defined properties, this class automatically collects platform information and stores them as properties. These defaults can be overridden (useful for cross-compilation).

Instance Methods
 
__init__(self, filename=None, properties=None)
Create the configuration object.
 
__contains__(self, key)
Return whether the configuration contains a value for the specified key.
 
__getitem__(self, key)
Return the value for the specified configuration key.
 
__str__(self)
str(x)
 
get_dirpath(self, key)
Return the value of the specified configuration key, but verify that the value refers to the path of an existing directory.
 
get_filepath(self, key)
Return the value of the specified configuration key, but verify that the value refers to the path of an existing file.
 
interpolate(self, text, **vars)
Interpolate configuration and environment properties into a string.

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

Properties

Inherited from object: __class__

Method Details

__init__(self, filename=None, properties=None)
(Constructor)

 
Create the configuration object.
Parameters:
  • filename - the path to the configuration file, if any
  • properties - a dictionary of the configuration properties provided on the command-line
Overrides: object.__init__

__contains__(self, key)
(In operator)

 
Return whether the configuration contains a value for the specified key.
Parameters:
  • key - name of the configuration option using dotted notation (for example, "python.path")

__getitem__(self, key)
(Indexing operator)

 
Return the value for the specified configuration key.
Parameters:
  • key - name of the configuration option using dotted notation (for example, "python.path")

__str__(self)
(Informal representation operator)

 
str(x)
Overrides: object.__str__
(inherited documentation)

get_dirpath(self, key)

 

Return the value of the specified configuration key, but verify that the value refers to the path of an existing directory.

If the value does not exist, or is not a directory path, return None.

Parameters:
  • key - name of the configuration option using dotted notation (for example, "ant.home")

get_filepath(self, key)

 

Return the value of the specified configuration key, but verify that the value refers to the path of an existing file.

If the value does not exist, or is not a file path, return None.

Parameters:
  • key - name of the configuration option using dotted notation (for example, "python.path")

interpolate(self, text, **vars)

 

Interpolate configuration and environment properties into a string.

Configuration properties can be referenced in the text using the notation ${property.name}. A default value can be provided by appending it to the property name separated by a colon, for example ${property.name:defaultvalue}. This value will be used when there's no such property in the configuration. Otherwise, if no default is provided, the reference is not replaced at all.

Environment properties substitute from environment variables, supporting the common notations of $VAR and ${VAR}.

Parameters:
  • text - the string containing variable references
  • vars - extra variables to use for the interpolation