Skip to main content

User configuration management library

Project description

UserConf

UserConf is a user configuration management Python library. It stores key-value settings in a JSON file and manages data files and directories. The JSON file and the data files and directories are inside a directory that is inside the user home directory.

Usage example

from userconf import UserConf

# Create an instance of the UserConf class providing an application ID. The
# settings JSON file is "settings.json" and the directory for data files and
# directories is "files". The "settings.json" file and the "files" directory
# will be created inside a directory which name is a period (".") followed by
# the application ID, which will be created inside the user's home directory
# (e.g. "/home/user/.app/settings.json" and "/home/user/.app/files" in Linux).
uc = UserConf("example-app")

# Set a setting value providing the setting ID and the value. The value can be
# any JSON serializable object (a string, an integer, a list, a dictionary...).
uc.settings.set("example-key", "Example value")

# Get a setting value given the setting ID. If the ID doesn't exist, None is
# returned.
value = uc.settings.get("example-key")

# Set a default value to return if the setting ID doesn't exist
value = uc.settings.get("example-key-2", "Default value")

# Delete a setting given its ID
uc.settings.delete("example-key")

# Delete all the settings
uc.settings.delete_all()

# Get an absolute path for a data file. This doesn't create the file but it
# creates its directory and all the intermediate directories if they don't
# exist, so that the application using this library can save data in this path
# without having to create its directory.
path = uc.files.get_path("example-file.txt")

How to install

We can install UserConf in the following ways:

Install from PyPI (Python Package Index)

pip install userconf

Install from the source code

python setup.py install

Generate a package and install it

We can generate and install the built package or the source archive from the source code. The wheel package is needed for generating the built package.

To generate and install the built package (preferred), run the following commands from the project directory:

pip install wheel
python setup.py bdist_wheel
pip install ./dist/notelist*.whl

To generate and install the source archive, run the following commands from the project directory:

python setup.py sdist
pip install ./dist/notelist*.tar.gz

How to run the unit tests

To run all the unit tests, run the following command from the project directory:

python -m unittest discover test

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

userconf-0.5.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

userconf-0.5.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file userconf-0.5.0.tar.gz.

File metadata

  • Download URL: userconf-0.5.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for userconf-0.5.0.tar.gz
Algorithm Hash digest
SHA256 efa688a3d86d2427b82843700943f9bc5ea1c027c65e4a366be7c364d4dbd4b6
MD5 b462e0301d7563c7f7d686656c0393ce
BLAKE2b-256 7649244683ba478d3f23c1e1b2b83c2d880e6a47d2ec3ca3d1862eb387cebe4e

See more details on using hashes here.

File details

Details for the file userconf-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: userconf-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.2

File hashes

Hashes for userconf-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 965f09596cd9860e359ce25f872c7a2b25639dcdfbe041366f94ff96a294b89a
MD5 a8807a931189702bb4605bb77858726d
BLAKE2b-256 3f86d982b61dbb772ce235c82e2be700ae93928694ccff7f9d0003131c5779f6

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