zee 0.0.3__py3-none-any.whl → 0.0.4__py3-none-any.whl
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.
- zee/__init__.py +2 -2
- zee/dicts.py +16 -7
- zee/modules.py +1 -2
- {zee-0.0.3.dist-info → zee-0.0.4.dist-info}/METADATA +1 -1
- zee-0.0.4.dist-info/RECORD +8 -0
- {zee-0.0.3.dist-info → zee-0.0.4.dist-info}/WHEEL +1 -1
- zee-0.0.3.dist-info/RECORD +0 -8
- {zee-0.0.3.dist-info → zee-0.0.4.dist-info}/LICENSE +0 -0
- {zee-0.0.3.dist-info → zee-0.0.4.dist-info}/top_level.txt +0 -0
zee/__init__.py
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# of this software and associated documentation files(the "Software"), to deal
|
|
5
5
|
# in the Software without restriction, including without limitation the rights
|
|
6
6
|
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
8
|
# furnished to do so, subject to the following conditions:
|
|
9
9
|
|
|
10
10
|
# The above copyright notice and this permission notice shall be included in
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
from .dicts import query_dict_from_string, update_dict_by_string
|
|
21
|
+
from .dicts import flatten_dict, query_dict_from_string, update_dict_by_string
|
|
22
22
|
from .modules import load_module
|
zee/dicts.py
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# of this software and associated documentation files(the "Software"), to deal
|
|
5
5
|
# in the Software without restriction, including without limitation the rights
|
|
6
6
|
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
8
|
# furnished to do so, subject to the following conditions:
|
|
9
9
|
|
|
10
10
|
# The above copyright notice and this permission notice shall be included in
|
|
@@ -64,6 +64,17 @@ def string_to_dict(path: str, value: Any = None):
|
|
|
64
64
|
return d
|
|
65
65
|
|
|
66
66
|
|
|
67
|
+
def flatten_dict(d: dict, parent: str = '', sep: str = '.'):
|
|
68
|
+
items = {}
|
|
69
|
+
for k, v in d.items():
|
|
70
|
+
nkey = f"{parent}{sep}{k}" if parent else k
|
|
71
|
+
if isinstance(v, dict):
|
|
72
|
+
items.update(flatten_dict(v, nkey, sep=sep))
|
|
73
|
+
else:
|
|
74
|
+
items[nkey] = v
|
|
75
|
+
return items
|
|
76
|
+
|
|
77
|
+
|
|
67
78
|
def merge_dict(target: dict, source: dict):
|
|
68
79
|
"""Merge source to target
|
|
69
80
|
|
|
@@ -78,7 +89,7 @@ def merge_dict(target: dict, source: dict):
|
|
|
78
89
|
tuple: a tuple contains the key and value
|
|
79
90
|
"""
|
|
80
91
|
for k in set(target.keys()) | set(source.keys()):
|
|
81
|
-
|
|
92
|
+
# for k in sorted(set(target.keys()) | set(source.keys())):
|
|
82
93
|
if k in target and k in source:
|
|
83
94
|
if isinstance(target[k], dict) and isinstance(source[k], dict):
|
|
84
95
|
yield (k, dict(merge_dict(target[k], source[k])))
|
|
@@ -112,9 +123,7 @@ def query_dict_from_string(path: str, source: dict = {}):
|
|
|
112
123
|
source = source[key]
|
|
113
124
|
except KeyError as e:
|
|
114
125
|
raise KeyError(f'{path} not found!')
|
|
115
|
-
|
|
116
|
-
return source
|
|
117
|
-
# if not isinstance(source, dict):
|
|
118
|
-
# return source
|
|
119
126
|
|
|
120
|
-
|
|
127
|
+
return source
|
|
128
|
+
# if not isinstance(source, dict):
|
|
129
|
+
# return source
|
zee/modules.py
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
# of this software and associated documentation files(the "Software"), to deal
|
|
5
5
|
# in the Software without restriction, including without limitation the rights
|
|
6
6
|
# to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
|
|
7
|
-
# copies of the Software, and to permit persons to whom the Software is
|
|
7
|
+
# copies of the Software, and to permit persons to whom the Software is
|
|
8
8
|
# furnished to do so, subject to the following conditions:
|
|
9
9
|
|
|
10
10
|
# The above copyright notice and this permission notice shall be included in
|
|
@@ -53,4 +53,3 @@ def load_module(modname: str, location: str = '', verbose: bool = True) -> Modul
|
|
|
53
53
|
# package, name = name.rsplit('.', 1)
|
|
54
54
|
module = import_module(name)
|
|
55
55
|
return module
|
|
56
|
-
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
zee/__init__.py,sha256=daAON9WVwYf7vKJ_87v69ZuVxortr1bKB1yuLsigGd0,1218
|
|
2
|
+
zee/dicts.py,sha256=_FCLdne7rxIjU7b1LvFjKxl8Njx55eD3D3UT4qpdWPY,4159
|
|
3
|
+
zee/modules.py,sha256=ZarDpqQGUjAGfFYT3q2TQcrMosNW3CEkyG_MfWWaO7U,2435
|
|
4
|
+
zee-0.0.4.dist-info/LICENSE,sha256=x3_XlAxJv8eKBMOwlOY6BuAG9rGlqXiVG7PsFJb7nf8,1080
|
|
5
|
+
zee-0.0.4.dist-info/METADATA,sha256=tfufSfUsyLgtA5GV5Z_hA2_ewVXziYHelW--4kTso9I,859
|
|
6
|
+
zee-0.0.4.dist-info/WHEEL,sha256=OVMc5UfuAQiSplgO0_WdW7vXVGAt9Hdd6qtN4HotdyA,91
|
|
7
|
+
zee-0.0.4.dist-info/top_level.txt,sha256=dd8XvBYxs9R92Nb3XbtQNIVj1TBR3v3iKHmQrc9Nkhs,4
|
|
8
|
+
zee-0.0.4.dist-info/RECORD,,
|
zee-0.0.3.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
zee/__init__.py,sha256=YpyYkeK8s_tMGoGxsmquFVEKoCA-BFFCZ7SKd2U4gaA,1205
|
|
2
|
-
zee/dicts.py,sha256=KFZ51DI09sJN9MtD5Bw5EC40w-AQ9SurtIXOkEhPVwE,3862
|
|
3
|
-
zee/modules.py,sha256=TEjDoVFKt7z6Hr2J5_AS0gmGhmEb-avBt4GRFraNtE4,2438
|
|
4
|
-
zee-0.0.3.dist-info/LICENSE,sha256=x3_XlAxJv8eKBMOwlOY6BuAG9rGlqXiVG7PsFJb7nf8,1080
|
|
5
|
-
zee-0.0.3.dist-info/METADATA,sha256=bkbR2JaZTH_jphiIiqSJ5295TvIiD2xvLMeQ-oraqE0,859
|
|
6
|
-
zee-0.0.3.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
|
7
|
-
zee-0.0.3.dist-info/top_level.txt,sha256=dd8XvBYxs9R92Nb3XbtQNIVj1TBR3v3iKHmQrc9Nkhs,4
|
|
8
|
-
zee-0.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|