Helper functions for reading keys from JSON and config files
Project description
#configReaders configReaders is a small helper library that reads .cfg, .ini or .json files that contain 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(file_path) 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 = "file_name.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(file_path) 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 = "file_name.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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file configreaders-0.1.0.tar.gz.
File metadata
- Download URL: configreaders-0.1.0.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
113c31bdd8d45563972e859340c4d1225e1484531bdeafc61e5d59b1d14f172c
|
|
| MD5 |
1289a674179fd450cf973055ed8e4810
|
|
| BLAKE2b-256 |
a591302b305820af2bcb6672574e48408d21b7e5ad7d863e89f53b2f7a59898f
|
File details
Details for the file configreaders-0.1.0-py3-none-any.whl.
File metadata
- Download URL: configreaders-0.1.0-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
598aafb6c7e8fd663f93d935a57afa9f129bdee587e331af03fc04acb95c3c21
|
|
| MD5 |
5cf807c0bf147afa16e3e92b87632745
|
|
| BLAKE2b-256 |
4a498e6aeb6decd20bd6f81ae9de6e96fa1bc7528373ea33d85c4b8204758a86
|