kisa-utils 0.37.19__py3-none-any.whl → 0.38.0__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
@@ -955,11 +955,10 @@ class Api:
955
955
  reply['log'] = 'database not open'
956
956
  return reply if not self.__returnKISAResponse else Error(reply['log'])
957
957
 
958
- if self.__withContextCount > 1:
958
+ if not self.inTopLevelContext:
959
959
  reply['log'] = 'can not commit transaction in non top-level context'
960
960
  return reply if not self.__returnKISAResponse else Error(reply['log'])
961
961
 
962
-
963
962
  for op in self.__transactionData:
964
963
  if self.__transactionData[op]['failed']:
965
964
  reply['log'] = f'{self.__transactionData[op]["failed"]} `{op}` operation(s) returned a `False` status'
@@ -1103,6 +1102,14 @@ class Api:
1103
1102
  def __bool__(self)->bool:
1104
1103
  return self.isOpen
1105
1104
 
1105
+ @property
1106
+ def inTopLevelContext(self) -> bool:
1107
+ '''
1108
+ check if the opened db-handle is in the top-most `with` context.
1109
+ If it is, then its okay to commit a transaction
1110
+ '''
1111
+ return self.__withContextCount <= 1
1112
+
1106
1113
  Handle = Api
1107
1114
 
1108
1115
  def transaction(*dbArgs, **dbKwargs) -> dict|Response:
@@ -6,14 +6,11 @@ from kisa_utils.response import Response, Ok, Error
6
6
  from kisa_utils.storage import Path
7
7
  from kisa_utils.structures.validator import Value, validateWithResponse
8
8
  import copy
9
- from typing import Any, get_args, Callable, Generic, ParamSpec, TypeVar
9
+ from typing import Any, get_args, Callable
10
10
 
11
- P = ParamSpec('P')
12
- T = TypeVar('T')
13
-
14
- class Definition(Generic[T]):
11
+ class Definition:
15
12
  @staticmethod
16
- def __class_getitem__(structure:type[T]) -> Any:
13
+ def __class_getitem__(structure:Any) -> Any:
17
14
  return structure
18
15
 
19
16
  def private(func:Callable) -> Callable:
@@ -63,6 +60,9 @@ def protected(func:Callable) -> Callable:
63
60
  return wrapper
64
61
 
65
62
  # ------------------------------------------------------------------------------
63
+ from typing import ParamSpec, TypeVar
64
+ P = ParamSpec('P')
65
+ T = TypeVar('T')
66
66
 
67
67
  def enforceRequirements(func:Callable[P, T]) -> Callable[P, T]:
68
68
  '''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kisa-utils
3
- Version: 0.37.19
3
+ Version: 0.38.0
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=QH9nvwc3Lr-NyUA-47Rae-s2xeMIE6m2rNGozcpr2jg,48950
6
+ kisa_utils/db.py,sha256=tVNMV-hc-oPxR4iRSX-d82Gi4fQwI5Cga1eP8SLvHFs,49202
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=I33ZeDNcQsumhgWyFWodj0D3RKkwfiUFZfCGwmAkDYo,6561
10
+ kisa_utils/functionUtils.py,sha256=PlXjnmU1uJWNdISlJJ3SCgavTsgNBoebaa9dtWSFhRA,6553
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=665rXIapGwFqejizeJwy3DryeskCQOdgP25BCdLkGvk,2898
25
25
  kisa_utils/structures/validator.py,sha256=Y4UmB4TH7N-GkK22EV1WOsPWjTeqxVWLTentl1keZD4,4053
26
- kisa_utils-0.37.19.dist-info/METADATA,sha256=-y5a78qkRd5OybszNjtiKAOAKAUV4Y9an8mA8jJT8ew,478
27
- kisa_utils-0.37.19.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
28
- kisa_utils-0.37.19.dist-info/top_level.txt,sha256=URxY4sRuqmirOxWtztpVmPoGQdksEMYO6hmYsEDGz2Y,75
29
- kisa_utils-0.37.19.dist-info/RECORD,,
26
+ kisa_utils-0.38.0.dist-info/METADATA,sha256=N9Rr0nesf9HuUFeg9N_nQgpZYO5YLOMhfOYax5vI3NA,477
27
+ kisa_utils-0.38.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
28
+ kisa_utils-0.38.0.dist-info/top_level.txt,sha256=URxY4sRuqmirOxWtztpVmPoGQdksEMYO6hmYsEDGz2Y,75
29
+ kisa_utils-0.38.0.dist-info/RECORD,,