configoose package
Subpackages
- configoose.cli package
- configoose.database package
- configoose.protocol package
- configoose.util package
Submodules
configoose.configurator module
- class configoose.configurator.AbstractConfigurator(address)
Bases:
ABCProvide an interface for client programs that use configoose to configurate themselves
- Parameters:
address (str) – the abstract address used to find configuration files
- add_protocol(protopath, *args, **kwargs)
Declare a configuration protocol honored by the client program
- Parameters:
protopath (str) – full dotted path of a
Protocolclass in Python’s module systemargs – additional arguments stored in the resulting object
kwargs – additional keyword arguments stored in the resulting object
- Returns:
an
AddedProtocolinstance that has been registered in this configurator instance- Return type:
- abstract property database
The configoose database used by this configurator
- run(missing_ok=False)
Concretely executes the configuration action
- Parameters:
missing_ok (bool) – indicates that an absence of configuration file must be silently ignored. Defaults to False
By a lookup in the database, the configurator tries to find a configuration file corresponding to the address given to the constructor. If this succeeds, it reads the preamble of the configuration file to extract the protocol. If this protocol has been added to the configurator, it instanciates the protocol class and calls the protocol’s run() method, passing it the
AddedProtocolinstance, the preamble and the remaining text of the configuration file.
- class configoose.configurator.AddedProtocol(args, kwargs)
Bases:
objectObject returned by configurators
add_protocol()and passed toProtocol.run()methods.- Parameters:
args – additional tuple of arguments
kwargs – additional dict of arguments
- __call__(func)
Use self as a decorator to register a handler function
- Parameters:
func (Callable) – callable
- Returns:
the function passed as argument unchanged
The effect of the call is to add a pair (‘handler’, func) to the kwarg dict stored in the instance. This enables protocols run() method to call the handler method because this instance is passed to these methods.
- exception configoose.configurator.Error
Bases:
Exception
Module contents
A module enabling Python programs and libraries to use configuration files while leaving users free to store these configuration files to the location that suits them in their file system and other locations.
- configoose.root_db
The global database used by configoose
- class configoose.Configurator(address)
Bases:
AbstractConfiguratorConcrete configurator class using the global database
- property database
The configoose database used by this configurator
- configoose.init_root_db()
Initialize the root_db database
This function is executed when configoose is first imported. It processes the modules
configooseconfanduserconfigooseconf, if they exist, to populate the global database by adding marinas. It is not considered an error if these modules don’t exist.