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.

@@ -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)
@@ -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
- if isinstance(data, dict):
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python3-commons
3
- Version: 0.0.15
3
+ Version: 0.0.17
4
4
  Summary: Re-usable Python3 code
5
5
  Home-page: https://github.com/kamikaze/python3-commons
6
6
  Author: Oleg Korsak
@@ -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=Gax-RrJAnEeGK94THJe-Dp13YsCl9Ae3GVrqN6tlNj4,1094
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=9oJ2pVC5uLdBKhBJy3WKaQdL6UvaM2__wWCovFnDg1I,1307
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.15.dist-info/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
14
- python3_commons-0.0.15.dist-info/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
15
- python3_commons-0.0.15.dist-info/METADATA,sha256=R7nEYWeBJMssBieubE_vJWSvA0OVJV49Ztb_J3dZu8Q,902
16
- python3_commons-0.0.15.dist-info/WHEEL,sha256=a-zpFRIJzOq5QfuhBzbhiA1eHTzNCJn8OdRvhdNX0Rk,110
17
- python3_commons-0.0.15.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
18
- python3_commons-0.0.15.dist-info/RECORD,,
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,,