python3-commons 0.17.2__py3-none-any.whl → 0.17.4__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 +11 -11
- python3_commons/cache.py +5 -5
- python3_commons/conf.py +5 -6
- python3_commons/db/helpers.py +1 -1
- python3_commons/object_storage.py +10 -6
- {python3_commons-0.17.2.dist-info → python3_commons-0.17.4.dist-info}/METADATA +2 -2
- {python3_commons-0.17.2.dist-info → python3_commons-0.17.4.dist-info}/RECORD +11 -11
- {python3_commons-0.17.2.dist-info → python3_commons-0.17.4.dist-info}/WHEEL +0 -0
- {python3_commons-0.17.2.dist-info → python3_commons-0.17.4.dist-info}/licenses/AUTHORS.rst +0 -0
- {python3_commons-0.17.2.dist-info → python3_commons-0.17.4.dist-info}/licenses/LICENSE +0 -0
- {python3_commons-0.17.2.dist-info → python3_commons-0.17.4.dist-info}/top_level.txt +0 -0
python3_commons/api_client.py
CHANGED
|
@@ -25,7 +25,7 @@ logger = logging.getLogger(__name__)
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
async def _store_response_for_audit(
|
|
28
|
-
|
|
28
|
+
response: ClientResponse, audit_name: str, uri_path: str, method: str, request_id: str
|
|
29
29
|
) -> None:
|
|
30
30
|
response_text = await response.text()
|
|
31
31
|
|
|
@@ -43,16 +43,16 @@ async def _store_response_for_audit(
|
|
|
43
43
|
|
|
44
44
|
@asynccontextmanager
|
|
45
45
|
async def request(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
client: ClientSession,
|
|
47
|
+
base_url: str,
|
|
48
|
+
uri: str,
|
|
49
|
+
query: Mapping | None = None,
|
|
50
|
+
method: Literal['get', 'post', 'put', 'patch', 'options', 'head', 'delete'] = 'get',
|
|
51
|
+
headers: Mapping | None = None,
|
|
52
|
+
json: Mapping | Sequence | str | None = None,
|
|
53
|
+
data: bytes | None = None,
|
|
54
|
+
timeout: ClientTimeout | Enum | None = None,
|
|
55
|
+
audit_name: str | None = None,
|
|
56
56
|
) -> AsyncGenerator[ClientResponse]:
|
|
57
57
|
now = datetime.now(tz=UTC)
|
|
58
58
|
date_path = now.strftime('%Y/%m/%d')
|
python3_commons/cache.py
CHANGED
|
@@ -81,11 +81,11 @@ def get_valkey_client() -> Valkey:
|
|
|
81
81
|
|
|
82
82
|
|
|
83
83
|
async def scan(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
84
|
+
cursor: int = 0,
|
|
85
|
+
match: bytes | str | memoryview | None = None,
|
|
86
|
+
count: int | None = None,
|
|
87
|
+
_type: str | None = None,
|
|
88
|
+
**kwargs,
|
|
89
89
|
) -> ResponseT:
|
|
90
90
|
return await get_valkey_client().scan(cursor, match, count, _type, **kwargs)
|
|
91
91
|
|
python3_commons/conf.py
CHANGED
|
@@ -58,11 +58,11 @@ class DBSettings(BaseSettings):
|
|
|
58
58
|
@model_validator(mode='after')
|
|
59
59
|
def build_dsn_if_missing(self) -> DBSettings:
|
|
60
60
|
if self.dsn is None and all(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
(
|
|
62
|
+
self.user,
|
|
63
|
+
self.password,
|
|
64
|
+
self.name,
|
|
65
|
+
)
|
|
66
66
|
):
|
|
67
67
|
self.dsn = PostgresDsn.build(
|
|
68
68
|
scheme=self.scheme,
|
|
@@ -82,7 +82,6 @@ class S3Settings(BaseSettings):
|
|
|
82
82
|
aws_access_key_id: SecretStr | None = None
|
|
83
83
|
aws_secret_access_key: SecretStr | None = None
|
|
84
84
|
|
|
85
|
-
s3_endpoint_url: str | None = None
|
|
86
85
|
s3_addressing_style: Literal['path', 'virtual'] = 'virtual'
|
|
87
86
|
s3_secure: bool = True
|
|
88
87
|
s3_bucket: str | None = None
|
python3_commons/db/helpers.py
CHANGED
|
@@ -16,7 +16,7 @@ logger = logging.getLogger(__name__)
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
def get_query(
|
|
19
|
-
|
|
19
|
+
search: Mapping[str, str] | None = None, order_by: str | None = None, columns: Mapping | None = None
|
|
20
20
|
) -> tuple[ColumnElement[bool] | None, tuple[ColumnElement[bool]] | None]:
|
|
21
21
|
"""
|
|
22
22
|
:columns:
|
|
@@ -50,9 +50,6 @@ class ObjectStorage(metaclass=SingletonMeta):
|
|
|
50
50
|
'config': Config(s3={'addressing_style': settings.s3_addressing_style}, signature_version='s3v4'),
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
if s3_endpoint_url := settings.s3_endpoint_url:
|
|
54
|
-
config['endpoint_url'] = s3_endpoint_url
|
|
55
|
-
|
|
56
53
|
if aws_access_key_id := settings.aws_access_key_id:
|
|
57
54
|
config['aws_access_key_id'] = aws_access_key_id.get_secret_value()
|
|
58
55
|
|
|
@@ -113,10 +110,17 @@ async def get_object_stream(bucket_name: str, path: str) -> AsyncGenerator[Strea
|
|
|
113
110
|
|
|
114
111
|
|
|
115
112
|
async def get_object(bucket_name: str, path: str) -> bytes:
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
logger.debug('Getting object from object storage: %s:%s', bucket_name, path)
|
|
114
|
+
|
|
115
|
+
try:
|
|
116
|
+
client = get_client()
|
|
117
|
+
absolute_path = get_absolute_path(path)
|
|
118
|
+
url = f's3://{bucket_name}/{absolute_path}'
|
|
119
|
+
body = await client.get_object(url)
|
|
120
|
+
except Exception as e:
|
|
121
|
+
logger.exception('Failed getting object from object storage: %s:%s', bucket_name, path, exc_info=e)
|
|
118
122
|
|
|
119
|
-
|
|
123
|
+
raise
|
|
120
124
|
|
|
121
125
|
return body
|
|
122
126
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python3-commons
|
|
3
|
-
Version: 0.17.
|
|
3
|
+
Version: 0.17.4
|
|
4
4
|
Summary: Re-usable Python3 code
|
|
5
5
|
Author-email: Oleg Korsak <kamikaze.is.waiting.you@gmail.com>
|
|
6
6
|
License-Expression: GPL-3.0
|
|
@@ -37,7 +37,7 @@ Requires-Dist: asyncpg~=0.31.0; extra == "database"
|
|
|
37
37
|
Requires-Dist: SQLAlchemy[asyncio]~=2.0.49; extra == "database"
|
|
38
38
|
Provides-Extra: object-storage
|
|
39
39
|
Requires-Dist: aiobotocore~=3.5.0; extra == "object-storage"
|
|
40
|
-
Requires-Dist: object-storage-client==0.0.
|
|
40
|
+
Requires-Dist: object-storage-client==0.0.23; extra == "object-storage"
|
|
41
41
|
Dynamic: license-file
|
|
42
42
|
|
|
43
43
|
Re-usable Python3 code
|
|
@@ -1,18 +1,18 @@
|
|
|
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=WuP2SDikWvdrJ6yCLUVrtUBxv0UDfcFKxLZwj-It6R8,5418
|
|
3
3
|
python3_commons/async_functools.py,sha256=A2HvwFzZHxOWTp4IQM5UiBY2yg1S_0U1CWra5BWK0gk,9101
|
|
4
4
|
python3_commons/audit.py,sha256=vO4-eIeFEwd6FfydY4ZqX8eUXfx0KiDo8IXotYvpYQg,2278
|
|
5
5
|
python3_commons/auth.py,sha256=TtE4uj6gKiV3GzzXDDjXb7gwPX_hLnDDfGmufPJRe0g,2231
|
|
6
|
-
python3_commons/cache.py,sha256=
|
|
7
|
-
python3_commons/conf.py,sha256=
|
|
6
|
+
python3_commons/cache.py,sha256=lowiXJqFgFy1Yg86wi9IhuoNqIUGP6nc5eNibmf0dfY,8018
|
|
7
|
+
python3_commons/conf.py,sha256=ZdfuYfIRYlzXvJHMCwMwxEs2JJwgFaOhX8IJ6IYNxDE,2854
|
|
8
8
|
python3_commons/exceptions.py,sha256=EGjHZVBnsM6CeBfPMqhL0IPMKjDJ_2-Z-aSPXwq91LE,36
|
|
9
9
|
python3_commons/fs.py,sha256=dn8ZcwsQf9xcAEg6neoxLN6IzJbWpprfm8wV8S55BL0,337
|
|
10
10
|
python3_commons/generators.py,sha256=P6sKdCFhHT79-DZgzPU-qmwZvHg3wU8a75UFIwrycOY,1163
|
|
11
11
|
python3_commons/helpers.py,sha256=2U0XyiBhylPrPIdPkZ16jrJRDZBE-yKv9GjRIY4C-EA,4541
|
|
12
|
-
python3_commons/object_storage.py,sha256=
|
|
12
|
+
python3_commons/object_storage.py,sha256=Zk3HAc5ik6VCknMLlxmAvD5lZy_bR7JuXTNbruyrnHc,7230
|
|
13
13
|
python3_commons/permissions.py,sha256=gaMKSWg0MgPQTdP1voll4ItXcblXku9BlD0Lq3Xv64U,1724
|
|
14
14
|
python3_commons/db/__init__.py,sha256=i60JvWiUY8kz8nEaVjc5MA1IN_P5g3tK7jX8KgcUd0Y,3105
|
|
15
|
-
python3_commons/db/helpers.py,sha256=
|
|
15
|
+
python3_commons/db/helpers.py,sha256=xRpWs4aVkBge6HCLjb6OLSnWc1nlV6rKGyaVhZ_x12w,2001
|
|
16
16
|
python3_commons/db/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
17
17
|
python3_commons/db/models/auth.py,sha256=t6z_0c7l_1eB-CCdnPSV9OzJ_ymgkwD1cLpecNhQgoA,773
|
|
18
18
|
python3_commons/db/models/common.py,sha256=mC76mxjHR5bnUrAAAbIaS4kzruBJbuD3ZDecHZpJq_M,1674
|
|
@@ -26,9 +26,9 @@ python3_commons/serializers/common.py,sha256=VkA7C6wODvHk0QBXVX_x2JieDstihx3U__U
|
|
|
26
26
|
python3_commons/serializers/json.py,sha256=UPkC3ps13x2C_NxwVV-K7Ewp4VjkVHSSUkJVw5k7Wiw,712
|
|
27
27
|
python3_commons/serializers/msgpack.py,sha256=zESFBX34GsZ8rDu6Zk5V6CLT6P0mPilU0r04Ka6TblI,1474
|
|
28
28
|
python3_commons/serializers/msgspec.py,sha256=upy5CBmK66-8hYnK5bAM_sZvZY5CAqZmzCw9GIF346I,2988
|
|
29
|
-
python3_commons-0.17.
|
|
30
|
-
python3_commons-0.17.
|
|
31
|
-
python3_commons-0.17.
|
|
32
|
-
python3_commons-0.17.
|
|
33
|
-
python3_commons-0.17.
|
|
34
|
-
python3_commons-0.17.
|
|
29
|
+
python3_commons-0.17.4.dist-info/licenses/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
|
|
30
|
+
python3_commons-0.17.4.dist-info/licenses/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
|
|
31
|
+
python3_commons-0.17.4.dist-info/METADATA,sha256=ZYGgckhIXegv6uLiP1ewROGdZxvrl6NPylrUabD7WPA,1853
|
|
32
|
+
python3_commons-0.17.4.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
33
|
+
python3_commons-0.17.4.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
|
|
34
|
+
python3_commons-0.17.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|