Python settings files done simple.
Project description
simplesettings-py
Python settings files done simple. PyPI Page here
Simple docs
simplesettings.clear()
Clears the settings file
simplesettings.save()
Saves a variable to the settings file, example:
import simplesettings
simplesettings.save("Data", 123)
simplesettings.save("MoreData", "real")
simplesettings.save("MoreMoreData", {"You can save": "a dictionary!"})
simplesettings.save("EvenMoreMoreData", ("A", "B", "C"))
Outputted settings file:
(main)
Data = 123
MoreData = real
MoreMoreData = {'You can save': 'a dictionary!'}
EvenMoreMoreData = ('A', 'B', 'C')
simplesettings.save_dict()
Saves an entire dictionary to the settings file in simplesettings format, example:
import simplesettings
a_dictionary = {
"Data": 123,
"MoreData": "One Two Three",
"MoreMoreData": {"You can save": "a dictionary!"},
"EvenMoreMoreData": ("A", "B", "C")
}
simplesettings.save_dict(a_dictionary)
Outputted settings file:
(main)
Data = 123
MoreData = One Two Three
MoreMoreData = {'You can save': 'a dictionary!'}
EvenMoreMoreData = ('A', 'B', 'C')
simplesettings.load()
Loads the settings file into a dictionary; example:
import simplesettings
print(simplesettings.load())
Output: {'main': {'Data': 123, 'MoreData': 'One Two Three', 'MoreMoreData': {'You can save': 'a dictionary!'}, 'EvenMoreMoreData': ('A', 'B', 'C')}}
You can use this to get certain values, example:
import simplesettings
settings = simplesettings.load()
print(settings["main"]["Data"])
Output: 123
simplesettings.loads()
The same as simplesettings.load()
but takes a simplesettings string as an argument, example:
import simplesettings
print(simplesettings.loads(
"""
(main)
Data = 123
MoreData = real
MoreMoreData = {'You can save': 'a dictionary!'}
EvenMoreMoreData = ('A', 'B', 'C')
"""
))
Output: {'main': {'Data': 123, 'MoreData': 'real', 'MoreMoreData': {'You can save': 'a dictionary!'}, 'EvenMoreMoreData': ('A', 'B', 'C')}}
Note that the load()
and loads()
functions will automatically convert strings of integers, floats, booleans, tuples, lists and dictionaries to the right type, don't forget to convert them back to the type you want (which you should be doing anyway x))
Please feel free to create a pull request if you encounter any issues or something that could be improved
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file simplesettings_py-1.0.3.tar.gz
.
File metadata
- Download URL: simplesettings_py-1.0.3.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f7ec794bbd702673118aae458453b852669ffb5c6eb2e06e8e762e6d33494cb |
|
MD5 | d4b9e99458b29c3910b0e15c30351c11 |
|
BLAKE2b-256 | afe5bb78c7f035781e2cf6b700a2d8f0aa07dff64a8ec0d68e8a1efee8e430ec |
File details
Details for the file simplesettings_py-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: simplesettings_py-1.0.3-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dfdf2d99bcf29a9259895860e48748009bbb8c5823d9a9039f9c5cd5240a547 |
|
MD5 | aa9997aad56f89472f05306853cbf515 |
|
BLAKE2b-256 | 3ec6ac929673b30cbe8277da785ebf828ff5c229ee3a9754effc55486de20ced |