pecan.configuration – Pecan Configuration Engine

The pecan.configuration module provides an implementation of a Python-based configuration engine for Pecan applications.

class pecan.configuration.Config(conf_dict={}, filename='')

Bases: object

Base class for Pecan configurations.

Create a Pecan configuration object from a dictionary or a filename.

Parameters
  • conf_dict – A python dictionary to use for the configuration.

  • filename – A filename to use for the configuration.

to_dict(prefix=None)

Converts recursively the Config object into a valid dictionary.

Parameters

prefix – A string to optionally prefix all key elements in the returned dictonary.

update(conf_dict)

Updates this configuration with a dictionary.

Parameters

conf_dict – A python dictionary to update this configuration with.

class pecan.configuration.ConfigDict

Bases: dict

pecan.configuration.conf_from_dict(conf_dict)

Creates a configuration dictionary from a dictionary.

Parameters

conf_dict – The configuration dictionary.

pecan.configuration.conf_from_file(filepath)

Creates a configuration dictionary from a file.

Parameters

filepath – The path to the file.

pecan.configuration.get_conf_path_from_env()

If the PECAN_CONFIG environment variable exists and it points to a valid path it will return that, otherwise it will raise a RuntimeError.

pecan.configuration.initconf()

Initializes the default configuration and exposes it at pecan.configuration.conf, which is also exposed at pecan.conf.

pecan.configuration.set_config(config, overwrite=False)

Updates the global configuration.

Parameters

config – Can be a dictionary containing configuration, or a string which represents a (relative) configuration filename.