velocity-python 0.0.30__py3-none-any.whl → 0.0.32__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/aws/__init__.py +4 -8
- velocity/aws/handlers/response.py +203 -52
- velocity/db/core/column.py +31 -20
- velocity/db/core/database.py +9 -9
- velocity/db/core/engine.py +101 -99
- velocity/db/core/exceptions.py +23 -0
- velocity/db/core/sequence.py +11 -3
- velocity/db/servers/mysql.py +580 -282
- velocity/db/servers/sqlite.py +649 -371
- velocity/db/servers/sqlserver.py +746 -331
- velocity/misc/conv/__init__.py +1 -1
- velocity/misc/conv/iconv.py +106 -143
- velocity/misc/conv/oconv.py +128 -162
- velocity/misc/db.py +25 -19
- velocity/misc/export.py +125 -115
- velocity/misc/format.py +57 -59
- velocity/misc/mail.py +51 -40
- velocity/misc/merge.py +34 -17
- velocity/misc/timer.py +35 -12
- {velocity_python-0.0.30.dist-info → velocity_python-0.0.32.dist-info}/METADATA +1 -1
- velocity_python-0.0.32.dist-info/RECORD +39 -0
- {velocity_python-0.0.30.dist-info → velocity_python-0.0.32.dist-info}/WHEEL +1 -1
- velocity_python-0.0.30.dist-info/RECORD +0 -39
- {velocity_python-0.0.30.dist-info → velocity_python-0.0.32.dist-info}/LICENSE +0 -0
- {velocity_python-0.0.30.dist-info → velocity_python-0.0.32.dist-info}/top_level.txt +0 -0
velocity/misc/merge.py
CHANGED
|
@@ -1,35 +1,52 @@
|
|
|
1
1
|
from copy import deepcopy
|
|
2
2
|
from functools import reduce
|
|
3
|
+
from typing import Dict, List, Any
|
|
3
4
|
|
|
4
5
|
|
|
5
|
-
def deep_merge(*dicts, update=False):
|
|
6
|
+
def deep_merge(*dicts: Dict[str, Any], update: bool = False) -> Dict[str, Any]:
|
|
6
7
|
"""
|
|
7
|
-
|
|
8
|
+
Deeply merges multiple dictionaries.
|
|
9
|
+
|
|
8
10
|
Parameters
|
|
9
11
|
----------
|
|
10
|
-
dicts :
|
|
11
|
-
|
|
12
|
-
update : bool
|
|
13
|
-
|
|
12
|
+
*dicts : Dict[str, Any]
|
|
13
|
+
Variable number of dictionaries to merge.
|
|
14
|
+
update : bool, optional
|
|
15
|
+
If True, updates the first dictionary in-place.
|
|
16
|
+
If False, creates and returns a new merged dictionary. Default is False.
|
|
17
|
+
|
|
14
18
|
Returns
|
|
15
19
|
-------
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
Dict[str, Any]
|
|
21
|
+
The merged dictionary.
|
|
22
|
+
|
|
23
|
+
Notes
|
|
24
|
+
-----
|
|
25
|
+
- If a key's value in two dictionaries is a dictionary, they are merged recursively.
|
|
26
|
+
- If a key's value in two dictionaries is a list, values from the second list
|
|
27
|
+
are added to the first, avoiding duplicates.
|
|
28
|
+
- For all other types, the value from the latter dictionary overwrites the former.
|
|
18
29
|
"""
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
|
|
31
|
+
def merge_into(d1: Dict[str, Any], d2: Dict[str, Any]) -> Dict[str, Any]:
|
|
32
|
+
for key, value in d2.items():
|
|
21
33
|
if key not in d1:
|
|
22
|
-
|
|
23
|
-
elif isinstance(d1[key], dict):
|
|
24
|
-
d1[key] = merge_into(d1[key],
|
|
25
|
-
elif isinstance(d1[key], list) and isinstance(
|
|
26
|
-
d1[key]
|
|
34
|
+
d1[key] = deepcopy(value)
|
|
35
|
+
elif isinstance(d1[key], dict) and isinstance(value, dict):
|
|
36
|
+
d1[key] = merge_into(d1[key], value)
|
|
37
|
+
elif isinstance(d1[key], list) and isinstance(value, list):
|
|
38
|
+
existing_items = set(d1[key])
|
|
39
|
+
d1[key].extend(x for x in value if x not in existing_items)
|
|
40
|
+
existing_items.update(
|
|
41
|
+
value
|
|
42
|
+
) # Keep the set updated for further iterations
|
|
27
43
|
else:
|
|
28
|
-
d1[key] = deepcopy(
|
|
29
|
-
|
|
44
|
+
d1[key] = deepcopy(value) # Overwrite with the new value
|
|
30
45
|
return d1
|
|
31
46
|
|
|
32
47
|
if update:
|
|
48
|
+
# Update the first dictionary in-place
|
|
33
49
|
return reduce(merge_into, dicts[1:], dicts[0])
|
|
34
50
|
else:
|
|
51
|
+
# Create a new dictionary for the merged result
|
|
35
52
|
return reduce(merge_into, dicts, {})
|
velocity/misc/timer.py
CHANGED
|
@@ -1,27 +1,50 @@
|
|
|
1
1
|
import time
|
|
2
|
+
from typing import Optional
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
class Timer:
|
|
5
|
-
def __init__(self, label=
|
|
6
|
+
def __init__(self, label: str = "Timer"):
|
|
7
|
+
"""
|
|
8
|
+
Initializes a Timer instance with an optional label and starts the timer.
|
|
9
|
+
"""
|
|
6
10
|
self._label = label
|
|
11
|
+
self._start: Optional[float] = None
|
|
12
|
+
self._end: Optional[float] = None
|
|
13
|
+
self._diff: Optional[float] = None
|
|
7
14
|
self.start()
|
|
8
15
|
|
|
9
|
-
def start(self):
|
|
10
|
-
|
|
11
|
-
self.
|
|
16
|
+
def start(self) -> None:
|
|
17
|
+
"""Starts or restarts the timer."""
|
|
18
|
+
self._start = time.time()
|
|
19
|
+
self._end = None
|
|
20
|
+
self._diff = None
|
|
12
21
|
|
|
13
|
-
def
|
|
22
|
+
def stop(self) -> float:
|
|
23
|
+
"""Stops the timer and calculates the time elapsed."""
|
|
24
|
+
if self._start is None:
|
|
25
|
+
raise ValueError("Timer has not been started.")
|
|
14
26
|
self._end = time.time()
|
|
15
27
|
self._diff = self._end - self._start
|
|
28
|
+
return self._diff
|
|
16
29
|
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
30
|
+
def elapsed(self) -> float:
|
|
31
|
+
"""Returns the elapsed time in seconds without stopping the timer."""
|
|
32
|
+
if self._start is None:
|
|
33
|
+
raise ValueError("Timer has not been started.")
|
|
34
|
+
return time.time() - self._start
|
|
21
35
|
|
|
36
|
+
def __str__(self) -> str:
|
|
37
|
+
"""Returns a string representation of the time elapsed or final time."""
|
|
38
|
+
if self._diff is not None: # Timer has been stopped
|
|
39
|
+
return f"{self._label}: {self._diff:.4f} s"
|
|
40
|
+
else: # Timer is still running, show elapsed time
|
|
41
|
+
return f"{self._label}: {self.elapsed():.4f} s"
|
|
22
42
|
|
|
23
|
-
|
|
43
|
+
|
|
44
|
+
if __name__ == "__main__":
|
|
24
45
|
t = Timer("My Label")
|
|
25
|
-
time.sleep(.003)
|
|
46
|
+
time.sleep(0.003)
|
|
47
|
+
print(t) # Should display elapsed time
|
|
26
48
|
time.sleep(3)
|
|
27
|
-
|
|
49
|
+
t.stop()
|
|
50
|
+
print(t) # Should display the stopped time (final diff)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: velocity-python
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.32
|
|
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
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
velocity/__init__.py,sha256=8Xcz_RUYvy6ibGGQeUrwa-fEVzDMhSKe2ZnYgytCeTw,88
|
|
2
|
+
velocity/aws/__init__.py,sha256=GBTEr02whnCH3TG-BWCpUC3KfHY3uNxD21g0OvsVJnc,598
|
|
3
|
+
velocity/aws/handlers/__init__.py,sha256=xnpFZJVlC2uoeeFW4zuPST8wA8ajaQDky5Y6iXZzi3A,172
|
|
4
|
+
velocity/aws/handlers/context.py,sha256=UIjNR83y2NSIyK8HMPX8t5tpJHFNabiZvNgmmdQL3HA,1822
|
|
5
|
+
velocity/aws/handlers/lambda_handler.py,sha256=RfEFIIn6a2k0W25AMEOMWCqbpUkXF13kV6vXFVKz0b0,6309
|
|
6
|
+
velocity/aws/handlers/response.py,sha256=LXhtizLKnVBWjtHyE0h0bk-NYDrRpj7CHa7tRz9KkC4,9324
|
|
7
|
+
velocity/aws/handlers/sqs_handler.py,sha256=YBqrEkA6EfkQUVk_kwsSI-HjFJO8-JqYco-p0UYDNXE,3368
|
|
8
|
+
velocity/db/__init__.py,sha256=vrn2AFNAKaqTdnPwLFS0OcREcCtzUCOodlmH54U7ADg,200
|
|
9
|
+
velocity/db/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
+
velocity/db/core/column.py,sha256=nibAue9zBY3ln7S81tgMvCDzpAmrHlBqAjvvzatzB5A,6258
|
|
11
|
+
velocity/db/core/database.py,sha256=r4S_x9ntkdXkwqdPqSgVQ7YB2r68SbKssHyXfSfCJYo,1875
|
|
12
|
+
velocity/db/core/decorators.py,sha256=q3_0j06vZF9J-pPcLjsR2wftp4iXjlGgJ2l70WdtbUo,3271
|
|
13
|
+
velocity/db/core/engine.py,sha256=qubySirnGymBYfQb5hF6EdYUhNr-GSjOmvRNswG9RFI,14535
|
|
14
|
+
velocity/db/core/exceptions.py,sha256=MOWyA1mlMe8eWbFkEHK0Lp9czdplpRyqbAn2JfGmMrM,707
|
|
15
|
+
velocity/db/core/result.py,sha256=keE-SKn4Uw08uoiA_8FdaMzBfiaAIxidQEEsl3TM86U,4945
|
|
16
|
+
velocity/db/core/row.py,sha256=AHopXrrQUp5dCXEMLEDm0iAhswKDtMUdBxjTtPQ7Udk,5659
|
|
17
|
+
velocity/db/core/sequence.py,sha256=4WkXJUE1tea4bo3y8JzJq6KgtU_1yAV6rp3HHrOVAoI,1177
|
|
18
|
+
velocity/db/core/table.py,sha256=d7KyIXAinBBzIqvxIZClJ8d-DGskPucruFiFFT4PtCM,19805
|
|
19
|
+
velocity/db/core/transaction.py,sha256=XeqGkgrleIqC8krrDcqVXWiBAjXx9z67ZecJNjELgiw,6641
|
|
20
|
+
velocity/db/servers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
+
velocity/db/servers/mysql.py,sha256=O3-lP1Y4VmdeAL5PcYcj_mulJBeK7vcoei_v23oo8qc,24272
|
|
22
|
+
velocity/db/servers/postgres.py,sha256=aA4Fkz-PTo-Vi9kpDvWWMt2snv4r93PtQYDzgCg1XIs,42723
|
|
23
|
+
velocity/db/servers/sqlite.py,sha256=_PGg6ECHdOyOMn4tTWX4WlectAukW3Dov7cZxHbVtBM,36198
|
|
24
|
+
velocity/db/servers/sqlserver.py,sha256=ACdkTyJzdFzN-RpmOabKgmMPtCdHzT-FwYH00UpSNyM,34465
|
|
25
|
+
velocity/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
+
velocity/misc/db.py,sha256=MtuNa7Z6F4SBy9wCXqLpSzWOJMkx51Z3vpUxn4FgUqU,2850
|
|
27
|
+
velocity/misc/export.py,sha256=lATvwTe-Of6X7ZtzvJZiFghh9QlyMYZfDfQ_GJyt5yg,5197
|
|
28
|
+
velocity/misc/format.py,sha256=OnjkxEEKzKuwihdf570VDSpsqOJLp0iyW0cuyDaxL-U,2649
|
|
29
|
+
velocity/misc/mail.py,sha256=BrxDqeVsOd0epyJKwrHA-owzs6di2oLA_qJskoTux-c,2553
|
|
30
|
+
velocity/misc/merge.py,sha256=EYtqwnckBllPO60tRALxFRuzmUQ7Wl0qZC6sCgyiZDA,1885
|
|
31
|
+
velocity/misc/timer.py,sha256=cN3aS0t6HLlhYfF2Ir6ihJehxNrWf9ebaLzXUaWRKEA,1637
|
|
32
|
+
velocity/misc/conv/__init__.py,sha256=MLYF58QHjzfDSxb1rdnmLnuEQCa3gnhzzZ30CwZVvQo,40
|
|
33
|
+
velocity/misc/conv/iconv.py,sha256=ThTT3_t0Us5P7UuBa58ko-GKVm30FFUrSmPBd6Gfh90,5660
|
|
34
|
+
velocity/misc/conv/oconv.py,sha256=XdRTQnywWNwVc0FH-8hPHjlTpZNFg80ivIfyTV3mMak,5495
|
|
35
|
+
velocity_python-0.0.32.dist-info/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
|
|
36
|
+
velocity_python-0.0.32.dist-info/METADATA,sha256=teq0KrZ_b16Wx7QWDWpXIChNmAxJMiKbyjBMDt_9uf4,8522
|
|
37
|
+
velocity_python-0.0.32.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
38
|
+
velocity_python-0.0.32.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
|
|
39
|
+
velocity_python-0.0.32.dist-info/RECORD,,
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
velocity/__init__.py,sha256=AdcyndESw30hDhTzKaaDtdbwcCXgJgSyb8BLGlek0pA,88
|
|
2
|
-
velocity/aws/__init__.py,sha256=ukvGrS0R8p6HtYajexOAJ7Kn9CJNlx6yb58W7o-JrAg,620
|
|
3
|
-
velocity/aws/handlers/__init__.py,sha256=xnpFZJVlC2uoeeFW4zuPST8wA8ajaQDky5Y6iXZzi3A,172
|
|
4
|
-
velocity/aws/handlers/context.py,sha256=UIjNR83y2NSIyK8HMPX8t5tpJHFNabiZvNgmmdQL3HA,1822
|
|
5
|
-
velocity/aws/handlers/lambda_handler.py,sha256=RfEFIIn6a2k0W25AMEOMWCqbpUkXF13kV6vXFVKz0b0,6309
|
|
6
|
-
velocity/aws/handlers/response.py,sha256=PlbrTFWZ6-2s7MGqaGAYENVuL63wOC7FlW7ZogFyTKo,3869
|
|
7
|
-
velocity/aws/handlers/sqs_handler.py,sha256=YBqrEkA6EfkQUVk_kwsSI-HjFJO8-JqYco-p0UYDNXE,3368
|
|
8
|
-
velocity/db/__init__.py,sha256=vrn2AFNAKaqTdnPwLFS0OcREcCtzUCOodlmH54U7ADg,200
|
|
9
|
-
velocity/db/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
velocity/db/core/column.py,sha256=vB7dCrcIWFvRG1fgyzDQnEu7j_0KYxUuDSTCWVCYlPc,6153
|
|
11
|
-
velocity/db/core/database.py,sha256=i1hzCkte6onEInH8ZtTI7D2Xj8q3uwU-uL3wn7Ix5oU,1860
|
|
12
|
-
velocity/db/core/decorators.py,sha256=q3_0j06vZF9J-pPcLjsR2wftp4iXjlGgJ2l70WdtbUo,3271
|
|
13
|
-
velocity/db/core/engine.py,sha256=94wVlnapVVmJCRp6NPGrwnqSxCDlC-848Vu42p9RtCs,14643
|
|
14
|
-
velocity/db/core/exceptions.py,sha256=3ZyRq-idtCdtOGyT4rbNsmEyjfP75BMBq9y-Phakxow,684
|
|
15
|
-
velocity/db/core/result.py,sha256=keE-SKn4Uw08uoiA_8FdaMzBfiaAIxidQEEsl3TM86U,4945
|
|
16
|
-
velocity/db/core/row.py,sha256=AHopXrrQUp5dCXEMLEDm0iAhswKDtMUdBxjTtPQ7Udk,5659
|
|
17
|
-
velocity/db/core/sequence.py,sha256=6sUaHJ29ItthNYoAvQy0SMAZURRdDS8bomnmQspJaT4,1083
|
|
18
|
-
velocity/db/core/table.py,sha256=d7KyIXAinBBzIqvxIZClJ8d-DGskPucruFiFFT4PtCM,19805
|
|
19
|
-
velocity/db/core/transaction.py,sha256=XeqGkgrleIqC8krrDcqVXWiBAjXx9z67ZecJNjELgiw,6641
|
|
20
|
-
velocity/db/servers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
|
-
velocity/db/servers/mysql.py,sha256=c0yUG00jvgnhLMJcV8BuOlTL7uGJ3uRPjJ0xVJingbk,21975
|
|
22
|
-
velocity/db/servers/postgres.py,sha256=aA4Fkz-PTo-Vi9kpDvWWMt2snv4r93PtQYDzgCg1XIs,42723
|
|
23
|
-
velocity/db/servers/sqlite.py,sha256=QVdr_ytvCuSSKVgcP_PI05yTU0gNyFRtTmH4XQlQVjQ,34047
|
|
24
|
-
velocity/db/servers/sqlserver.py,sha256=5kRNLNKbaszMww8JrlUvs2viSIb2hDZfn6nSvR52MEU,31593
|
|
25
|
-
velocity/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
26
|
-
velocity/misc/db.py,sha256=ZbAlVjSC-ASfVV69zlLjUqwndQnsUTBBjORyIBNrMUo,2842
|
|
27
|
-
velocity/misc/export.py,sha256=KA_ezon-jd874rHIDMeZSOWTCAuLcA7kayjWZVTewew,4863
|
|
28
|
-
velocity/misc/format.py,sha256=2GwdWOpUqmQjtLJKrHjQjTMFrATF6G1IXkLI1xVPB7U,2301
|
|
29
|
-
velocity/misc/mail.py,sha256=fKfJtEkRKO3f_JbHNw9ThxKHJnChlBMsQwmEDFgj264,2096
|
|
30
|
-
velocity/misc/merge.py,sha256=hBYPJy6lGL8lzb0wK1i1oEAyzragTWKF1rW9_PGHm6s,918
|
|
31
|
-
velocity/misc/timer.py,sha256=wMbV-1yNXeCJo_UPi5sTSslu9hPzokLaIKgd98tyG_4,536
|
|
32
|
-
velocity/misc/conv/__init__.py,sha256=-caOuiqo0mzjP30Rh-3T0bSlt4M-SzJ4SPr2COk9wmg,39
|
|
33
|
-
velocity/misc/conv/iconv.py,sha256=V-PcpDXq7wCmyxZ3sXfzpmVH5Nc9OHScvMH26K7N3bI,4375
|
|
34
|
-
velocity/misc/conv/oconv.py,sha256=TGC6vTcOACtwp_Gpce33ZiVmgqBYQnwBcMNQ1MP6Qdc,4121
|
|
35
|
-
velocity_python-0.0.30.dist-info/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
|
|
36
|
-
velocity_python-0.0.30.dist-info/METADATA,sha256=Y-7JiFFbsnSw4MiYeM679d3NlXrqnluwIH-WFOTDyqw,8522
|
|
37
|
-
velocity_python-0.0.30.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
|
|
38
|
-
velocity_python-0.0.30.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
|
|
39
|
-
velocity_python-0.0.30.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|