configoose package

Subpackages

Submodules

configoose.configurator module

class configoose.configurator.AbstractConfigurator(address)

Bases: ABC

Provide 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 Protocol class in Python’s module system

  • args – additional arguments stored in the resulting object

  • kwargs – additional keyword arguments stored in the resulting object

Returns:

an AddedProtocol instance that has been registered in this configurator instance

Return type:

AddedProtocol

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 AddedProtocol instance, the preamble and the remaining text of the configuration file.

class configoose.configurator.AddedProtocol(args, kwargs)

Bases: object

Object returned by configurators add_protocol() and passed to Protocol.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: AbstractConfigurator

Concrete 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 configooseconf and userconfigooseconf, if they exist, to populate the global database by adding marinas. It is not considered an error if these modules don’t exist.