PyLoader#
- class PyLoader(app, filename, *args, **kwargs)#
Bases:
FileLoaderLoad config from a python file.
Follows the syntax of traitlets python config files:
c.ClassName.parameter = 1
but now also:
c.group.subgroup.parameter = True
Arbitrary sections and sub-sections can be specified. The object
cis already defined. It is a simple object only meant to allow for this syntax (PyConfigContainer). Any code will be run, so some logic can be used in the config files directly (changing a value depending on OS or hostname for instance).Sub-configs are not supported (but could be if necessary).
- Parameters:
app (Application)
filename (str)
args (Any)
kwargs (Any)
- load_config()#
Populate the config attribute from python file.
Compile the config file, and execute it with the variable
cdefined as an emptyPyConfigContainerobject.- Return type:
- serialize_item(value, trait)#
Serialize value using repr.
- serialize_section(section, fullpath, comment='full', comment_default=False)#
Serialize a Section and its subsections recursively.
If comments are present, trait are separated by double comment lines (##) that can be read by editors as magic cells separations.
For the key = value lines, we make use of
TraitType.default_value_repr().
- wrap_comment(text)#
Wrap text and return it as commented lines.