configReaders 25.7.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,69 @@
1
+ Metadata-Version: 2.4
2
+ Name: configReaders
3
+ Version: 25.7.1
4
+ Summary: Helper functions for reading keys from JSON and config files
5
+ Author: T. Werstlein
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+
14
+ #configHelpers
15
+ _I wrote configHelpers to read .cfg, .ini or .json files that contain my api keys and passwords.
16
+ I found that I was recreating the same functions to perform these takes in multiple scripts and
17
+ decided to use this as a learning moment to dive into packages.
18
+
19
+ ##configReaders
20
+ This is the package that contains readers.py.
21
+
22
+ ##Readers.py
23
+ There are methods: read_config and read_json.
24
+
25
+ ###read_config
26
+ The read_config method takes in a path to an .cfg or .ini file.
27
+ The .cfg or .ini sould be formatted into sections with your api keys and passwords.
28
+ How you segregate your keys and passwords is up to you, it is your .cfg or .ini after all.
29
+
30
+ -- usage example:
31
+ config_path = "default.cfg"
32
+ myKeys = read_config(config_path)
33
+
34
+ for key, value in myKeys['api_keys'].items():
35
+ print(key + ': ' + value)
36
+
37
+ print(myKeys['api_keys']['my_key'])
38
+
39
+ ###read_json
40
+ The read_json method takes in a path to a .json file.
41
+ The .json file should be formatted into a dictionary of key/value sets.
42
+
43
+ -- usage example:
44
+ json_path = "openAI.json"
45
+ DB = read_json(json_path)
46
+ print(DB['KEYS']['api_key'])
47
+
48
+
49
+ -- config (.cfg) example:
50
+ [keys]
51
+ api_key1 = key_string1
52
+ api_key2 = key_string2
53
+ exit_keys = q, Q, exit, EXIT, quit, QUIT
54
+
55
+ [passwords]
56
+ api_pword1 = pass_string1
57
+ api_pword2 = pass_string2
58
+
59
+ -- json (.json) example:
60
+ {
61
+ 'api1':{
62
+ 'api_key': 'key_string',
63
+ 'api_pass': 'pass_string',
64
+ }
65
+ 'api2':{
66
+ 'api_key': 'key_string',
67
+ 'api_pass': 'pass_string',
68
+ }
69
+ }
@@ -0,0 +1,56 @@
1
+ #configHelpers
2
+ _I wrote configHelpers to read .cfg, .ini or .json files that contain my api keys and passwords.
3
+ I found that I was recreating the same functions to perform these takes in multiple scripts and
4
+ decided to use this as a learning moment to dive into packages.
5
+
6
+ ##configReaders
7
+ This is the package that contains readers.py.
8
+
9
+ ##Readers.py
10
+ There are methods: read_config and read_json.
11
+
12
+ ###read_config
13
+ The read_config method takes in a path to an .cfg or .ini file.
14
+ The .cfg or .ini sould be formatted into sections with your api keys and passwords.
15
+ How you segregate your keys and passwords is up to you, it is your .cfg or .ini after all.
16
+
17
+ -- usage example:
18
+ config_path = "default.cfg"
19
+ myKeys = read_config(config_path)
20
+
21
+ for key, value in myKeys['api_keys'].items():
22
+ print(key + ': ' + value)
23
+
24
+ print(myKeys['api_keys']['my_key'])
25
+
26
+ ###read_json
27
+ The read_json method takes in a path to a .json file.
28
+ The .json file should be formatted into a dictionary of key/value sets.
29
+
30
+ -- usage example:
31
+ json_path = "openAI.json"
32
+ DB = read_json(json_path)
33
+ print(DB['KEYS']['api_key'])
34
+
35
+
36
+ -- config (.cfg) example:
37
+ [keys]
38
+ api_key1 = key_string1
39
+ api_key2 = key_string2
40
+ exit_keys = q, Q, exit, EXIT, quit, QUIT
41
+
42
+ [passwords]
43
+ api_pword1 = pass_string1
44
+ api_pword2 = pass_string2
45
+
46
+ -- json (.json) example:
47
+ {
48
+ 'api1':{
49
+ 'api_key': 'key_string',
50
+ 'api_pass': 'pass_string',
51
+ }
52
+ 'api2':{
53
+ 'api_key': 'key_string',
54
+ 'api_pass': 'pass_string',
55
+ }
56
+ }
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "configReaders"
7
+ version = "25.7.1"
8
+ description = "Helper functions for reading keys from JSON and config files"
9
+ readme = "README.md"
10
+ requires-python = ">=3.8"
11
+ authors = [
12
+ { name = "T. Werstlein" }
13
+ ]
14
+ license = { text = "MIT" }
15
+ classifiers = [
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3 :: Only",
18
+ "License :: OSI Approved :: MIT License",
19
+ "Operating System :: OS Independent",
20
+ ]
21
+
22
+ [tool.setuptools.packages.find]
23
+ where = ["src"]
24
+ include = ["configReaders*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from .readers import (read_config, read_json)
@@ -0,0 +1,38 @@
1
+ import configparser
2
+ import json
3
+
4
+ # use this for .cfg or .ini files
5
+ def read_config(file_path):
6
+ """
7
+ Read from .cfg file
8
+
9
+ Parameters
10
+ ----------
11
+ file_path (str) : the path to the config file
12
+
13
+ Returns
14
+ -------
15
+ see configparser docstring
16
+ """
17
+ config = configparser.ConfigParser()
18
+ config.read(file_path)
19
+ return config
20
+
21
+
22
+
23
+
24
+ def read_json(file_path):
25
+ """
26
+ Reads .json files
27
+
28
+ Parameters
29
+ ----------
30
+ file_path (str) : the path to the json file
31
+
32
+ Returns
33
+ --------
34
+ f (dict) : dictionary
35
+
36
+ """
37
+ with open(file_path, 'r') as f:
38
+ return json.load(f)
@@ -0,0 +1,69 @@
1
+ Metadata-Version: 2.4
2
+ Name: configReaders
3
+ Version: 25.7.1
4
+ Summary: Helper functions for reading keys from JSON and config files
5
+ Author: T. Werstlein
6
+ License: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3 :: Only
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.8
12
+ Description-Content-Type: text/markdown
13
+
14
+ #configHelpers
15
+ _I wrote configHelpers to read .cfg, .ini or .json files that contain my api keys and passwords.
16
+ I found that I was recreating the same functions to perform these takes in multiple scripts and
17
+ decided to use this as a learning moment to dive into packages.
18
+
19
+ ##configReaders
20
+ This is the package that contains readers.py.
21
+
22
+ ##Readers.py
23
+ There are methods: read_config and read_json.
24
+
25
+ ###read_config
26
+ The read_config method takes in a path to an .cfg or .ini file.
27
+ The .cfg or .ini sould be formatted into sections with your api keys and passwords.
28
+ How you segregate your keys and passwords is up to you, it is your .cfg or .ini after all.
29
+
30
+ -- usage example:
31
+ config_path = "default.cfg"
32
+ myKeys = read_config(config_path)
33
+
34
+ for key, value in myKeys['api_keys'].items():
35
+ print(key + ': ' + value)
36
+
37
+ print(myKeys['api_keys']['my_key'])
38
+
39
+ ###read_json
40
+ The read_json method takes in a path to a .json file.
41
+ The .json file should be formatted into a dictionary of key/value sets.
42
+
43
+ -- usage example:
44
+ json_path = "openAI.json"
45
+ DB = read_json(json_path)
46
+ print(DB['KEYS']['api_key'])
47
+
48
+
49
+ -- config (.cfg) example:
50
+ [keys]
51
+ api_key1 = key_string1
52
+ api_key2 = key_string2
53
+ exit_keys = q, Q, exit, EXIT, quit, QUIT
54
+
55
+ [passwords]
56
+ api_pword1 = pass_string1
57
+ api_pword2 = pass_string2
58
+
59
+ -- json (.json) example:
60
+ {
61
+ 'api1':{
62
+ 'api_key': 'key_string',
63
+ 'api_pass': 'pass_string',
64
+ }
65
+ 'api2':{
66
+ 'api_key': 'key_string',
67
+ 'api_pass': 'pass_string',
68
+ }
69
+ }
@@ -0,0 +1,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/configReaders/__init__.py
4
+ src/configReaders/readers.py
5
+ src/configReaders.egg-info/PKG-INFO
6
+ src/configReaders.egg-info/SOURCES.txt
7
+ src/configReaders.egg-info/dependency_links.txt
8
+ src/configReaders.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ configReaders