kisa-utils 0.37.8__py3-none-any.whl → 0.37.10__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.
kisa_utils/db.py CHANGED
@@ -15,6 +15,7 @@ if sqlite3.sqlite_version_info[1]<38:
15
15
  sys.exit(f'we need sqlite3 v3.38.0+ to run this program. current version::{sqlite3.sqlite_version}')
16
16
 
17
17
  MAX_FETCH_ITEMS = 16*1024
18
+ RETURN_KISA_RESPONSES = False # ensure all Handles return KISA-Responses globally
18
19
 
19
20
  __EXT__ = 'sqlite3'
20
21
 
@@ -98,7 +99,7 @@ class Api:
98
99
  *,
99
100
  accessFromMultipleThreads:bool = False,
100
101
  useWALMode:bool = False,
101
- returnKISAResponse:bool = False,
102
+ returnKISAResponse:bool|None = None,
102
103
  ):
103
104
  '''
104
105
  attempt to open an sqlite3 database connection object/instance
@@ -159,7 +160,7 @@ class Api:
159
160
 
160
161
  accessFromMultipleThreads(bool): if set to `True`, access to the handle from difference threads will be permitted
161
162
  useWALMode(bool): if set to `True`, WAL mode will be used for the underlying sqlite3 database
162
- returnKISAResponse(bool): if set to `True`, all public methods that dont return `None` will return KISA Response objects
163
+ returnKISAResponse(bool|None): if not set, `kisa_utils.db.RETURN_KISA_RESPONSES` will be used. if set to `True`, all public methods that dont return `None` will return KISA Response objects
163
164
  '''
164
165
 
165
166
  self._in_with_statement = False
@@ -169,7 +170,7 @@ class Api:
169
170
 
170
171
  self.__transactionMode = True if transactionMode else False
171
172
  self.__withContextCount = 0
172
- self.__returnKISAResponse = returnKISAResponse
173
+ self.__returnKISAResponse = RETURN_KISA_RESPONSES if None==returnKISAResponse else returnKISAResponse
173
174
 
174
175
  if path not in [':memory:', ':ram:',':RAM:']:
175
176
  while path.endswith('/'): path = path[:-1]
@@ -1052,7 +1053,7 @@ def transaction(*dbArgs, **dbKwargs) -> dict|Response:
1052
1053
  + `indices:dict` = {False}
1053
1054
  + `accessFromMultipleThreads:bool` = False
1054
1055
  + `useWALMode:bool` = False
1055
- + `returnKISAResponse:bool` = False
1056
+ + `returnKISAResponse:bool|None` = None | kisa_utils.db.RETURN_KISA_RESPONSES
1056
1057
 
1057
1058
  NB: the exact ordering and naming of `dbArgs` and `dbKwargs` should ALWAYS be got from Api/Handle
1058
1059
 
@@ -59,7 +59,12 @@ def protected(func:Callable) -> Callable:
59
59
  return func(*args, **kwargs)
60
60
  return wrapper
61
61
 
62
- def enforceRequirements(func:Callable) -> Callable:
62
+ # ------------------------------------------------------------------------------
63
+ from typing import ParamSpec, TypeVar
64
+ P = ParamSpec('P')
65
+ T = TypeVar('T')
66
+
67
+ def enforceRequirements(func:Callable[P, T]) -> Callable[P, T]:
63
68
  '''
64
69
  force decorated function to observe the following
65
70
  - have type hints for all `args`, and `kwargs` as well as the `return` type-hint
@@ -68,9 +73,9 @@ def enforceRequirements(func:Callable) -> Callable:
68
73
  - ensure all arguments are given values of the right type when the function is called
69
74
  - return the right data-type as specified by the return type-hint when invoked
70
75
  '''
76
+ signature = inspect.signature(func)
77
+ typeHints = func.__annotations__
71
78
  if 1:
72
- signature = inspect.signature(func)
73
- typeHints = func.__annotations__
74
79
  parameters = signature.parameters
75
80
 
76
81
  if not (func.__doc__ and func.__doc__.strip()):
@@ -118,7 +123,7 @@ def enforceRequirements(func:Callable) -> Callable:
118
123
  # print(registeredArgs, registeredKwargs)
119
124
 
120
125
  @wraps(func)
121
- def w(*args, **kwargs):
126
+ def w(*args:P.args, **kwargs:P.kwargs):
122
127
  for index, arg in enumerate(args):
123
128
  if registeredArgs[index][0] in ['self']: continue
124
129
  if not (resp := validateWithResponse(arg, registeredArgs[index][1])):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kisa-utils
3
- Version: 0.37.8
3
+ Version: 0.37.10
4
4
  Summary: Utility functions and modules for KISA Developers
5
5
  Author: Tom Bukenya
6
6
  Author-email: glayn2bukman@gmail.com
@@ -3,11 +3,11 @@ kisa_utils/cache.py,sha256=4Ue5G3QhHSQAmIfQKYgWKWjNL4rA4wLLd_RdBLb2ABY,7345
3
3
  kisa_utils/codes.py,sha256=PV_S53Skggf4XetOdYoIKtEmM8cpN5wZwUlxje70WZY,904
4
4
  kisa_utils/config.py,sha256=NfluzGKTh66qfNtC-Ae0zNb1XzMTgU2Me9Vi82R9c1E,2285
5
5
  kisa_utils/dates.py,sha256=kcNqoY_iguG9hSzABMIBqeL3MGz3n4MRIXuW4OxRHLs,12662
6
- kisa_utils/db.py,sha256=Mv9BcHydRZZHE_ONbNPhGiezqVYXuILXct6qBZhgrdU,44223
6
+ kisa_utils/db.py,sha256=gU6BSBSglrndUMhmhOmIEVNXKSiRV6vqf2pskJKYmlQ,44463
7
7
  kisa_utils/encryption.py,sha256=nFzNpzWV_D9uSEq4FsgCnlS7FQtqWP9fvM_81rsfcLo,4218
8
8
  kisa_utils/enqueue.py,sha256=VIliaMvw4MUdOqts0dXdZCYNxs-QrOVjIRAR3scGrRM,11786
9
9
  kisa_utils/figures.py,sha256=pYIpQzu1OXRSsY1d98GhgPifnIRmgl-r7S32ai-Ms0c,3731
10
- kisa_utils/functionUtils.py,sha256=BV1HMkALLbBM-n-7qCFZ1u2qzITRBA8WQZK9B3nOTUE,6246
10
+ kisa_utils/functionUtils.py,sha256=5Xu-ixV5S7sVBrr1ZhIOrLPVVCbvU-EOAX7i46Mzwdc,6422
11
11
  kisa_utils/log.py,sha256=0TYdxcIBts026RCSuVIQBcZ-CW1ES7n3M1nEIjmeLTM,2295
12
12
  kisa_utils/queues.py,sha256=9QqPtDujw6tbWk7uUiXrsd0rVBTIkzeQw9b45l5Fo3k,6502
13
13
  kisa_utils/remote.py,sha256=0RDrfC4RUW4m6JLziC0_EXJYqzWp38Rw8NDroJ0MuqI,2149
@@ -23,7 +23,7 @@ kisa_utils/servers/flask.py,sha256=o76cJKlQ3L8EOVdHUF092qwoAZMzgttuLt0mMhtCsGI,4
23
23
  kisa_utils/structures/__init__.py,sha256=JBU1j3A42jQ62ALKnsS1Hav9YXcYwjDw1wQJtohXPbU,83
24
24
  kisa_utils/structures/utils.py,sha256=l56NQiPVcFijpuLqt2n9ZwnVKT4XzK6oknRVallRzwQ,2573
25
25
  kisa_utils/structures/validator.py,sha256=Y4UmB4TH7N-GkK22EV1WOsPWjTeqxVWLTentl1keZD4,4053
26
- kisa_utils-0.37.8.dist-info/METADATA,sha256=hYf3YtnDHzuO47WJ4ED_xBZpwiNvKc0xYHdPUmr9ihY,477
27
- kisa_utils-0.37.8.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
28
- kisa_utils-0.37.8.dist-info/top_level.txt,sha256=URxY4sRuqmirOxWtztpVmPoGQdksEMYO6hmYsEDGz2Y,75
29
- kisa_utils-0.37.8.dist-info/RECORD,,
26
+ kisa_utils-0.37.10.dist-info/METADATA,sha256=pfh6GQFbwBdENr7T8xWvntPceW2jy1o-G4X1eqsaT-U,478
27
+ kisa_utils-0.37.10.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
28
+ kisa_utils-0.37.10.dist-info/top_level.txt,sha256=URxY4sRuqmirOxWtztpVmPoGQdksEMYO6hmYsEDGz2Y,75
29
+ kisa_utils-0.37.10.dist-info/RECORD,,