PREFS is Python library that stores preferences in a text file with a dictionary-like structure.
Features
- Simple syntax.
- Supports tree/cascade in nested dictionaries.
- Supports
export
/import
JSON files. - Supports
export
/import
YAML files. - Supports bytes and ranges.
- Create a PREFS file manually and read it..
- Resource system to bundle PREFS files.
- Simple Command Line Interface tool.
Limitations
- Keys can only be strings.
- The supported types are int, float, str, list, tuple, set, dict, bytes and ranges.
Example
import prefs
default_prefs = {
"lang": "en",
"theme": "dark",
"scheme": {
"background-color": "#AB2E6A",
"font": {
"color": "#129396",
"size": 15
"family": "UbuntuMono"
}
}
}
my_prefs = prefs.Prefs(default_prefs, path="settings.prefs")
print(my_prefs["scheme/font/size"])
>>> 15
my_prefs["scheme/font/size"] = 20
my_prefs.pop("theme")
A new file got created that looks like:
settings.prefs
#PREFS
lang='en'
scheme=>
background-color='#AB2E6A'
font=>
color='#129396'
size=20
family='UbuntuMono'