craftr.options
¶
Utility functions to read options from the environment.
-
craftr.options.
get
(name, default=None, inherit_global=True)[source]¶ Reads an option value from the environment variables. The option name will be prefixed by the identifier of the module that is currently executed, eg:
# craftr_module(test) from craftr import options, environ value = options.get('debug', inherit_global=False) # is equal to value = environ.get('test.debug')
Parameters: - name – The name of the option.
- default – The default value that is returned if the
option is not set in the environment. If
NotImplemented
is passed for default and the option is not set, aKeyError
is raised. - inherit_global – If this is True, the option is also searched globally (ie. name without the prefix of the currently executed module).
Raises: KeyError – If default is
NotImplemented
and the option does not exist.
-
craftr.options.
get_bool
(name, default=False, inherit_global=True)[source]¶ Read a boolean option. The actual option value is interpreted as boolean value. Allowed values that are interpreted as correct boolean values are:
''
,'true'
,'false''`, ``'yes'
,'no'
,'0'
and'1'
Raises: - KeyError – If default is
NotImplemented
and the option does not exist. - ValueError – If the option exists but has a value that can not be interpreted as boolean.
- KeyError – If default is