用于管理脚本特定设置和多个配置的小型实用程序
smallconfig的Python项目详细描述
小配置
对于python3.8+。在
用于管理脚本特定设置和多个
配置。配置文件存储在Appdata/Roaming
中
.json文件。仅使用标准库。在
快速启动
此实用程序包含一个模板类SmallConfig
,该类处理
同一脚本的多个配置文件。在
创建SmallConfig
的子类,该类实现
manager_name
和default_config
属性。在
fromsmallconfigimportSmallConfigasSmallConfigTemplateclassSmallConfig(SmallConfigTemplate):@propertydefmanager_name(self):return'ExampleManagerName'@propertydefdefault_config(self):return{'key':'value','is_example':True,}
然后创建类的实例。将默认配置设置为 清理函数调用。在
^{pr2}$其他有用的功能,主要用于处理多种配置:
# returns a list of full file paths to configs with given manager nameconfig.get_configs()# gets the config dictionary of a given config nameconfig.get_config('config.json')# reloads the cache of a config directly from a fileconfig.reload()# creates a new configuration file (with default settings)config.create_config('newconfig.json')# sets the default configurationconfig.set_active_config('otherconfig.json')
- 项目
标签: