maleo-foundation 0.2.59__py3-none-any.whl → 0.2.62__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.
@@ -3,7 +3,6 @@ from .formatter import BaseFormatter
3
3
  from .exceptions import BaseExceptions
4
4
  from .extractor import BaseExtractors
5
5
  from .loaders import BaseLoaders
6
- from .mergers import BaseMergers
7
6
  from .controller import BaseControllerUtils
8
7
  from .query import BaseQueryUtils
9
8
 
@@ -12,6 +11,5 @@ class BaseUtils:
12
11
  Exceptions = BaseExceptions
13
12
  Extractors = BaseExtractors
14
13
  Loaders = BaseLoaders
15
- Mergers = BaseMergers
16
14
  Controller = BaseControllerUtils
17
15
  Query = BaseQueryUtils
@@ -0,0 +1,21 @@
1
+ from collections.abc import Mapping
2
+ from typing import Dict
3
+
4
+ def deep_merge(*obj:Dict) -> Dict:
5
+ def merge_dicts(a:Dict, b:Dict) -> Dict:
6
+ result = dict(a)
7
+ for key, value in b.items():
8
+ if (
9
+ key in result
10
+ and isinstance(result[key], Mapping)
11
+ and isinstance(value, Mapping)
12
+ ):
13
+ result[key] = merge_dicts(result[key], value)
14
+ else:
15
+ result[key] = value
16
+ return result
17
+
18
+ merged = {}
19
+ for ob in obj:
20
+ merged = merge_dicts(merged, ob)
21
+ return merged
@@ -0,0 +1,15 @@
1
+ from typing import Dict, List
2
+
3
+ def deep_search(d:Dict, key:str) -> List:
4
+ """Recursively search for all values of a key in a nested Dict/List."""
5
+ results = []
6
+ if isinstance(d, Dict):
7
+ for k, v in d.items():
8
+ if k == key:
9
+ results.append(v)
10
+ elif isinstance(v, (Dict, List)):
11
+ results.extend(deep_search(v, key))
12
+ elif isinstance(d, List):
13
+ for item in d:
14
+ results.extend(deep_search(item, key))
15
+ return results
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: maleo_foundation
3
- Version: 0.2.59
3
+ Version: 0.2.62
4
4
  Summary: Foundation package for Maleo
5
5
  Author-email: Agra Bima Yuda <agra@nexmedis.com>
6
6
  License: MIT
@@ -97,15 +97,16 @@ maleo_foundation/models/transfers/results/service/general.py,sha256=RfxzBNZQhMNw
97
97
  maleo_foundation/models/transfers/results/service/repository.py,sha256=djITRZh2jrncxd19MyCYBux8C7u906u224U2DPgAQI8,1471
98
98
  maleo_foundation/models/transfers/results/service/controllers/__init__.py,sha256=HZJWMy2dskzOCzLmp_UaL9rjbQ-sDMI7sd2bXb-4QOU,175
99
99
  maleo_foundation/models/transfers/results/service/controllers/rest.py,sha256=wCuFyOTQkuBs2cqjPsWnPy0XIsCfMqGByhrSy57qp7Y,1107
100
- maleo_foundation/utils/__init__.py,sha256=SRPEVoqjZoO6W8rtF_Ti8VIangg6Auwm6eHbZMdOthY,520
100
+ maleo_foundation/utils/__init__.py,sha256=KoERe8U2ERGZeAKUNBPW_itk7g9YpH7v7_mD9_i050o,461
101
101
  maleo_foundation/utils/client.py,sha256=F5X9TUxWQgeOHjwsMpPoSRhZANQYZ_iFv0RJDTUVhrw,2820
102
102
  maleo_foundation/utils/controller.py,sha256=XhCcRy-OxJzv0xkZmVEBOkYqbaAckHaMaW6ND6Be-_c,4520
103
103
  maleo_foundation/utils/exceptions.py,sha256=kDLTWiUauvc-fSKrEyxlGvIi2NtZIAhJ9bV3OXnpTyo,6253
104
104
  maleo_foundation/utils/extractor.py,sha256=SZXVYDHWGaA-Dd1BUydwF2HHdZqexEielS4CjL0Ceng,814
105
105
  maleo_foundation/utils/logging.py,sha256=W5Fhk_xAXVqSujaY8mv3hRH4wlQSpUn4ReuMoiKcQa4,7759
106
- maleo_foundation/utils/mergers.py,sha256=DniUu3Ot4qkYH_YSw4uD1cn9cfirum4S_Opp8fMkQwA,702
106
+ maleo_foundation/utils/merger.py,sha256=z9GROLVtGpwx84bOiakBFphKazsI-9l3F3WauTDwQLs,597
107
107
  maleo_foundation/utils/query.py,sha256=nDj-9Q-5eAOvqXqKgKjtHaFAxVAY87E0BMaVXmTN7jA,7957
108
108
  maleo_foundation/utils/repository.py,sha256=knBi3xOLlhBIEtChvqbZh4wXmgrFCB3rDwQXy41d7_c,2852
109
+ maleo_foundation/utils/searcher.py,sha256=gsseMkr0swKj3l-xil5qqncTbYNkS96eieFE_ehaF8I,504
109
110
  maleo_foundation/utils/dependencies/__init__.py,sha256=0KKGrdfj8Cc5A4SRk_ZBAxzOP795Mizdb4zIBh07KC4,122
110
111
  maleo_foundation/utils/dependencies/auth.py,sha256=wS9qnmd1n2WsFhiSfyq_3Io3wwZKTENVPv4rMwxJslE,727
111
112
  maleo_foundation/utils/formatter/__init__.py,sha256=iKf5YCbEdg1qKnFHyKqqcQbqAqEeRUf8mhI3v3dQoj8,78
@@ -117,7 +118,7 @@ maleo_foundation/utils/loaders/credential/__init__.py,sha256=qopTKvcMVoTFwyRijeg
117
118
  maleo_foundation/utils/loaders/credential/google.py,sha256=SKsqPuFnAiCcYLf24CxKnMybhVHpgqnq1gGSlThqjts,994
118
119
  maleo_foundation/utils/loaders/key/__init__.py,sha256=hVygcC2ImHc_aVrSrOmyedR8tMUZokWUKCKOSh5ctbo,106
119
120
  maleo_foundation/utils/loaders/key/rsa.py,sha256=gDhyX6iTFtHiluuhFCozaZ3pOLKU2Y9TlrNMK_GVyGU,3796
120
- maleo_foundation-0.2.59.dist-info/METADATA,sha256=qndEK8gX0PhJ3uZ3BitYl6ZlcncfYwH4Oz05Aozx8Mk,3598
121
- maleo_foundation-0.2.59.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
122
- maleo_foundation-0.2.59.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
123
- maleo_foundation-0.2.59.dist-info/RECORD,,
121
+ maleo_foundation-0.2.62.dist-info/METADATA,sha256=YHruZS9nCTQHrcO0se4LewI5rveFO_GMulIRZitoqGA,3598
122
+ maleo_foundation-0.2.62.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
123
+ maleo_foundation-0.2.62.dist-info/top_level.txt,sha256=_iBos3F_bhEOdjOnzeiEYSrCucasc810xXtLBXI8cQc,17
124
+ maleo_foundation-0.2.62.dist-info/RECORD,,
@@ -1,23 +0,0 @@
1
- from collections.abc import Mapping
2
- from typing import Dict
3
-
4
- class BaseMergers:
5
- @staticmethod
6
- def deep_merge(*obj:Dict) -> Dict:
7
- def merge_dicts(a:Dict, b:Dict) -> Dict:
8
- result = dict(a)
9
- for key, value in b.items():
10
- if (
11
- key in result
12
- and isinstance(result[key], Mapping)
13
- and isinstance(value, Mapping)
14
- ):
15
- result[key] = merge_dicts(result[key], value)
16
- else:
17
- result[key] = value
18
- return result
19
-
20
- merged = {}
21
- for ob in obj:
22
- merged = merge_dicts(merged, ob)
23
- return merged