repocribro.config¶
-
class
repocribro.config.
Config
(*args, **kwargs)¶ Repocribro app configuration container
-
check
()¶ Check and correct missing mandatory options and sections
Returns: List of errors (string with section and option) Return type: list of str
-
default
¶ Access defaults as property
Returns: Default configuration options Return type: dict
-
mark_mandatory
(section, option)¶ Mark some option within section as mandatory
Parameters: - section (str) – Section with mandatory option
- option (str) – Option to be mandatory
-
read_env
(section, option, env_name)¶ Shorthand for reading ENV variable into config
Parameters: - section (str) – Target config section
- option (str) – Target config option
- env_name (str) – Name of ENV variable
-
read_envs
(prefix)¶ Shorthand for reading ENV variables with given prefix into config
This will load all ENV variables with given prefix, the section name is after prefix and next underscore so section name can not contain undercore. For example
REPOCRIBRO_FLASK_SECRET_KEY
will be loaded to sectionFLASK
and optionSECRET_KEY
(REPOCRIBRO
is the prefix).Parameters: prefix (str) – ENV variable name prefix
-
update_flask_cfg
(app)¶ All options from flask section will be inserted to config of the given Flask app
Parameters: app ( flask.Flask
) – Flask application to be configured
-
-
repocribro.config.
check_config
(config, exit_code=1)¶ Procedure for checking mandatory config
If there are some missing mandatory configurations this procedure prints info on stderr and exits program with specified exit code.
Parameters: - config (
repocribro.config.Config
) – Configuration object - exit_code (int) – Exit code on fail
Raises: SystemExit
- config (
-
repocribro.config.
create_config
(cfg_files, env_prefix='REPOCRIBRO')¶ Factory for making Repocribro config object
Parameters: cfg_files – Single or more config file(s) Returns: Constructed config object Return type: repocribro.config.Config