tracktolib 0.32.0__tar.gz → 0.34.0__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.32.0 → tracktolib-0.34.0}/PKG-INFO +1 -1
- {tracktolib-0.32.0 → tracktolib-0.34.0}/pyproject.toml +2 -2
- {tracktolib-0.32.0 → tracktolib-0.34.0}/setup.py +1 -1
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/tests.py +5 -3
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/utils.py +20 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/LICENSE +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/README.md +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/__init__.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/api.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/http.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/logs.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/pg/__init__.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/pg/query.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/pg/utils.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/pg_sync.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/pg_utils.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/s3/__init__.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/s3/minio.py +0 -0
- {tracktolib-0.32.0 → tracktolib-0.34.0}/tracktolib/s3/s3.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "tracktolib"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.34.0"
|
|
4
4
|
description = "Utility library for python"
|
|
5
5
|
authors = ["Julien Brayere <julien.brayere@tracktor.fr>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -70,7 +70,7 @@ pythonPlatform = "Linux"
|
|
|
70
70
|
|
|
71
71
|
[tool.commitizen]
|
|
72
72
|
name = "cz_conventional_commits"
|
|
73
|
-
version = "0.
|
|
73
|
+
version = "0.34.0"
|
|
74
74
|
tag_format = "$version"
|
|
75
75
|
version_files = [
|
|
76
76
|
"pyproject.toml:version"
|
|
@@ -19,7 +19,7 @@ extras_require = \
|
|
|
19
19
|
|
|
20
20
|
setup_kwargs = {
|
|
21
21
|
'name': 'tracktolib',
|
|
22
|
-
'version': '0.
|
|
22
|
+
'version': '0.34.0',
|
|
23
23
|
'description': 'Utility library for python',
|
|
24
24
|
'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",
|
|
25
25
|
'author': 'Julien Brayere',
|
|
@@ -2,7 +2,6 @@ import pprint
|
|
|
2
2
|
from typing import Iterable
|
|
3
3
|
import warnings
|
|
4
4
|
|
|
5
|
-
|
|
6
5
|
try:
|
|
7
6
|
import deepdiff
|
|
8
7
|
except ImportError:
|
|
@@ -14,5 +13,8 @@ def get_uuid(i: int = 0):
|
|
|
14
13
|
return f'00000000-0000-0000-0000-000000{i:06}'
|
|
15
14
|
|
|
16
15
|
|
|
17
|
-
def assert_equals(d1: dict | Iterable, d2: dict | Iterable
|
|
18
|
-
|
|
16
|
+
def assert_equals(d1: dict | Iterable, d2: dict | Iterable,
|
|
17
|
+
*,
|
|
18
|
+
ignore_order: bool = False):
|
|
19
|
+
diff = deepdiff.DeepDiff(d1, d2, ignore_order=ignore_order)
|
|
20
|
+
assert not diff, pprint.pprint(diff)
|
|
@@ -8,6 +8,7 @@ from ipaddress import IPv4Address, IPv6Address
|
|
|
8
8
|
from pathlib import Path
|
|
9
9
|
from typing import Iterable, TypeVar, Iterator, Literal, overload, Any
|
|
10
10
|
import importlib.util
|
|
11
|
+
import asyncio
|
|
11
12
|
|
|
12
13
|
T = TypeVar('T')
|
|
13
14
|
|
|
@@ -29,6 +30,25 @@ def exec_cmd(cmd: str | list[str],
|
|
|
29
30
|
return stdout.decode(encoding)
|
|
30
31
|
|
|
31
32
|
|
|
33
|
+
async def aexec_cmd(cmd: str | list[str],
|
|
34
|
+
*,
|
|
35
|
+
encoding: str = 'utf-8',
|
|
36
|
+
env: dict | None = None) -> str:
|
|
37
|
+
_cmd = cmd if isinstance(cmd, str) else ' '.join(cmd)
|
|
38
|
+
default_shell = os.getenv('SHELL', '/bin/bash')
|
|
39
|
+
|
|
40
|
+
proc = await asyncio.create_subprocess_shell(_cmd,
|
|
41
|
+
shell=True,
|
|
42
|
+
stdout=subprocess.PIPE,
|
|
43
|
+
stderr=subprocess.PIPE,
|
|
44
|
+
executable=default_shell,
|
|
45
|
+
env=env)
|
|
46
|
+
stdout, stderr = await proc.communicate()
|
|
47
|
+
if proc.returncode != 0:
|
|
48
|
+
raise Exception(stderr.decode(encoding))
|
|
49
|
+
return stdout.decode(encoding)
|
|
50
|
+
|
|
51
|
+
|
|
32
52
|
def import_module(path: Path):
|
|
33
53
|
"""
|
|
34
54
|
Import a module from a path.
|
|
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
|