configReaders 0.1.0__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: 0.1.0
4
+ Summary: Helper functions for reading keys from JSON and config files
5
+ Author: T. Werstlein
6
+ License: MIT
7
+ Keywords: config,configparser,json,helpers
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+
15
+ #configReaders
16
+ configReaders is a small helper library that reads .cfg, .ini or .json files that contain api keys and passwords.
17
+ 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.
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(file_path)
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 = "file_name.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(file_path)
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 = "file_name.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,55 @@
1
+ #configReaders
2
+ configReaders is a small helper library that reads .cfg, .ini or .json files that contain api keys and passwords.
3
+ 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.
4
+
5
+ ##configReaders
6
+ This is the package that contains readers.py.
7
+
8
+ ##readers.py
9
+ There are methods: read_config and read_json.
10
+
11
+ ###read_config(file_path)
12
+ The read_config method takes in a path to an .cfg or .ini file.
13
+ The .cfg or .ini sould be formatted into sections with your api keys and passwords.
14
+ How you segregate your keys and passwords is up to you, it is your .cfg or .ini after all.
15
+
16
+ -- usage example:
17
+ config_path = "file_name.cfg"
18
+ myKeys = read_config(config_path)
19
+
20
+ for key, value in myKeys['api_keys'].items():
21
+ print(key + ': ' + value)
22
+
23
+ print(myKeys['api_keys']['my_key'])
24
+
25
+ ###read_json(file_path)
26
+ The read_json method takes in a path to a .json file.
27
+ The .json file should be formatted into a dictionary of key/value sets.
28
+
29
+ -- usage example:
30
+ json_path = "file_name.json"
31
+ DB = read_json(json_path)
32
+ print(DB['KEYS']['api_key'])
33
+
34
+
35
+ -- config (.cfg) example:
36
+ [keys]
37
+ api_key1 = key_string1
38
+ api_key2 = key_string2
39
+ exit_keys = q, Q, exit, EXIT, quit, QUIT
40
+
41
+ [passwords]
42
+ api_pword1 = pass_string1
43
+ api_pword2 = pass_string2
44
+
45
+ -- json (.json) example:
46
+ {
47
+ 'api1':{
48
+ 'api_key': 'key_string',
49
+ 'api_pass': 'pass_string',
50
+ }
51
+ 'api2':{
52
+ 'api_key': 'key_string',
53
+ 'api_pass': 'pass_string',
54
+ }
55
+ }
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "configReaders"
7
+ version = "0.1.0"
8
+ description = "Helper functions for reading keys from JSON and config files"
9
+ keywords = ["config", "configparser", "json", "helpers"]
10
+ readme = "README.md"
11
+ requires-python = ">=3.8"
12
+ authors = [
13
+ { name = "T. Werstlein" }
14
+ ]
15
+ license = { text = "MIT" }
16
+ classifiers = [
17
+ "Programming Language :: Python :: 3",
18
+ "Programming Language :: Python :: 3 :: Only",
19
+ "License :: OSI Approved :: MIT License",
20
+ "Operating System :: OS Independent",
21
+ ]
22
+
23
+ [tool.setuptools.packages.find]
24
+ where = ["src"]
25
+ 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: 0.1.0
4
+ Summary: Helper functions for reading keys from JSON and config files
5
+ Author: T. Werstlein
6
+ License: MIT
7
+ Keywords: config,configparser,json,helpers
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3 :: Only
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Operating System :: OS Independent
12
+ Requires-Python: >=3.8
13
+ Description-Content-Type: text/markdown
14
+
15
+ #configReaders
16
+ configReaders is a small helper library that reads .cfg, .ini or .json files that contain api keys and passwords.
17
+ 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.
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(file_path)
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 = "file_name.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(file_path)
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 = "file_name.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