Configuration Module

hedwig.config

hedwig.config.read_config(file_)
hedwig.config.read_json(file_)
class hedwig.config.MemoCache
instances = [<hedwig.config.MemoCache object>, <hedwig.config.MemoCache object>, <hedwig.config.MemoCache object>, <hedwig.config.MemoCache object>, <hedwig.config.MemoCache object>]
classmethod clear_all()
hedwig.config.get_config()

Read the configuration file.

Returns a ConfigParser object.

hedwig.config.get_countries()

Get ordered dictionary of 2-letter country codes mapping to country names. This is sorted by country name.

hedwig.config.get_database(database_url=None, facility_spec=None)

Construct a database control object.

The database URL and facility specifier text (comma-separated string) can be given for testing – otherwise they are read from the configuration.

hedwig.config._get_database(database_url, facility_spec)
hedwig.config._get_db_class(facility_spec)

Create a combined database class for the given facilities.

hedwig.config.get_facilities(db=None, facility_spec=None)

Get a dictionary of facilities as listed in the configuration file.

The facility specifier text (comma-separated string) can be given for testing – otherwise it is read from the configuration.

If no database is available, db can be given as () (the empty tuple), and dummy identifiers will be used. Otherwise if db is None, then get_database will be used to obtain a database object.

hedwig.config._get_facilities(db, facility_spec)
hedwig.config._create_facility(db, facility_class)
hedwig.config.get_home()

Determine the application’s home directory.

hedwig.config.set_home(directory)

Set the application’s home directory.

This will alter the value returned in subsequent calls to get_home.

hedwig.config.get_pdf_writer(db=None, app=None)

Get a PDF writer object.

hedwig.config._get_pdf_writer(db, app)
hedwig.config._import_class(class_name, module_pattern, class_pattern=None)

Import the given class.

The class can either be fully specified (full module name, a dot, and class name), or the name of a class installed as part of Hedwig. In the latter case, the module_pattern argument is used to generate the module name (using the lower-case version of the class name) and the class_pattern (if given) is used to generate the class name.