velocity-python 0.0.73__py3-none-any.whl → 0.0.74__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 velocity-python might be problematic. Click here for more details.
- velocity/__init__.py +1 -1
- velocity/misc/format.py +15 -15
- {velocity_python-0.0.73.dist-info → velocity_python-0.0.74.dist-info}/METADATA +1 -1
- {velocity_python-0.0.73.dist-info → velocity_python-0.0.74.dist-info}/RECORD +7 -7
- {velocity_python-0.0.73.dist-info → velocity_python-0.0.74.dist-info}/WHEEL +0 -0
- {velocity_python-0.0.73.dist-info → velocity_python-0.0.74.dist-info}/licenses/LICENSE +0 -0
- {velocity_python-0.0.73.dist-info → velocity_python-0.0.74.dist-info}/top_level.txt +0 -0
velocity/__init__.py
CHANGED
velocity/misc/format.py
CHANGED
|
@@ -2,6 +2,7 @@ import decimal
|
|
|
2
2
|
import json
|
|
3
3
|
from typing import Union
|
|
4
4
|
from types import FunctionType, MethodType
|
|
5
|
+
from datetime import datetime, date, time, timedelta
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
def gallons(data: Union[None, str, float, decimal.Decimal]) -> str:
|
|
@@ -63,25 +64,24 @@ def to_json(o, datefmt: str = "%Y-%m-%d", timefmt: str = "%H:%M:%S") -> str:
|
|
|
63
64
|
try:
|
|
64
65
|
if hasattr(obj, "to_json"):
|
|
65
66
|
return obj.to_json()
|
|
66
|
-
|
|
67
|
+
if isinstance(obj, decimal.Decimal):
|
|
67
68
|
return float(obj)
|
|
68
|
-
|
|
69
|
+
if isinstance(obj, datetime):
|
|
69
70
|
return obj.strftime(f"{datefmt} {timefmt}")
|
|
70
|
-
|
|
71
|
+
if isinstance(obj, date):
|
|
71
72
|
return obj.strftime(datefmt)
|
|
72
|
-
|
|
73
|
+
if isinstance(obj, time):
|
|
73
74
|
return obj.strftime(timefmt)
|
|
74
|
-
|
|
75
|
-
return str(obj) # Or use
|
|
76
|
-
|
|
77
|
-
return f"WARNING: unserializable: method {obj
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
75
|
+
if isinstance(obj, timedelta):
|
|
76
|
+
return str(obj) # Or use human_delta(obj) if preferred
|
|
77
|
+
if isinstance(obj, (FunctionType, MethodType)):
|
|
78
|
+
return f"WARNING: unserializable: method {getattr(obj, '__name__', 'anonymous')}"
|
|
79
|
+
return f"WARNING: unserializable: {type(obj).__name__}" + (
|
|
80
|
+
f" ({getattr(obj, '__name__', '')})"
|
|
81
|
+
if hasattr(obj, "__name__")
|
|
82
|
+
else ""
|
|
83
|
+
)
|
|
84
84
|
except Exception as e:
|
|
85
|
-
return f"WARNING:
|
|
85
|
+
return f"WARNING: failed to serialize {type(obj).__name__}: {e}"
|
|
86
86
|
|
|
87
87
|
return json.dumps(o, cls=JsonEncoder, indent=2)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: velocity-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.74
|
|
4
4
|
Summary: A rapid application development library for interfacing with data storage
|
|
5
5
|
Author-email: Paul Perez <pperez@codeclubs.org>
|
|
6
6
|
Project-URL: Homepage, https://codeclubs.org/projects/velocity
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
velocity/__init__.py,sha256=
|
|
1
|
+
velocity/__init__.py,sha256=iGFXefwjGUAnNVu8T5y7RGuPAPMorbJz0f4m5K5j-lI,88
|
|
2
2
|
velocity/aws/__init__.py,sha256=GBTEr02whnCH3TG-BWCpUC3KfHY3uNxD21g0OvsVJnc,598
|
|
3
3
|
velocity/aws/handlers/__init__.py,sha256=xnpFZJVlC2uoeeFW4zuPST8wA8ajaQDky5Y6iXZzi3A,172
|
|
4
4
|
velocity/aws/handlers/context.py,sha256=UIjNR83y2NSIyK8HMPX8t5tpJHFNabiZvNgmmdQL3HA,1822
|
|
@@ -33,7 +33,7 @@ velocity/db/servers/postgres/types.py,sha256=Wa45ppVf_pdWul-jYWFRGMl6IdSq8dAp10S
|
|
|
33
33
|
velocity/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
34
34
|
velocity/misc/db.py,sha256=MPgt-kkukKR_Wh_S_5W-MyDgaeoZ4YLoDJ54wU2ppm4,2830
|
|
35
35
|
velocity/misc/export.py,sha256=lATvwTe-Of6X7ZtzvJZiFghh9QlyMYZfDfQ_GJyt5yg,5197
|
|
36
|
-
velocity/misc/format.py,sha256=
|
|
36
|
+
velocity/misc/format.py,sha256=jwZDEniBMTyh4UysiOdy14OWyd7-hseBNKFRZDckuQM,3214
|
|
37
37
|
velocity/misc/mail.py,sha256=BrxDqeVsOd0epyJKwrHA-owzs6di2oLA_qJskoTux-c,2553
|
|
38
38
|
velocity/misc/merge.py,sha256=EYtqwnckBllPO60tRALxFRuzmUQ7Wl0qZC6sCgyiZDA,1885
|
|
39
39
|
velocity/misc/timer.py,sha256=cN3aS0t6HLlhYfF2Ir6ihJehxNrWf9ebaLzXUaWRKEA,1637
|
|
@@ -41,8 +41,8 @@ velocity/misc/tools.py,sha256=_bGneHHA_BV-kUonzw5H3hdJ5AOJRCKfzhgpkFbGqIo,1502
|
|
|
41
41
|
velocity/misc/conv/__init__.py,sha256=MLYF58QHjzfDSxb1rdnmLnuEQCa3gnhzzZ30CwZVvQo,40
|
|
42
42
|
velocity/misc/conv/iconv.py,sha256=d4_BucW8HTIkGNurJ7GWrtuptqUf-9t79ObzjJ5N76U,10603
|
|
43
43
|
velocity/misc/conv/oconv.py,sha256=h5Lo05DqOQnxoD3y6Px_MQP_V-pBbWf8Hkgkb9Xp1jk,6032
|
|
44
|
-
velocity_python-0.0.
|
|
45
|
-
velocity_python-0.0.
|
|
46
|
-
velocity_python-0.0.
|
|
47
|
-
velocity_python-0.0.
|
|
48
|
-
velocity_python-0.0.
|
|
44
|
+
velocity_python-0.0.74.dist-info/licenses/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
|
|
45
|
+
velocity_python-0.0.74.dist-info/METADATA,sha256=xqlwCWTD5-qSePkvEjLVitGJQesEixuE0x63aOKtyBU,8541
|
|
46
|
+
velocity_python-0.0.74.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
47
|
+
velocity_python-0.0.74.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
|
|
48
|
+
velocity_python-0.0.74.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|