ycleptic.src.yclept module

A class for handling specialized YAML-format input files

class ycleptic.src.yclept.Yclept(basefile: str, userfile: str = '', userdict: dict = None, rcfile: str = '')[source]

Bases: UserDict

A class for handling specialized YAML-format input files, including a base config file and an optional user config file. Inherits from collections.UserDict.

This class reads a base config file and an optional user config file to generate an overal instance configuration state. It allows for recursive processing of attributes and subattributes, and provides methods for generating documentation and interactive help.

Parameters:
  • basefile (str) – The path to the base config file.

  • userfile (str) – The path to the user config file. Optional; if omitted an empty user config is created.

  • userdict (dict) – A dictionary of user-defined configurations. Optional; used instead of userfile when provided.

  • rcfile (str) – The path to a resource config file that extends the base config. Optional.

console_help(arglist: list[str], end: str = '', **kwargs)[source]

Interactive help with base config structure

If Y is an initialized instance of Yclept, then

>>> Y.console_help()

will show the name of the top-level attributes and their respective help strings. Each positional argument will drill down another level in the base-config structure.

dump_user(filename: str = 'complete-user.yaml')[source]

Generates a full dump of the processed user config, including all implied default values

make_default_specs(*args)[source]

Generates a partial config based on NULL user input and specified hierarchy

Parameters:

args (str) – The names of the attributes to include in the partial config.

make_doctree(topname: str = 'config_ref', footer_style: str = 'paragraph')[source]

Generates a Sphinx-style documentation tree from the base config file, including a root node.

topname may be a bare name (config_ref) or a path (docs/source/config_ref), allowing the command to be run from any directory without a prior cd.

update_user(new_data: dict = None)[source]

Update the user configuration with new data.

Parameters:

new_data (dict) – A dictionary containing the new user configuration data.