python3-commons 0.7.4__py3-none-any.whl → 0.7.6__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.
- python3_commons/api_client.py +5 -3
- python3_commons/db/helpers.py +15 -8
- {python3_commons-0.7.4.dist-info → python3_commons-0.7.6.dist-info}/METADATA +3 -3
- {python3_commons-0.7.4.dist-info → python3_commons-0.7.6.dist-info}/RECORD +8 -8
- {python3_commons-0.7.4.dist-info → python3_commons-0.7.6.dist-info}/WHEEL +1 -1
- {python3_commons-0.7.4.dist-info → python3_commons-0.7.6.dist-info}/AUTHORS.rst +0 -0
- {python3_commons-0.7.4.dist-info → python3_commons-0.7.6.dist-info}/LICENSE +0 -0
- {python3_commons-0.7.4.dist-info → python3_commons-0.7.6.dist-info}/top_level.txt +0 -0
python3_commons/api_client.py
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
import logging
|
2
2
|
from contextlib import asynccontextmanager
|
3
3
|
from datetime import datetime, UTC
|
4
|
+
from enum import Enum
|
4
5
|
from http import HTTPStatus
|
5
6
|
from json import dumps
|
6
7
|
from typing import AsyncGenerator, Literal, Mapping, Sequence
|
7
8
|
from uuid import uuid4
|
8
9
|
|
9
|
-
from aiohttp import ClientResponse, ClientSession, client_exceptions
|
10
|
+
from aiohttp import ClientResponse, ClientSession, client_exceptions, ClientTimeout
|
10
11
|
from pydantic import HttpUrl
|
11
12
|
|
12
13
|
from python3_commons import audit
|
@@ -49,6 +50,7 @@ async def request(
|
|
49
50
|
headers: Mapping | None = None,
|
50
51
|
json: Mapping | Sequence | str | None = None,
|
51
52
|
data: bytes | None = None,
|
53
|
+
timeout: ClientTimeout | Enum | None = None,
|
52
54
|
audit_name: str | None = None
|
53
55
|
) -> AsyncGenerator[ClientResponse]:
|
54
56
|
now = datetime.now(tz=UTC)
|
@@ -80,7 +82,7 @@ async def request(
|
|
80
82
|
|
81
83
|
try:
|
82
84
|
if method == 'get':
|
83
|
-
async with client_method(url, params=query, headers=headers) as response:
|
85
|
+
async with client_method(url, params=query, headers=headers, timeout=timeout) as response:
|
84
86
|
if audit_name:
|
85
87
|
await _store_response_for_audit(response, audit_name, uri_path, method, request_id)
|
86
88
|
|
@@ -107,7 +109,7 @@ async def request(
|
|
107
109
|
else:
|
108
110
|
headers = {'Content-Type': 'application/json'}
|
109
111
|
|
110
|
-
async with client_method(url, params=query, data=data, headers=headers) as response:
|
112
|
+
async with client_method(url, params=query, data=data, headers=headers, timeout=timeout) as response:
|
111
113
|
if audit_name:
|
112
114
|
await _store_response_for_audit(response, audit_name, uri_path, method, request_id)
|
113
115
|
|
python3_commons/db/helpers.py
CHANGED
@@ -20,16 +20,23 @@ def get_query(search: Mapping[str, str] | None = None,
|
|
20
20
|
3: exact match if True, LIKE %value% if False
|
21
21
|
"""
|
22
22
|
|
23
|
+
order_by_cols = {}
|
24
|
+
|
23
25
|
if order_by:
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
for order_by_col in order_by.split(','):
|
27
|
+
if order_by_col.startswith('-'):
|
28
|
+
direction = desc
|
29
|
+
order_by_col = order_by_col[1:]
|
30
|
+
else:
|
31
|
+
direction = asc
|
32
|
+
|
33
|
+
order_by_cols[order_by_col] = direction
|
29
34
|
|
30
|
-
|
35
|
+
order_by_clauses = tuple(
|
36
|
+
direction(columns[order_by_col][0]) for order_by_col, direction in order_by_cols.items()
|
37
|
+
)
|
31
38
|
else:
|
32
|
-
|
39
|
+
order_by_clauses = None
|
33
40
|
|
34
41
|
if search:
|
35
42
|
where_parts = [
|
@@ -58,4 +65,4 @@ def get_query(search: Mapping[str, str] | None = None,
|
|
58
65
|
else:
|
59
66
|
where_clause = None
|
60
67
|
|
61
|
-
return where_clause,
|
68
|
+
return where_clause, order_by_clauses
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: python3-commons
|
3
|
-
Version: 0.7.
|
3
|
+
Version: 0.7.6
|
4
4
|
Summary: Re-usable Python3 code
|
5
5
|
Author-email: Oleg Korsak <kamikaze.is.waiting.you@gmail.com>
|
6
6
|
License: gpl-3
|
@@ -12,7 +12,7 @@ Requires-Python: >=3.13
|
|
12
12
|
Description-Content-Type: text/x-rst
|
13
13
|
License-File: LICENSE
|
14
14
|
License-File: AUTHORS.rst
|
15
|
-
Requires-Dist: aiohttp[speedups]~=3.11.
|
15
|
+
Requires-Dist: aiohttp[speedups]~=3.11.14
|
16
16
|
Requires-Dist: asyncpg~=0.30.0
|
17
17
|
Requires-Dist: fastapi-users-db-sqlalchemy~=7.0.0
|
18
18
|
Requires-Dist: fastapi-users[sqlalchemy]~=14.0.1
|
@@ -22,7 +22,7 @@ Requires-Dist: msgpack~=1.1.0
|
|
22
22
|
Requires-Dist: msgspec~=0.19.0
|
23
23
|
Requires-Dist: pydantic[email]~=2.10.6
|
24
24
|
Requires-Dist: pydantic-settings~=2.8.1
|
25
|
-
Requires-Dist: SQLAlchemy[asyncio]~=2.0.
|
25
|
+
Requires-Dist: SQLAlchemy[asyncio]~=2.0.39
|
26
26
|
Requires-Dist: zeep~=4.3.1
|
27
27
|
Provides-Extra: testing
|
28
28
|
Requires-Dist: pytest; extra == "testing"
|
@@ -1,5 +1,5 @@
|
|
1
1
|
python3_commons/__init__.py,sha256=0KgaYU46H_IMKn-BuasoRN3C4Hi45KlkHHoPbU9cwiA,189
|
2
|
-
python3_commons/api_client.py,sha256=
|
2
|
+
python3_commons/api_client.py,sha256=zj6zTF-DhUMu4bjj9VWLi63mVODG_SB47Q5qlmG-Sxg,4539
|
3
3
|
python3_commons/audit.py,sha256=DMQ-nrWSs0qilD7wkz_8PV4jXcee75O8FgAm2YIuOiY,6256
|
4
4
|
python3_commons/conf.py,sha256=GAcjlFlloLriZXa9JmNGMtTPzvtHUActYDiE4C1DacU,749
|
5
5
|
python3_commons/fs.py,sha256=wfLjybXndwLqNlOxTpm_HRJnuTcC4wbrHEOaEeCo9Wc,337
|
@@ -7,7 +7,7 @@ python3_commons/helpers.py,sha256=OmuCF7UeJ6oe-rH1Y4ZYVW_uPQ973lCLsikj01wmNqs,31
|
|
7
7
|
python3_commons/object_storage.py,sha256=Bte49twIJ4l6VAzIqK6tLx7DFYwijErUmmhWkrZpSJE,4074
|
8
8
|
python3_commons/permissions.py,sha256=V6kT7gBQ0fZRDQwreM9es90BvvpB3gUofuqnFvx2g-o,1553
|
9
9
|
python3_commons/db/__init__.py,sha256=pZk0Fv-Le2sFC-KaVDdJjDDsHtmv-IJz_aFP5o2PGHA,1682
|
10
|
-
python3_commons/db/helpers.py,sha256=
|
10
|
+
python3_commons/db/helpers.py,sha256=0z-pXAxQg0KqrqfoUcRooRHNrrKi-g2mSO6euVMscpE,1891
|
11
11
|
python3_commons/db/models/__init__.py,sha256=AeeTLUqdqQrhCTi14ACWO0ccyVyWFppZVtCeWShSvR0,193
|
12
12
|
python3_commons/db/models/auth.py,sha256=ctHiz_5x17TdXac7a3SjfuZ0-nEgnxK7RwKOY8qflZc,1195
|
13
13
|
python3_commons/db/models/common.py,sha256=ScFEL04HwEomX3X7f8WHMq505uvoID6itBETRWfya9w,1402
|
@@ -19,9 +19,9 @@ python3_commons/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
|
|
19
19
|
python3_commons/serializers/json.py,sha256=P288wWz9ic38QWEMrpp_uwKPYkQiOgvE1cI4WZn6ZCg,808
|
20
20
|
python3_commons/serializers/msgpack.py,sha256=tzIGGyDL3UpZnnouCtnxuYDx6InKM_C3PP1N4PN8wd4,1269
|
21
21
|
python3_commons/serializers/msgspec.py,sha256=FuZVqOLJb0-lEKrs7dtjhwEbHIpfMUk5yu1hD64zRdc,2038
|
22
|
-
python3_commons-0.7.
|
23
|
-
python3_commons-0.7.
|
24
|
-
python3_commons-0.7.
|
25
|
-
python3_commons-0.7.
|
26
|
-
python3_commons-0.7.
|
27
|
-
python3_commons-0.7.
|
22
|
+
python3_commons-0.7.6.dist-info/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
|
23
|
+
python3_commons-0.7.6.dist-info/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
|
24
|
+
python3_commons-0.7.6.dist-info/METADATA,sha256=GtDliyLHNI1Y-zqZCrMXr7ggUb98BhvLffLIu3ROTIs,1127
|
25
|
+
python3_commons-0.7.6.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
|
26
|
+
python3_commons-0.7.6.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
|
27
|
+
python3_commons-0.7.6.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|