config.manager module¶
Provides a way to create and execute configuration files.
- class config.manager.ConfigManager(filepath, cvar_prefix='', indention=3, max_line_length=79, encoding='utf-8')[source]¶
Bases:
object
Config Management class used to create a config file.
- __init__(filepath, cvar_prefix='', indention=3, max_line_length=79, encoding='utf-8')[source]¶
Initialized the configuration manager.
- Parameters:
filepath (str) – Location where the configuration should be stored. The extension
.cfg
can be skipped. It will be added automatically.cvar_prefix (str) – A prefix that should be added to every console variable.
indention (int) – Number of spaces used to indent values within the configuration file.
max_line_length (int) – Maximum line length within the configuration file.
- command(name, description='')[source]¶
Add/return a command instance to add to the config file.
- Parameters:
name (str) – Name of the command to add.
description (str/TranslationString) – Description of the command.
- Return type:
_CommandManager
- cvar(name, default=0, description='', flags=0, min_value=None, max_value=None)[source]¶
Add/return a cvar instance to add to the config file.
- Parameters:
name (str) – Name of the console variable.
default (object) – A default value for the console variable. It will be converted to a string.
description (str/TranslationStrings) – A description of the console variable.
flags (ConVarFlags) – Flags that should be used for the console variable.
min_value (float) – Minimum value.
max_value (float) – Maximum value.
- Return type:
_CvarManager
- section(name, separator='#')[source]¶
Add/return a section instance to add to the config file.
- Parameters:
name (str/TranslationStrings) – Name of the section to add.
separator (str) – A single separator character to use to separate the section.
- Return type:
_SectionManager
- text(text)[source]¶
Add text to the config file.
- Parameters:
text (str/TranslationStrings) – The text to add.
- property filepath¶
Return the file path for the config file.
The path does not include the
.cfg
file extension.- Return type:
- property fullpath¶
Return the full path to the configuration file.
The path include the
.cfg
file extension.- Return type:
path.Path