Skip to main content

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])
     settings.create(key3, {"subkey1": "value1", "subkey2": value2, "subkey3": value3})
    
  4. .dispose(key): Removes created parameter from instance.

  5. .dump() Removes all created parameters. Useful in case when only one instance is invoked and multiple configuration files are being loaded - allows to prevent mixing parameters simply by dumping them out.

  6. .veil(key, index="0", marker=""): 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. If you want to reach value in nested dictionary, you can use subkey OR it's subkey's index number. You can also pass marker char (or chars) to put as first and last char of returned value, it will help with identifying veiled strings (you can combine unveil with slicing). Example:

       settings.veil("setting1", marker="$")
       settings.veil("setting3", 1)
       settings.veil("setting3", "key", "<>") 
    

    Result print(settings()):

       "setting1": "$674141414141426c65566a6c6123123330617a41416c6330307a3667794a41535965537733423sdvb347705f464a5648435a39596b586a45304b31506232646b645353355f2d4c4646623546fggf3395a6c4e38595f7358676269513d3d$"
       "setting3": "value1", "674141414141426c65566a6c6123123330617a41416c6330307a3667794a41535965537733423sdvb347705f464a5648435a39596b586a45304b31506232646b645353355f2d4c4646623546fggf3395a6c4e38595f7358676269513d3d"
       "setting3": {"key": "<674141414141426c65566a6c6123123330617a41416c6330307a3667794a41535965537733423sdvb347705f464a5648435a39596b586a45304b31506232646b645353355f2d4c4646623546fggf3395a6c4e38595f7358676269513d3d>"}
    
  7. .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])
    settings.unveil(settings()["setting3"]["key"])
    
  8. .save(verbose=False): Saves all parameters created to file. Prints result of operation (success/failure) if verbose parameter has been given.

  9. .load(verbose=False): Loads json formatted settings from file. Prints result of operation (success/failure) if verbose parameter has been given.

Metadata

Release files for conson 3.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for conson 3.2.1
File Size Uploaded
conson-3.2.1.tar.gz 5.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for conson 3.2.1
File Interpreter ABI Platform
conson-3.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 11.6 kB

Release files / conson-3.2.1.tar.gz

Download URL conson-3.2.1.tar.gz
Size 5.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8b53b72bfcfa5c3a48fd0fbb0f3c488696c4a73162741e667657ec0aa1ae1b82
BLAKE2b-256 checksum
How to use checksums
7949a942e4bf5858a60a172777d48761f3aab96fe53b7d04e510a4b43894f09e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.2

Release files / conson-3.2.1-py3-none-any.whl

Download URL conson-3.2.1-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6898aff07738a0f36e538c097daca658d5f908e63c5f98d37e4bc065989cd032
BLAKE2b-256 checksum
How to use checksums
395376305386d228276a53a5eefd6a74e54d5b72f5d20a9e5fb894cd5681cde7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

3.2.1 This release

2 release files

3.1.9

1 release file

3.1.8

1 release file

3.1.7

1 release file

3.1.6

1 release file

3.1.5

1 release file

3.1.0

1 release file

3.0.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page