Welcome to ReadSettings’s documentation!

Easily manage a customized settings file in JSON, YML, YAML or TOML which you can use for storing all of the settings for your application.

class readsettings.ReadSettings(path, ext=None, autosave=True)

Bases: object

Main ReadSettings class.

>>> data = ReadSettings(".rs-tmp/t1.json")
>>> data["foo"] = "Hello World"
>>> data["foo"]
'Hello World'
>>> del data["foo"]
>>> data = ReadSettings(".rs-tmp/t0.invalid")
Traceback (most recent call last):
  ...
ValueError: Invalid file type provided!
>>> data = ReadSettings(".rs-tmp/t6.json")
>>> data["helloWorld"] = "newValue"
>>> data = ReadSettings(".rs-tmp/t1.yml")
>>> data["helloWorld"] = "newValue"
>>> data = ReadSettings(".rs-tmp/t1.toml")
>>> data["helloWorld"] = "newValue"

autosave(option=None)

Configure autosaving.

>>> data = ReadSettings(".rs-tmp/t2.json")
>>> data.autosave()
True
>>> data.autosave(False)
False
>>> data.autosave()
False

clear()

Explicit function to clear the settings.

>>> data = ReadSettings(".rs-tmp/t5.json")
>>> data.clear()
>>> data.json()
{}

json(value=None)

Get or set the json object of the settings file.

>>> data = ReadSettings(".rs-tmp/t4.json")
>>> data.json()
{}
>>> data.json({"foo": "bar"})
{'foo': 'bar'}
>>> data.json(["a", "b", "c"])
['a', 'b', 'c']

save()

Force a file save.

>>> data = ReadSettings(".rs-tmp/t3.json")
>>> data["bar"] = "Lorem Ipsum"
>>> data.save()

Indices and tables