Skip to main content

Python settings files done simple.

Project description

simplesettings-py

Python settings files done simple.

Simple docs

simplesettings.clear() Clears the settings file


simplesettings.save() Saves a variable to the settings file, example:

import simplesettings_py as settings

settings.save("Data", 123)
settings.save("MoreData", "real")
settings.save("MoreMoreData", {"You can save": "a dictionary!"}, table="dictionaries")
settings.save("EvenMoreMoreData", ("A", "B", "C"), table="tuples")

Outputted settings file (by default .settings):

(main)
Data = 123
MoreData = real

(dictionaries)
MoreMoreData = {'You can save': 'a dictionary!'}

(tuples)
EvenMoreMoreData = ('A', 'B', 'C')

simplesettings.save_dict() Saves an entire dictionary to the settings file in simplesettings format, example:

import simplesettings_py as settings

a_dictionary = {
	"Data": 123,
	"MoreData": "One Two Three",
	"MoreMoreData": {"You can save": "a dictionary!"},
	"EvenMoreMoreData": ("A", "B", "C")
}

settings.save_dict(a_dictionary, table="saved_dict")

Outputted settings file:

(saved_dict)
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_py as settings

print(settings.load())

Output: {'saved_dict': {'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_py as settings

settings = settings.load()
print(settings["saved_dict"]["Data"])

Output: 123


simplesettings.loads() The same as simplesettings.load() but takes a simplesettings string as an argument, example:

import simplesettings_py as settings

print(settings.loads(
"""
(main)
Data = 123
MoreData = real
  
(dictionaries)
MoreMoreData = {'You can save': 'a dictionary!'}
  
(tuples)
EvenMoreMoreData = ('A', 'B', 'C')
"""
))

Output: {'main': {'Data': 123, 'MoreData': 'real'}, 'dictionaries': {'MoreMoreData': {'You can save': 'a dictionary!'}}, 'tuples': {'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

simplesettings-py-1.0.4.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

simplesettings_py-1.0.4-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file simplesettings-py-1.0.4.tar.gz.

File metadata

  • Download URL: simplesettings-py-1.0.4.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for simplesettings-py-1.0.4.tar.gz
Algorithm Hash digest
SHA256 2a91917b17f6bd21e74054b8f733a1c0e8f5080a3c1a880d1dedd94955cbbd4e
MD5 52a806371bcd4141fa9aea142908ebea
BLAKE2b-256 d133c9b83f2179c2f217539c9fa4ac2aa75e45597e3c011e76b72b69d39f00be

See more details on using hashes here.

File details

Details for the file simplesettings_py-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for simplesettings_py-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 73b3d7a4140eed36c91f9d7a66f0e226a425331f443db7fbe87ba34e9da764e0
MD5 3141f1743aa1d0f3fc78d72a91138235
BLAKE2b-256 a5a297a2e607c19b9ce21d889979ad2720cd218131943bcccf76b2606e300ee0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page