A package to manage settings files.
pip install git+https://github.com/rgossington/settings-manager.git
from settingsmanager import SettingsManager
settings = SettingsManager("settings.txt")
Reads the contents of 'settings.txt' into the settings instance. Will create 'settings.txt' in the working directory if it does not already exist.
settings.add_section("general")
settings.add_entry("new_key", "new value", "general")
or
settings.add_entry("new_key", "new value", settings.general)
or
settings.general.add_entry("new_key", "new value")
settings.general.new_key = "edited value"
or
settings.general.set_value("new_key", "edited_value")
or
settings.set_value("new_key", "edited_value", "general")
settings.general.new_key
Will return the value of 'new_key'.
The following method returns a list of Section instances from the SettingsManager instance:
settings.get_sections()
settings.save()
The settings can be reloaded from the file by using:
settings.refresh()
The following method will return True if the file has changed since the last refresh:
settings.refresh_and_has_changed()
By default, all booleans, integers and floats will be parsed. These can be disabled individually when creating the SettingsManager instance:
settings = SettingsManager(file_path, parse_bool=False, parse_int=False, parse_float=False)
- Prevention of adding multiple sections with the same same
- Section and key removal methods