devctrl.utility.config_file.ConfigFile#

class ConfigFile(filepath: str, init_values=None)[source]#

Bases: object

Class managing a yaml config file. The file is loaded on creation and can be saved with .save().

You may initialize an instance with empty string as filepath, in this case no file will not be loaded or saved.

Methods

get

get_or

get_path

Get a path with ~ and environment variables expanded :raise KeyError: if name is not a valid key

get_path_or

get_values

Get a copy of the values dictionary

save

Save the current variables to the config file

set

set_values

Set the values from a dictionary

__annotations__ = {}#
__contains__(item)[source]#
__dict__ = mappingproxy({'__module__': 'devctrl.utility.config_file', '__firstlineno__': 6, '__doc__': '\nClass managing a yaml config file.\nThe file is loaded on creation and can be saved with .save().\n\nYou may initialize an instance with empty string as filepath,\nin this case no file will not be loaded or saved.\n', '__init__': <function ConfigFile.__init__>, 'save': <function ConfigFile.save>, 'get_or': <function ConfigFile.get_or>, 'get': <function ConfigFile.get>, 'get_path': <function ConfigFile.get_path>, 'get_path_or': <function ConfigFile.get_path_or>, 'set': <function ConfigFile.set>, 'get_values': <function ConfigFile.get_values>, 'set_values': <function ConfigFile.set_values>, '__contains__': <function ConfigFile.__contains__>, '__static_attributes__': ('filepath', 'values'), '__dict__': <attribute '__dict__' of 'ConfigFile' objects>, '__weakref__': <attribute '__weakref__' of 'ConfigFile' objects>, '__annotations__': {}})#
__firstlineno__ = 6#
__init__(filepath: str, init_values=None)[source]#
__module__ = 'devctrl.utility.config_file'#
__static_attributes__ = ('filepath', 'values')#
__weakref__#

list of weak references to the object

get(name: str)[source]#
get_or(name: str, default)[source]#
get_path(name: str)[source]#

Get a path with ~ and environment variables expanded :raise KeyError: if name is not a valid key

get_path_or(name: str, default)[source]#
get_values() dict[source]#

Get a copy of the values dictionary

save()[source]#

Save the current variables to the config file

set(name: str, value)[source]#
set_values(values: dict)[source]#

Set the values from a dictionary