tracktolib 0.47.2__tar.gz → 0.48.1__tar.gz
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.
- {tracktolib-0.47.2 → tracktolib-0.48.1}/PKG-INFO +1 -1
- {tracktolib-0.47.2 → tracktolib-0.48.1}/pyproject.toml +4 -2
- {tracktolib-0.47.2 → tracktolib-0.48.1}/setup.py +1 -1
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/api.py +2 -1
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/s3/s3.py +32 -4
- {tracktolib-0.47.2 → tracktolib-0.48.1}/LICENSE +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/README.md +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/__init__.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/http_utils.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/logs.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/pg/__init__.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/pg/query.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/pg/utils.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/pg_sync.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/pg_utils.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/s3/__init__.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/s3/minio.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/tests.py +0 -0
- {tracktolib-0.47.2 → tracktolib-0.48.1}/tracktolib/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "tracktolib"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.48.1"
|
|
4
4
|
description = "Utility library for python"
|
|
5
5
|
authors = ["Julien Brayere <julien.brayere@tracktor.fr>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -47,6 +47,8 @@ pytest = "^7.2.0"
|
|
|
47
47
|
pytest-cov = "^4.0.0"
|
|
48
48
|
pydantic = ">=2,<3"
|
|
49
49
|
ruff = "^0.1.6"
|
|
50
|
+
# Issue for mac with trackit version of multidict
|
|
51
|
+
multidict = ">=6.0.5"
|
|
50
52
|
|
|
51
53
|
[build-system]
|
|
52
54
|
requires = ["poetry-core"]
|
|
@@ -70,7 +72,7 @@ pythonPlatform = "Linux"
|
|
|
70
72
|
|
|
71
73
|
[tool.commitizen]
|
|
72
74
|
name = "cz_conventional_commits"
|
|
73
|
-
version = "0.
|
|
75
|
+
version = "0.48.1"
|
|
74
76
|
tag_format = "$version"
|
|
75
77
|
version_files = [
|
|
76
78
|
"pyproject.toml:version"
|
|
@@ -20,7 +20,7 @@ extras_require = \
|
|
|
20
20
|
|
|
21
21
|
setup_kwargs = {
|
|
22
22
|
'name': 'tracktolib',
|
|
23
|
-
'version': '0.
|
|
23
|
+
'version': '0.48.1',
|
|
24
24
|
'description': 'Utility library for python',
|
|
25
25
|
'long_description': "# Tracktolib\n\n[](https://pypi.python.org/pypi/tracktolib)\n[](https://pypi.python.org/pypi/tracktolib)\n[](https://app.circleci.com/pipelines/github/Tracktor/tracktolib?branch=master)\n\nUtility library for python\n\n# Installation\n\nYou can choose to not install all the dependencies by specifying\nthe [extra](https://python-poetry.org/docs/cli/#options-4) parameter such as:\n\n```bash\npoetry add tracktolib@latest -E pg-sync -E tests --group dev \n```\n\nHere we only install the utilities using `psycopg` (pg-sync) and `deepdiff` (tests) for the dev environment.\n\n# Utilities\n\n- **log**\n\nUtility functions for logging.\n\n```python\nimport logging\nfrom tracktolib.logs import init_logging\n\nlogger = logging.getLogger()\nformatter, stream_handler = init_logging(logger, 'json', version='0.0.1')\n```\n\n- **pg**\n\nUtility functions for [asyncpg](https://github.com/MagicStack/asyncpg)\n\n- **pg-sync**\n\nUtility functions based on psycopg such as `fetch_one`, `insert_many`, `fetch_count` ...\n\nTo use the functions, create a `Connection` using psycopg: `conn = psycopg2.connect()`\n\n*fetch_one*\n\n```python\nfrom pg.pg_sync import (\n insert_many, fetch_one, fetch_count, fetch_all\n)\n\ndata = [\n {'foo': 'bar', 'value': 1},\n {'foo': 'baz', 'value': 2}\n]\ninsert_many(conn, 'public.test', data) # Will insert the 2 dict\nquery = 'SELECT foo from public.test order by value asc'\nvalue = fetch_one(conn, query, required=True) # Will return {'foo': 'bar'}, raise an error is not found\nassert fetch_count(conn, 'public.test') == 2\nquery = 'SELECT * from public.test order by value asc'\nassert fetch_all(conn, query) == data\n\n```\n\n- **tests**\n\nUtility functions for testing\n\n- **s3-minio**\n\nUtility functions for [minio](https://min.io/docs/minio/linux/developers/python/API.html)\n\n- **s3**\n\nUtility functions for [aiobotocore](https://github.com/aio-libs/aiobotocore)\n\n- **logs**\n\nUtility functions to initialize the logging formatting and streams\n\n- **http**\n\nUtility functions using [httpx](https://www.python-httpx.org/)\n\n- **api**\n\nUtility functions using [fastapi](https://fastapi.tiangolo.com/)\n",
|
|
26
26
|
'author': 'Julien Brayere',
|
|
@@ -319,7 +319,8 @@ class CamelCaseModel(BaseModel):
|
|
|
319
319
|
|
|
320
320
|
|
|
321
321
|
def check_status(resp, status: int = starlette.status.HTTP_200_OK):
|
|
322
|
-
|
|
322
|
+
if resp.status_code != status:
|
|
323
|
+
raise AssertionError(json.dumps(resp.json(), indent=4))
|
|
323
324
|
|
|
324
325
|
|
|
325
326
|
def generate_list_name_model(model: Type[B], status: int | None = None) -> dict:
|
|
@@ -51,12 +51,40 @@ async def download_file(client: AioBaseClient, bucket: str, path: str) -> BytesI
|
|
|
51
51
|
return _file
|
|
52
52
|
|
|
53
53
|
|
|
54
|
-
async def delete_file(client: AioBaseClient, bucket: str, path: str) ->
|
|
54
|
+
async def delete_file(client: AioBaseClient, bucket: str, path: str) -> dict:
|
|
55
55
|
"""
|
|
56
|
-
Delete a file from
|
|
57
|
-
|
|
56
|
+
Delete a file from an S3 bucket.
|
|
57
|
+
|
|
58
|
+
Args:
|
|
59
|
+
client (AioBaseClient): The client to interact with the S3 service.
|
|
60
|
+
bucket (str): The name of the S3 bucket.
|
|
61
|
+
path (str): The path to the file within the S3 bucket.
|
|
62
|
+
|
|
63
|
+
Return:
|
|
64
|
+
dict: The response from the S3 service after attempting to delete the file.
|
|
65
|
+
This typically includes metadata about the operation, such as HTTP status code,
|
|
66
|
+
any errors encountered, and information about the deleted object.
|
|
67
|
+
"""
|
|
68
|
+
return await client.delete_object(Bucket=bucket, Key=path) # type:ignore
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
async def delete_files(client: AioBaseClient, bucket: str, paths: list[str], quiet: bool = True) -> dict:
|
|
72
|
+
"""
|
|
73
|
+
Delete multiple files from an S3 bucket.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
client (AioBaseClient): The client to interact with the S3 service.
|
|
77
|
+
bucket (str): The name of the S3 bucket.
|
|
78
|
+
paths (str): The paths to the files to delete within the S3 bucket.
|
|
79
|
+
quiet (bool): Whether to suppress printing messages to stdout (default: True).
|
|
80
|
+
|
|
81
|
+
Return:
|
|
82
|
+
dict: The response from the S3 service after attempting to delete the files.
|
|
83
|
+
This typically includes metadata about the operation, such as HTTP status code,
|
|
84
|
+
any errors encountered, and information about the deleted object.
|
|
58
85
|
"""
|
|
59
|
-
|
|
86
|
+
delete_request = {"Objects": [{"Key": path} for path in paths], "Quiet": quiet}
|
|
87
|
+
return await client.delete_objects(Bucket=bucket, Delete=delete_request) # type:ignore
|
|
60
88
|
|
|
61
89
|
|
|
62
90
|
class S3Item(TypedDict):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|