Skip to main content

A python package to quickly and easily make configs, or other things that your program needs to remember.

Project description

Jade Config

A Python package to quickly and easily make configs, or other things that your program needs to remember.

We've all written data to a text file for later. Sometimes It's fine. Sometimes we read from each line trying to put more than one value in one file, then it gets confusing. This package is a quick and easy way to save data using the shelve module from the Python Standard Library.

This module uses no third-party libraries. It only uses the Standard Library so it downloads really quick.

On Windows, Jade Config, creates three files.

file.bak
file.dat
file.dir

On Mac, Jade Config creates only one.

file.db

Usage


Jade Config is very simple to use.

Download it with:

pip install jade-config

Import it using:

>>> from jade_config import config

Create a file with:

>>> file = config.Config("fileName", True)

Replace 'fileName' with the name of the file. You do not need to include any file extensions. The last parameter is an optional logging feature. Set it to 'True' to enable logging, or to 'False' to disable it. It is False by default, so you can just omit the parameter if you don't need logging. The log file is located at (name of file).log.txt. Each file gets a seperate log file. Enabling logging could be a security vulnerabilty depending on what data you're storing.

From there you can set values

>>> file.setValue("username", "nfoert")
True

The first parameter is the key. The second parameter is the value. This returns True if the value was written, otherwise it throws a UnableToSetValue exception. You can set more than one value per file. Just use different keys, or you'll overwrite the last entry.

After you set a value, you can get it.

>>> get = file.getValue("username")
>>> print(get)
"nfoert"

You can use .getValue for any key in your file.

You can also remove a key from the file.

>>> file.removeKey("username")
[fileName] Removed key 'username'

The full example

from jade_config import config

file = config.Config("test", True)
file.setValue("username", "nfoert")
get = file.getValue("username")
print(get)

file.removeKey("username")

Future updates


  • CLI Support
  • The ability to choose the file location (may need to use a different library than shelve.)

Warning: The files created by this library can still be read by others, eg. hackers, by using Jade Config, shelve or others. Don't store sensitive data like passwords or API Keys! It's certainly more secure than text files, but be careful!

Changelog


  • [1.1.2] [5/24/23] Fixed a bug where if you tried to getValue() a key that couldn't be found, It would throw an UnboundLocalError.
  • [1.1.1] [5/23/23] Made errors more descriptive, added removeKey(), and made the database correctly close after it's done being used.
  • [1.0.1] Patch fixing a small logging confusion
  • [1.0.0] Initial release

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

jade_config-1.1.2.tar.gz (3.9 kB view hashes)

Uploaded Source

Built Distribution

jade_config-1.1.2-py3-none-any.whl (4.2 kB view hashes)

Uploaded Python 3

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