arpakitlib 1.7.228__py3-none-any.whl → 1.7.231__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.
@@ -388,6 +388,10 @@ class HealthcheckSO(BaseSO):
388
388
  is_ok: bool = True
389
389
 
390
390
 
391
+ class ARPAKITLibSO(BaseSO):
392
+ arpakitlib: bool = True
393
+
394
+
391
395
  def add_needed_api_router_to_app(*, app: FastAPI):
392
396
  api_router = APIRouter()
393
397
 
@@ -405,14 +409,14 @@ def add_needed_api_router_to_app(*, app: FastAPI):
405
409
 
406
410
  @api_router.get(
407
411
  "/arpakitlib",
408
- response_model=RawDataSO | ErrorSO,
412
+ response_model=ARPAKITLibSO | ErrorSO,
409
413
  status_code=starlette.status.HTTP_200_OK,
410
414
  tags=["arpakitlib"]
411
415
  )
412
416
  async def _():
413
417
  return APIJSONResponse(
414
418
  status_code=starlette.status.HTTP_200_OK,
415
- content=RawDataSO(data={"arpakitlib": True})
419
+ content=ARPAKITLibSO(arpakitlib=True)
416
420
  )
417
421
 
418
422
  app.include_router(router=api_router, prefix="")
@@ -11,8 +11,8 @@ def init_log_file(*, log_filepath: str):
11
11
  directory = os.path.dirname(log_filepath)
12
12
  if directory and not os.path.exists(directory):
13
13
  os.makedirs(directory, exist_ok=True)
14
- if not os.path.exists(path=log_filepath):
15
- with open(file=log_filepath, mode="w") as file:
14
+ if not os.path.exists(log_filepath):
15
+ with open(log_filepath, mode="w") as file:
16
16
  file.write("")
17
17
 
18
18
 
@@ -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,9 +1,14 @@
1
+ # arpakit
2
+
3
+
1
4
  import asyncio
2
5
  from datetime import timedelta
3
6
  from typing import Any
4
7
 
5
8
  from arpakitlib.ar_sleep_util import sync_safe_sleep, async_safe_sleep
6
9
 
10
+ _ARPAKIT_LIB_MODULE_VERSION = "3.0"
11
+
7
12
 
8
13
  async def async_retry_func(
9
14
  *,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: arpakitlib
3
- Version: 1.7.228
3
+ Version: 1.7.231
4
4
  Summary: arpakitlib
5
5
  License: Apache-2.0
6
6
  Keywords: arpakitlib,arpakit,arpakit-company,arpakitcompany,arpakit_company
@@ -167,7 +167,7 @@ arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css,sha256=jzPZlgJTFwSdSphk9C
167
167
  arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.css.map,sha256=5wq8eXMLU6Zxb45orZPL1zAsBFJReFw6GjYqGpUX3hg,262650
168
168
  arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js,sha256=ffrLZHHEQ_g84A-ul3yWa10Kk09waOAxHcQXPuZuavg,339292
169
169
  arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js.map,sha256=9UhIW7MqCOZPAz1Sl1IKfZUuhWU0p-LJqrnjjJD9Xhc,1159454
170
- arpakitlib/ar_fastapi_util.py,sha256=BEdIlcgOHGe_K42mRHvT7YiSD_4hCZJCZGp_YmIx-KU,26497
170
+ arpakitlib/ar_fastapi_util.py,sha256=dRDvlmU1tHYlEvNGV8OV9ziB_HdlkgQtbc3clYKAZ6Y,26551
171
171
  arpakitlib/ar_file_storage_in_dir_util.py,sha256=D3e3rGuHoI6xqAA5mVvEpVVpOWY1jyjNsjj2UhyHRbE,3674
172
172
  arpakitlib/ar_file_util.py,sha256=GUdJYm1tUZnYpY-SIPRHAZBHGra8NKy1eYEI0D5AfhY,489
173
173
  arpakitlib/ar_func_util.py,sha256=bCuWbSMoFXBaMNhb89sevj2oaXRk4Jk6Qjot8OXMDT4,1319
@@ -179,14 +179,15 @@ arpakitlib/ar_json_util.py,sha256=wJOsN8N7Rs7r8cTgMDXrmFa1GOkcD-LghqFEYXc8zGA,10
179
179
  arpakitlib/ar_jwt_util.py,sha256=Rhm4ywoTAn6yOV8NLjDASfAtAtheROxxDP40G3XjnuQ,761
180
180
  arpakitlib/ar_list_of_dicts_to_xlsx.py,sha256=MyjEl4Jl4beLVZqLVQMMv0-XDtBD3Xh4Z_ZPDJeFu04,745
181
181
  arpakitlib/ar_list_util.py,sha256=2woOAHAU8oTIiVjZ8GLnx15odEaoQUq3Q0JPxlufFF0,457
182
- arpakitlib/ar_logging_util.py,sha256=mx3H6CzX9dsh29ruFmYnva8lL6mwvdBXmeHH9E2tvu8,1678
182
+ arpakitlib/ar_logging_util.py,sha256=V4jypypFG1cj4nXae7JiBnRRfm02OTnZSEermx-wlDY,1668
183
183
  arpakitlib/ar_mongodb_util.py,sha256=2ECkTnGAZ92qxioL-fmN6R4yZOSr3bXdXLWTzT1C3vk,4038
184
184
  arpakitlib/ar_need_type_util.py,sha256=GETiREPMEYhch-yU6T--Bdawlbb04Jp1Qy7cOsUlIeA,2228
185
185
  arpakitlib/ar_openai_api_client_util.py,sha256=_XmlApvHFMSyjvZydPa_kASIt9LsFrZmSC7YEzIG8Bg,1806
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_retry_func_util.py,sha256=zKHBuSHxtLAQzAO40xCAzdIk7F2kTlUZgzqnwGqz1sY,2155
189
+ arpakitlib/ar_rat_func_util.py,sha256=xDO3gcmZZ0VsTF5zwqyfrkct8FWcKmyl1KUwfdA1s4k,2009
190
+ arpakitlib/ar_retry_func_util.py,sha256=EQtXhn0RvMiyaes9HMDBgMh_WjMIaGwds01UrKKDaBM,2204
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
192
193
  arpakitlib/ar_settings_util.py,sha256=rnoTqbRuhiq7294D4crD5kbnU8-gNWJbwGU_Ls2gJoU,2199
@@ -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.231.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
204
+ arpakitlib-1.7.231.dist-info/METADATA,sha256=5c4sAIRMU8w9DsmGVvioXm5jyKriZcIJRIojMV3oeYY,3310
205
+ arpakitlib-1.7.231.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
206
+ arpakitlib-1.7.231.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
207
+ arpakitlib-1.7.231.dist-info/RECORD,,