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 details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

Details for the file jade_config-1.1.2.tar.gz.

File metadata

  • Download URL: jade_config-1.1.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for jade_config-1.1.2.tar.gz
Algorithm Hash digest
SHA256 0493d5b66cb1bf5238ad34310221c1262c42987eac675590be37511a0f1ba7ea
MD5 f67249bbec1e51b9a6145eeac1c26b08
BLAKE2b-256 8deaeb4dd43212b5cf481b063869fdb60719d6d57c0e55f6bf399682f3bbe5da

See more details on using hashes here.

File details

Details for the file jade_config-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: jade_config-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for jade_config-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 bfe53a762d12d4f8e90a99f217b8335df47b7e86a249a4d74b7a26ed57459062
MD5 e11dfbc24e8d3b15b08e99e133dcd7e0
BLAKE2b-256 a6dc660b7755c61ea7f5d8efa1c1dcd74e17daea697a4f46986e5b2f9492b15a

See more details on using hashes here.

Supported by

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