Skip to main content

A simple json configuration file manager

Project description

Module for creating parameters, saving them and loading from JSON formatted file.

pip install conson

from .conson import Conson

Usage:

  1. Conson(cfile="config.json", cfilepath=os.getcwd(), salt="ch4ng3M3pl3453"): You can set file name/extension and path to config file directory. By default, current working directory is used.

  2. Instance call, parameters: Calling Conson instance will return all kwargs that has already been set by create method. Values modified with .veil method will be encrypted and presented in hex value. Parameters:

     <instance>.file
     <instance>.file = <filename>, <cfilepath=os.getcwd()>
    
     <instance>.salt
     <instance>.salt = <your salt>
    
  3. .create(key, *value): Creates parameter in key=value pair. Accepts single value or list of values. Example:

     settings = Conson()
    
     settings.create(key1, value1, value2, value3)
     settings.create(key2, [value1, value2, value3])
    
  4. .dispose(key): Removes created parameter from instance.

  5. .veil(key, index=0): Passes created value through Fernet SHA-256 encryption. We point the key and value index number. Secret key is based on system-related UUID, so decryption is meant to happen only on device the encryption has place. Example:

    settings.veil("setting1")
    settings.veil("setting3", 1)
    

    Result print(settings()):

    "setting1": "674141414141426c65566a6c6123123330617a41416c6330307a3667794a41535965537733423sdvb347705f464a5648435a39596b586a45304b31506232646b645353355f2d4c4646623546fggf3395a6c4e38595f7358676269513d3d"
    "setting3": "value1", "674141414141426c65566a6c6123123330617a41416c6330307a3667794a41535965537733423sdvb347705f464a5648435a39596b586a45304b31506232646b645353355f2d4c4646623546fggf3395a6c4e38595f7358676269513d3d"
    
  6. .unveil(value): Allows to decrypt veiled(encrypted) values. Value must be already present in instance (by .create or .load). Example:

    settings.unveil(settings()["setting1"])
    settings.unveil(settings()["setting3"][1])
    
  7. .save(): Saves all parameters created to file. Prints result of operation (success/failure).

  8. .load(): Loads json formatted settings from file. Prints result of operation (success/failure).

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

conson-3.0.3.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file conson-3.0.3.tar.gz.

File metadata

  • Download URL: conson-3.0.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for conson-3.0.3.tar.gz
Algorithm Hash digest
SHA256 06165f3077fd3478cc03e9d064839aa3ac4242c09f4a2ebf22805dfe7f90ba5e
MD5 a4545b2532de6c8372f6a79304954891
BLAKE2b-256 ca0c855a53aace8a97b5570a070643deeb786f82acfec436ea3d82686b346259

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