bridgedb.configure

Utilities for dealing with configuration files for BridgeDB.

loadConfig(configFile=None, configCls=None)[source]

Load configuration settings on top of the current settings.

All pathnames and filenames within settings in the configFile will be expanded, and their expanded values will be stored in the returned configuration object.

Note:

On the strange-looking use of:

exec compile(open(configFile).read(), '<string>', 'exec') in dict()

in this function…

The contents of the config file should be compiled first, and then passed to exec() – not execfile() ! – in order to get the contents of the config file to exist within the scope of the configuration dictionary. Otherwise, Python will default to executing the config file directly within the globals() scope.

Additionally, it’s roughly 20-30 times faster to use the compile() builtin on a string (the contents of the file) before passing it to exec(), than using execfile() directly on the file.

Variables:

itsSafeToUseLogging (bool) – This is called in bridgedb.Main.run() before bridgedb.safelog.configureLogging(). When called from run(), the configCls parameter is not given, because that is the first time that a config has been created. If a logging.Logger is created in this function, then logging will not be correctly configured, therefore, if the configCls parameter is not given, then it’s the first time this function has been called and it is therefore not safe to make calls to the logging module.

Parameters:
  • configFile (str or None) – If given, the filename of the config file to load.
  • configCls (bridgedb.configure.Conf or None) – The current configuration instance, if one already exists.
Returns:

A new configuration, with the old settings as defaults, and the settings from the configFile (if given) overriding those defaults.

class Conf(**attrs)[source]

Bases: object

A configuration object. Holds unvalidated attributes.