Skip to main content

Helper functions for reading keys from JSON and config files

Reason this release was yanked:

semantic versioning and metadata cleaned up. version 0.1.0 is the prefered version to use.

Project description

#configHelpers _I wrote configHelpers to read .cfg, .ini or .json files that contain my api keys and passwords. I found that I was recreating the same functions to perform these takes in multiple scripts and decided to use this as a learning moment to dive into packages.

##configReaders This is the package that contains readers.py.

##Readers.py There are methods: read_config and read_json.

###read_config The read_config method takes in a path to an .cfg or .ini file. The .cfg or .ini sould be formatted into sections with your api keys and passwords. How you segregate your keys and passwords is up to you, it is your .cfg or .ini after all.

-- usage example: config_path = "default.cfg" myKeys = read_config(config_path)

for key, value in myKeys['api_keys'].items(): print(key + ': ' + value)

print(myKeys['api_keys']['my_key'])

###read_json The read_json method takes in a path to a .json file. The .json file should be formatted into a dictionary of key/value sets.

-- usage example: json_path = "openAI.json" DB = read_json(json_path) print(DB['KEYS']['api_key'])

-- config (.cfg) example: [keys] api_key1 = key_string1 api_key2 = key_string2 exit_keys = q, Q, exit, EXIT, quit, QUIT

[passwords]
api_pword1 = pass_string1
api_pword2 = pass_string2

-- json (.json) example: { 'api1':{ 'api_key': 'key_string', 'api_pass': 'pass_string', } 'api2':{ 'api_key': 'key_string', 'api_pass': 'pass_string', } }

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

configreaders-25.7.1.tar.gz (2.2 kB view details)

Uploaded Source

Built Distribution

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

configreaders-25.7.1-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file configreaders-25.7.1.tar.gz.

File metadata

  • Download URL: configreaders-25.7.1.tar.gz
  • Upload date:
  • Size: 2.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for configreaders-25.7.1.tar.gz
Algorithm Hash digest
SHA256 5c3de708cfc4e763310555d881cc3d22e835c41a468726e97dc7dc09cc28f82d
MD5 2d52debe436958377367fb8afb7d500b
BLAKE2b-256 a96970972fc073ba58eae9ed4c436ebfd309bf305396ec76714c8b6a01daa968

See more details on using hashes here.

File details

Details for the file configreaders-25.7.1-py3-none-any.whl.

File metadata

  • Download URL: configreaders-25.7.1-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for configreaders-25.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a30815a4a250005dfa2ecd49579dab881dcbde483e7adb4ad9322b9fed696ab2
MD5 48f9feac26c182034f550ea51f001f90
BLAKE2b-256 cb4481eb845e79e4233e6f4d45db478b2eef7ccd0d4d8eaf11459f6582abbaf9

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