arpakitlib 1.7.228__py3-none-any.whl → 1.7.229__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.
@@ -0,0 +1,77 @@
1
+ from typing import Any
2
+
3
+ from pydantic import BaseModel, ConfigDict
4
+
5
+ from arpakitlib.ar_type_util import NotSet, is_set, is_not_set
6
+
7
+
8
+ class RatFuncRes(BaseModel):
9
+ model_config = ConfigDict(arbitrary_types_allowed=True)
10
+
11
+ func_res: Any = NotSet
12
+ func_exception: Exception | None = None
13
+
14
+ def raise_for_func_exception(self):
15
+ if self.func_exception is not None:
16
+ raise self.func_exception
17
+
18
+ @property
19
+ def has_exception(self) -> bool:
20
+ if self.func_exception is not None:
21
+ return True
22
+ return False
23
+
24
+ @property
25
+ def is_func_res_set(self) -> bool:
26
+ return is_set(self.func_res)
27
+
28
+ @property
29
+ def is_func_res_not_set(self) -> bool:
30
+ return is_not_set(self.func_res)
31
+
32
+
33
+ def rat_sync_func(
34
+ *,
35
+ sync_func: Any,
36
+ sync_func_args: tuple[Any, ...] | None = None,
37
+ sync_func_kwargs: dict[str, Any] | None = None,
38
+ ) -> RatFuncRes:
39
+ sync_func_args = sync_func_args or ()
40
+ sync_func_kwargs = sync_func_kwargs or {}
41
+ rat_func_res = RatFuncRes()
42
+ try:
43
+ rat_func_res.func_res = sync_func(*sync_func_args, **sync_func_kwargs)
44
+ except Exception as exception:
45
+ rat_func_res.func_exception = exception
46
+ return rat_func_res
47
+
48
+
49
+ async def rat_async_func(
50
+ *,
51
+ async_func: Any,
52
+ async_func_args: tuple[Any, ...] | None = None,
53
+ async_func_kwargs: dict[str, Any] | None = None,
54
+ ) -> RatFuncRes:
55
+ async_func_args = async_func_args or ()
56
+ async_func_kwargs = async_func_kwargs or {}
57
+ rat_func_res = RatFuncRes()
58
+ try:
59
+ rat_func_res.func_res = await async_func(*async_func_args, **async_func_kwargs)
60
+ except Exception as exception:
61
+ rat_func_res.func_exception = exception
62
+ return rat_func_res
63
+
64
+
65
+ def __example():
66
+ def go():
67
+ return "asfaf"
68
+
69
+ a = rat_sync_func(sync_func=go)
70
+ print(a.has_exception)
71
+ print(a)
72
+ print(a.is_func_res_set)
73
+ print(a.is_func_res_not_set)
74
+
75
+
76
+ if __name__ == '__main__':
77
+ __example()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: arpakitlib
3
- Version: 1.7.228
3
+ Version: 1.7.229
4
4
  Summary: arpakitlib
5
5
  License: Apache-2.0
6
6
  Keywords: arpakitlib,arpakit,arpakit-company,arpakitcompany,arpakit_company
@@ -186,6 +186,7 @@ arpakitlib/ar_openai_api_client_util.py,sha256=_XmlApvHFMSyjvZydPa_kASIt9LsFrZmS
186
186
  arpakitlib/ar_operation_execution_util.py,sha256=YkftxZthr6knqW40mgq28y-zRXSTJPfJ1y_4pOkBQOc,17601
187
187
  arpakitlib/ar_parse_command.py,sha256=-s61xcATIsfw1eV_iD3xi-grsitbGzSDoAFc5V0OFy4,3447
188
188
  arpakitlib/ar_postgresql_util.py,sha256=1AuLjEaa1Lg4pzn-ukCVnDi35Eg1k91APRTqZhIJAdo,945
189
+ arpakitlib/ar_rat_func_util.py,sha256=xDO3gcmZZ0VsTF5zwqyfrkct8FWcKmyl1KUwfdA1s4k,2009
189
190
  arpakitlib/ar_retry_func_util.py,sha256=zKHBuSHxtLAQzAO40xCAzdIk7F2kTlUZgzqnwGqz1sY,2155
190
191
  arpakitlib/ar_run_cmd_util.py,sha256=D_rPavKMmWkQtwvZFz-Io5Ak8eSODHkcFeLPzNVC68g,1072
191
192
  arpakitlib/ar_schedule_uust_api_client_util.py,sha256=93d-bc3S0PddqV65lSvmApcSoDV0gqxPVgIaB7zKXfY,6899
@@ -199,8 +200,8 @@ arpakitlib/ar_str_util.py,sha256=yU5gOwNXUQaH5b_tM5t6fXUn9oUcv5EQbVnq2wXXIpQ,337
199
200
  arpakitlib/ar_type_util.py,sha256=9C3ErtUVs0tAUqtK-foFzjJOykfBOntfCz2IogDOgfA,4134
200
201
  arpakitlib/ar_yookassa_api_client_util.py,sha256=sh4fcUkAkdOetFn9JYoTvjcSXP-M1wU04KEY-ECLfLg,5137
201
202
  arpakitlib/ar_zabbix_api_client_util.py,sha256=Q-VR4MvoZ9aHwZeYZr9G3LwN-ANx1T5KFmF6pvPM-9M,6402
202
- arpakitlib-1.7.228.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
203
- arpakitlib-1.7.228.dist-info/METADATA,sha256=xVDBqXUHoxRVOdvFosH3Cxxg1mXpU6es4HURatrRpMw,3310
204
- arpakitlib-1.7.228.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
205
- arpakitlib-1.7.228.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
206
- arpakitlib-1.7.228.dist-info/RECORD,,
203
+ arpakitlib-1.7.229.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
204
+ arpakitlib-1.7.229.dist-info/METADATA,sha256=lW9jVlLU_M_qy5hKTlohhGJNxfUaA3bRHexAMJWJpzM,3310
205
+ arpakitlib-1.7.229.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
206
+ arpakitlib-1.7.229.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
207
+ arpakitlib-1.7.229.dist-info/RECORD,,