cement.ext.ext_yaml_configobj
¶
The Yaml ConfigObj Extension is a combination of the
YamlConfigHandler
and ConfigObjConfigHandler
which allows
the application to read Yaml configuration files into a ConfigObj based
configuration handler.
Requirements¶
- ConfigObj (
pip install configobj
)- pyYaml (
pip install pyYaml
)
Configuration¶
This extension does not honor any application configuration settings.
Usage¶
myapp.conf
---
myapp:
foo: bar
myapp.py
from cement.core.foundation import CementApp
class MyApp(CementApp):
class Meta:
label = 'myapp'
extensions = ['yaml_configobj']
config_handler = 'yaml_configobj'
with MyApp() as app:
app.run()
# get config settings
app.config['myapp']['foo']
# set config settings
app.config['myapp']['foo'] = 'bar2'
# etc...
-
class
cement.ext.ext_yaml_configobj.
YamlConfigObjConfigHandler
(*args, **kw)¶ Bases:
cement.ext.ext_configobj.ConfigObjConfigHandler
This class implements the IConfig interface, and provides the same functionality of ConfigObjConfigHandler but with YAML configuration files. See pyYAML for more information on pyYAML
Note This extension has an external dependency on pyYAML and ConfigObj. You must include pyYAML and configobj in your application’s dependencies as Cement explicitly does not include external dependencies for optional extensions.
-
class
Meta
¶ Bases:
object
Handler meta-data.
-
YamlConfigObjConfigHandler.
_parse_file
(file_path)¶ Parse YAML configuration file settings from file_path, overwriting existing config settings. If the file does not exist, returns False.
Parameters: file_path – The file system path to the YAML configuration file. Returns: boolean
-
class