python3-commons 0.0.15__py2.py3-none-any.whl → 0.0.17__py2.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.
Potentially problematic release.
This version of python3-commons might be problematic. Click here for more details.
- python3_commons/helpers.py +7 -0
- python3_commons/serializers.py +1 -7
- {python3_commons-0.0.15.dist-info → python3_commons-0.0.17.dist-info}/METADATA +1 -1
- {python3_commons-0.0.15.dist-info → python3_commons-0.0.17.dist-info}/RECORD +8 -8
- {python3_commons-0.0.15.dist-info → python3_commons-0.0.17.dist-info}/AUTHORS.rst +0 -0
- {python3_commons-0.0.15.dist-info → python3_commons-0.0.17.dist-info}/LICENSE +0 -0
- {python3_commons-0.0.15.dist-info → python3_commons-0.0.17.dist-info}/WHEEL +0 -0
- {python3_commons-0.0.15.dist-info → python3_commons-0.0.17.dist-info}/top_level.txt +0 -0
python3_commons/helpers.py
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import datetime
|
|
2
2
|
import logging
|
|
3
3
|
|
|
4
|
+
from decimal import Decimal, ROUND_HALF_UP
|
|
5
|
+
|
|
6
|
+
|
|
4
7
|
logger = logging.getLogger(__name__)
|
|
5
8
|
|
|
6
9
|
|
|
@@ -37,3 +40,7 @@ def tries(times):
|
|
|
37
40
|
return wrapper
|
|
38
41
|
|
|
39
42
|
return func_wrapper
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def round_decimal(value: Decimal, decimal_places=2, rounding_mode=ROUND_HALF_UP):
|
|
46
|
+
return value.quantize(Decimal(10) ** -decimal_places, rounding=rounding_mode)
|
python3_commons/serializers.py
CHANGED
|
@@ -29,10 +29,7 @@ def msgpack_decoder(code, data):
|
|
|
29
29
|
def serialize_msgpack(data) -> bytes:
|
|
30
30
|
logger.debug('Serializing to msgpack', extra={'data': data})
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
result = msgpack.packb({k: serialize_msgpack(v) for k, v in data.items()}, default=msgpack_encoder)
|
|
34
|
-
else:
|
|
35
|
-
result = msgpack.packb(data, default=msgpack_encoder)
|
|
32
|
+
result = msgpack.packb(data, default=msgpack_encoder)
|
|
36
33
|
|
|
37
34
|
logger.debug('Serialized to msgpack', extra={'result': result})
|
|
38
35
|
|
|
@@ -44,9 +41,6 @@ def deserialize_msgpack(data: bytes):
|
|
|
44
41
|
|
|
45
42
|
result = msgpack.unpackb(data, ext_hook=msgpack_decoder)
|
|
46
43
|
|
|
47
|
-
if isinstance(result, dict):
|
|
48
|
-
result = {k: deserialize_msgpack(v) for k, v in result.items()}
|
|
49
|
-
|
|
50
44
|
logger.debug('De-serialized from msgpack', extra={'result': result})
|
|
51
45
|
|
|
52
46
|
return result
|
|
@@ -2,17 +2,17 @@ python3_commons/__init__.py,sha256=h-KTJUaQ50E3RmkTn_GO88IRunmDTEpNc3ylpFvCTOc,3
|
|
|
2
2
|
python3_commons/conf.py,sha256=upatHbTAq5Nb49VrJofZvxYyg3_yDAsl2l2wpjlNM4Y,182
|
|
3
3
|
python3_commons/db.py,sha256=4HaT1wlxvMuddnH-exaZMpnE9cRu91Dwch7MZO-QJJE,779
|
|
4
4
|
python3_commons/fs.py,sha256=wfLjybXndwLqNlOxTpm_HRJnuTcC4wbrHEOaEeCo9Wc,337
|
|
5
|
-
python3_commons/helpers.py,sha256=
|
|
5
|
+
python3_commons/helpers.py,sha256=APBaaJ2dom8ngw9CKNEWZwz1Hcnb215axI1iOxLTgZM,1305
|
|
6
6
|
python3_commons/json.py,sha256=JIVQvw2COzskHqmufae1faX9vKrcvromoQZx0zl9gKs,698
|
|
7
7
|
python3_commons/minio.py,sha256=R6o_yIpoK7SlSWI4jSsgZZF3kwYbTeD9FejGADqo87E,819
|
|
8
8
|
python3_commons/object_storage.py,sha256=AdGbZYA-UaetunIaPdCTQNSVGgbwItU2JjSEUXFbWRA,1724
|
|
9
|
-
python3_commons/serializers.py,sha256=
|
|
9
|
+
python3_commons/serializers.py,sha256=DovymeDcDnBbbV4w0AlBmEyaAEXq4MSE1h1OGtyxE2c,1048
|
|
10
10
|
python3_commons/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
python3_commons/logging/filters.py,sha256=fuyjXZAUm-i2MNrxvFYag8F8Rr27x8W8MdV3ke6miSs,175
|
|
12
12
|
python3_commons/logging/formatter.py,sha256=TPTKNv8FEqyQj0ZHbrgG-_awbUOa53FO0nXUPsKvy3o,498
|
|
13
|
-
python3_commons-0.0.
|
|
14
|
-
python3_commons-0.0.
|
|
15
|
-
python3_commons-0.0.
|
|
16
|
-
python3_commons-0.0.
|
|
17
|
-
python3_commons-0.0.
|
|
18
|
-
python3_commons-0.0.
|
|
13
|
+
python3_commons-0.0.17.dist-info/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
|
|
14
|
+
python3_commons-0.0.17.dist-info/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
|
|
15
|
+
python3_commons-0.0.17.dist-info/METADATA,sha256=xot3ga9PCY-uj4SXCbGbDi4l-K2xV5CdJXH3KNw6uhU,902
|
|
16
|
+
python3_commons-0.0.17.dist-info/WHEEL,sha256=a-zpFRIJzOq5QfuhBzbhiA1eHTzNCJn8OdRvhdNX0Rk,110
|
|
17
|
+
python3_commons-0.0.17.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
|
|
18
|
+
python3_commons-0.0.17.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|