kleinkram 0.38.1.dev20250113080249__py3-none-any.whl → 0.38.1.dev20250207122632__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.
Potentially problematic release.
This version of kleinkram might be problematic. Click here for more details.
- kleinkram/api/routes.py +0 -4
- kleinkram/cli/app.py +7 -3
- kleinkram/cli/error_handling.py +23 -0
- kleinkram/utils.py +6 -2
- {kleinkram-0.38.1.dev20250113080249.dist-info → kleinkram-0.38.1.dev20250207122632.dist-info}/METADATA +1 -1
- {kleinkram-0.38.1.dev20250113080249.dist-info → kleinkram-0.38.1.dev20250207122632.dist-info}/RECORD +13 -12
- testing/backend_fixtures.py +0 -2
- tests/test_error_handling.py +44 -0
- tests/test_fixtures.py +5 -0
- tests/test_utils.py +12 -0
- {kleinkram-0.38.1.dev20250113080249.dist-info → kleinkram-0.38.1.dev20250207122632.dist-info}/WHEEL +0 -0
- {kleinkram-0.38.1.dev20250113080249.dist-info → kleinkram-0.38.1.dev20250207122632.dist-info}/entry_points.txt +0 -0
- {kleinkram-0.38.1.dev20250113080249.dist-info → kleinkram-0.38.1.dev20250207122632.dist-info}/top_level.txt +0 -0
kleinkram/api/routes.py
CHANGED
|
@@ -75,7 +75,6 @@ FILE_ENDPOINT = "/file/many"
|
|
|
75
75
|
MISSION_ENDPOINT = "/mission/many"
|
|
76
76
|
PROJECT_ENDPOINT = "/project/many"
|
|
77
77
|
|
|
78
|
-
MISSION_BY_NAME = "/mission/byName"
|
|
79
78
|
TAG_TYPE_BY_NAME = "/tag/filtered"
|
|
80
79
|
|
|
81
80
|
|
|
@@ -109,7 +108,6 @@ def _project_query_to_params(
|
|
|
109
108
|
params[Params.PROJECT_PATTERNS.value] = project_query.patterns
|
|
110
109
|
if project_query.ids:
|
|
111
110
|
params[Params.PROJECT_IDS.value] = list(map(str, project_query.ids))
|
|
112
|
-
params = _handle_list_params(params)
|
|
113
111
|
return params
|
|
114
112
|
|
|
115
113
|
|
|
@@ -119,7 +117,6 @@ def _mission_query_to_params(mission_query: MissionQuery) -> Dict[str, List[str]
|
|
|
119
117
|
params[Params.MISSION_PATTERNS.value] = mission_query.patterns
|
|
120
118
|
if mission_query.ids:
|
|
121
119
|
params[Params.MISSION_IDS.value] = list(map(str, mission_query.ids))
|
|
122
|
-
params = _handle_list_params(params)
|
|
123
120
|
return params
|
|
124
121
|
|
|
125
122
|
|
|
@@ -129,7 +126,6 @@ def _file_query_to_params(file_query: FileQuery) -> Dict[str, List[str]]:
|
|
|
129
126
|
params[Params.FILE_PATTERNS.value] = list(file_query.patterns)
|
|
130
127
|
if file_query.ids:
|
|
131
128
|
params[Params.FILE_IDS.value] = list(map(str, file_query.ids))
|
|
132
|
-
params = _handle_list_params(params)
|
|
133
129
|
return params
|
|
134
130
|
|
|
135
131
|
|
kleinkram/cli/app.py
CHANGED
|
@@ -27,6 +27,7 @@ from kleinkram.cli._project import project_typer
|
|
|
27
27
|
from kleinkram.cli._upload import upload_typer
|
|
28
28
|
from kleinkram.cli._verify import verify_typer
|
|
29
29
|
from kleinkram.cli.error_handling import ErrorHandledTyper
|
|
30
|
+
from kleinkram.cli.error_handling import display_error
|
|
30
31
|
from kleinkram.config import Config
|
|
31
32
|
from kleinkram.config import check_config_compatibility
|
|
32
33
|
from kleinkram.config import get_config
|
|
@@ -109,9 +110,12 @@ app.add_typer(project_typer, name="project", rich_help_panel=CommandTypes.CRUD)
|
|
|
109
110
|
# attach error handler to app
|
|
110
111
|
@app.error_handler(Exception)
|
|
111
112
|
def base_handler(exc: Exception) -> int:
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
shared_state = get_shared_state()
|
|
114
|
+
|
|
115
|
+
display_error(exc=exc, verbose=shared_state.verbose)
|
|
116
|
+
logger.error(format_traceback(exc))
|
|
117
|
+
|
|
118
|
+
if not shared_state.debug:
|
|
115
119
|
return 1
|
|
116
120
|
raise exc
|
|
117
121
|
|
kleinkram/cli/error_handling.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import sys
|
|
3
4
|
from collections import OrderedDict
|
|
4
5
|
from typing import Any
|
|
5
6
|
from typing import Callable
|
|
@@ -7,6 +8,10 @@ from typing import Type
|
|
|
7
8
|
|
|
8
9
|
import typer
|
|
9
10
|
from click import ClickException
|
|
11
|
+
from rich.console import Console
|
|
12
|
+
from rich.panel import Panel
|
|
13
|
+
|
|
14
|
+
from kleinkram.utils import upper_camel_case_to_words
|
|
10
15
|
|
|
11
16
|
ExceptionHandler = Callable[[Exception], int]
|
|
12
17
|
|
|
@@ -42,3 +47,21 @@ class ErrorHandledTyper(typer.Typer):
|
|
|
42
47
|
exit_code = handler(e)
|
|
43
48
|
raise SystemExit(exit_code)
|
|
44
49
|
raise
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def display_error(*, exc: Exception, verbose: bool) -> None:
|
|
53
|
+
split_exc_name = upper_camel_case_to_words(type(exc).__name__)
|
|
54
|
+
|
|
55
|
+
if verbose:
|
|
56
|
+
panel = Panel(
|
|
57
|
+
str(exc), # get the error message
|
|
58
|
+
title=" ".join(split_exc_name),
|
|
59
|
+
style="red",
|
|
60
|
+
border_style="bold",
|
|
61
|
+
)
|
|
62
|
+
Console(file=sys.stderr).print(panel)
|
|
63
|
+
else:
|
|
64
|
+
text = f"{type(exc).__name__}"
|
|
65
|
+
if str(exc):
|
|
66
|
+
text += f": {exc}"
|
|
67
|
+
print(text, file=sys.stderr)
|
kleinkram/utils.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
import base64
|
|
4
|
-
import fnmatch
|
|
5
4
|
import hashlib
|
|
5
|
+
import re
|
|
6
6
|
import string
|
|
7
7
|
import traceback
|
|
8
8
|
from hashlib import md5
|
|
@@ -14,7 +14,6 @@ from typing import Optional
|
|
|
14
14
|
from typing import Sequence
|
|
15
15
|
from typing import Tuple
|
|
16
16
|
from typing import TypeVar
|
|
17
|
-
from typing import Union
|
|
18
17
|
from uuid import UUID
|
|
19
18
|
|
|
20
19
|
import yaml
|
|
@@ -55,6 +54,11 @@ def file_paths_from_files(
|
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
|
|
57
|
+
def upper_camel_case_to_words(s: str) -> List[str]:
|
|
58
|
+
"""split `s` given upper camel case to words"""
|
|
59
|
+
return re.sub("([a-z])([A-Z])", r"\1 \2", s).split()
|
|
60
|
+
|
|
61
|
+
|
|
58
62
|
def split_args(args: Sequence[str]) -> Tuple[List[UUID], List[str]]:
|
|
59
63
|
"""\
|
|
60
64
|
split a sequece of strings into a list of UUIDs and a list of names
|
{kleinkram-0.38.1.dev20250113080249.dist-info → kleinkram-0.38.1.dev20250207122632.dist-info}/RECORD
RENAMED
|
@@ -10,7 +10,7 @@ kleinkram/models.py,sha256=8nJlPrKVLSmehspeuQSFV6nUo76JzehUn6KIZYH1xy4,1832
|
|
|
10
10
|
kleinkram/printing.py,sha256=fgSlfRaGqQ7dNiIZGMvEPxMatmUL3MrCvh2ibrz9b_s,9914
|
|
11
11
|
kleinkram/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
12
12
|
kleinkram/types.py,sha256=nfDjj8TB1Jn5vqO0Xg6qhLOuKom9DDhe62BrngqnVGM,185
|
|
13
|
-
kleinkram/utils.py,sha256=
|
|
13
|
+
kleinkram/utils.py,sha256=6HFqTw7-eqDEjNG_PsVEQNMNK-RWOqPsoiZI5SK8F7Q,6270
|
|
14
14
|
kleinkram/wrappers.py,sha256=4xXU43eNnvMG2sssU330MmTLSSRdurOpnZ-zNGOGmt0,11342
|
|
15
15
|
kleinkram/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
16
|
kleinkram/api/client.py,sha256=t6pWY29bQi36IhfIy98Ijc-w-3LzcBTJxXprfPIdwJo,3614
|
|
@@ -18,7 +18,7 @@ kleinkram/api/deser.py,sha256=-eP0haBAFr-dRWJ1v-P5o_rxA8vOBlZMtAGXW8ItIAk,4870
|
|
|
18
18
|
kleinkram/api/file_transfer.py,sha256=VbVQh6F7r81207OIx8zwnRGhA6SpXmzBhJQHQgR8tso,12982
|
|
19
19
|
kleinkram/api/pagination.py,sha256=P_zPsBKlMWkmAv-YfUNHaGW-XLB_4U8BDMrKyiDFIXk,1370
|
|
20
20
|
kleinkram/api/query.py,sha256=gn5yf-eRB_Bcw2diLjt66yQtorrZMKdj5_oNA_oOhvc,3281
|
|
21
|
-
kleinkram/api/routes.py,sha256=
|
|
21
|
+
kleinkram/api/routes.py,sha256=xtNZOwrcjcePSrrx7tY0bCB_i6m9z2Gtd8rvrMfxpnM,12111
|
|
22
22
|
kleinkram/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
kleinkram/cli/_download.py,sha256=H4YlXJkZE4Md02nzgrO_i8Hsm4ZIejPsxBEKkcn4KHs,2371
|
|
24
24
|
kleinkram/cli/_endpoint.py,sha256=oY0p4bnuHLEDJCXtTmir4AHswcKAygZ8I4IWC3RFcKc,1796
|
|
@@ -27,22 +27,23 @@ kleinkram/cli/_mission.py,sha256=zDFnOozOFckpuREFgIPt1IzG5q3b1bsNxYlWQoHoz5A,530
|
|
|
27
27
|
kleinkram/cli/_project.py,sha256=N0C96NC_onCEwTteYp2wgkkwkdJt-1q43LFdqNXfjC8,3398
|
|
28
28
|
kleinkram/cli/_upload.py,sha256=gOhbjbmqhmwW7p6bWlSvI53vLHvBFO9QqD1kdU92I2k,2813
|
|
29
29
|
kleinkram/cli/_verify.py,sha256=0ABVa4U_WzaV36ClR8NsOIG7KAMRlnFmsbtnHhbWVj4,1742
|
|
30
|
-
kleinkram/cli/app.py,sha256=
|
|
31
|
-
kleinkram/cli/error_handling.py,sha256=
|
|
30
|
+
kleinkram/cli/app.py,sha256=pBPv_rDVer5aCelLLfBBqEofSm0yDB3GOBT6qVkd2vw,6539
|
|
31
|
+
kleinkram/cli/error_handling.py,sha256=wK3tzeKVSrZm-xmiyzGLnGT2E4TRpyxhaak6GWGP7P8,1921
|
|
32
32
|
testing/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
33
|
-
testing/backend_fixtures.py,sha256=
|
|
33
|
+
testing/backend_fixtures.py,sha256=79gB_s9cun3B1KGUA0YFcga5rN-rm_9zTRt1HajxRbI,1590
|
|
34
34
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
35
35
|
tests/conftest.py,sha256=5MLYQOtQoXWl0TRkYntYKNdqpd4hl9m0XTRi5OXanYI,104
|
|
36
36
|
tests/test_config.py,sha256=gfQUjwJb2rfvrNbi7cfkNwLr_DFn4mWMM29l3bunsBk,3269
|
|
37
37
|
tests/test_core.py,sha256=JbzB05LWmaaP77uXeTOQtCJD2AJT0zO9zhDfcZ3GNH8,5139
|
|
38
38
|
tests/test_end_to_end.py,sha256=kIY62viZk2_d5HGt4GVNTkDjR0f1IkAv9OJ8HSqcBG8,3172
|
|
39
|
-
tests/
|
|
39
|
+
tests/test_error_handling.py,sha256=qPSMKF1qsAHyUME0-krxbIrk38iGKkhAyAah-KwN4NE,1300
|
|
40
|
+
tests/test_fixtures.py,sha256=UlPmGbEsGvrDPsaStGMRjNvrVPGjCqOB0RMfLJq2VRA,1071
|
|
40
41
|
tests/test_printing.py,sha256=qCr04OJVl5ouht9FoeWGKOi8MZXevVV1EDghzV1JaMc,1903
|
|
41
42
|
tests/test_query.py,sha256=fExmCKXLA7-9j2S2sF_sbvRX_2s6Cp3a7OTcqE25q9g,3864
|
|
42
|
-
tests/test_utils.py,sha256=
|
|
43
|
+
tests/test_utils.py,sha256=eUBYrn3xrcgcaxm1X4fqZaX4tRvkbI6rh6BUbNbu9T0,4784
|
|
43
44
|
tests/test_wrappers.py,sha256=TbcTyO2L7fslbzgfDdcVZkencxNQ8cGPZm_iB6c9d6Q,2673
|
|
44
|
-
kleinkram-0.38.1.
|
|
45
|
-
kleinkram-0.38.1.
|
|
46
|
-
kleinkram-0.38.1.
|
|
47
|
-
kleinkram-0.38.1.
|
|
48
|
-
kleinkram-0.38.1.
|
|
45
|
+
kleinkram-0.38.1.dev20250207122632.dist-info/METADATA,sha256=iRYZsQuqJldM_lQrNcC3EBuUuut-8VX77uNt9Z-2rR0,2333
|
|
46
|
+
kleinkram-0.38.1.dev20250207122632.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
47
|
+
kleinkram-0.38.1.dev20250207122632.dist-info/entry_points.txt,sha256=SaB2l5aqhSr8gmaMw2kvQU90a8Bnl7PedU8cWYxkfYo,46
|
|
48
|
+
kleinkram-0.38.1.dev20250207122632.dist-info/top_level.txt,sha256=N3-sJagEHu1Tk1X6Dx1X1q0pLDNbDZpLzRxVftvepds,24
|
|
49
|
+
kleinkram-0.38.1.dev20250207122632.dist-info/RECORD,,
|
testing/backend_fixtures.py
CHANGED
|
@@ -8,9 +8,7 @@ import pytest
|
|
|
8
8
|
|
|
9
9
|
from kleinkram import create_mission
|
|
10
10
|
from kleinkram import create_project
|
|
11
|
-
from kleinkram import delete_mission
|
|
12
11
|
from kleinkram import delete_project
|
|
13
|
-
from kleinkram import list_files
|
|
14
12
|
from kleinkram import list_missions
|
|
15
13
|
from kleinkram import list_projects
|
|
16
14
|
from kleinkram import upload
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
5
|
+
from kleinkram.cli.error_handling import display_error
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MyException(Exception):
|
|
9
|
+
pass
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def test_display_error_not_verbose(capsys):
|
|
13
|
+
exc = MyException("hello")
|
|
14
|
+
|
|
15
|
+
display_error(exc=exc, verbose=False)
|
|
16
|
+
|
|
17
|
+
out, err = capsys.readouterr()
|
|
18
|
+
|
|
19
|
+
assert out == ""
|
|
20
|
+
assert err == "MyException: hello\n"
|
|
21
|
+
|
|
22
|
+
exc = MyException()
|
|
23
|
+
|
|
24
|
+
display_error(exc=exc, verbose=False)
|
|
25
|
+
|
|
26
|
+
out, err = capsys.readouterr()
|
|
27
|
+
|
|
28
|
+
assert out == ""
|
|
29
|
+
assert err == "MyException\n"
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def test_display_error_verbose(capsys):
|
|
33
|
+
exc = MyException("hello")
|
|
34
|
+
|
|
35
|
+
display_error(exc=exc, verbose=True)
|
|
36
|
+
|
|
37
|
+
out, err = capsys.readouterr()
|
|
38
|
+
|
|
39
|
+
assert out == ""
|
|
40
|
+
assert err == (
|
|
41
|
+
"╭──────────────────────────────── My Exception ────────────────────────────────╮\n"
|
|
42
|
+
"│ hello │\n"
|
|
43
|
+
"╰──────────────────────────────────────────────────────────────────────────────╯\n"
|
|
44
|
+
)
|
tests/test_fixtures.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
+
import pytest
|
|
4
|
+
|
|
3
5
|
from kleinkram import list_files
|
|
4
6
|
from kleinkram import list_missions
|
|
5
7
|
from kleinkram import list_projects
|
|
@@ -7,11 +9,13 @@ from testing.backend_fixtures import DATA_FILES
|
|
|
7
9
|
from testing.backend_fixtures import PROJECT_DESCRIPTION
|
|
8
10
|
|
|
9
11
|
|
|
12
|
+
@pytest.mark.slow
|
|
10
13
|
def test_project_fixture(project):
|
|
11
14
|
assert list_projects(project_ids=[project.id])[0].id == project.id
|
|
12
15
|
assert project.description == PROJECT_DESCRIPTION
|
|
13
16
|
|
|
14
17
|
|
|
18
|
+
@pytest.mark.slow
|
|
15
19
|
def test_mission_fixture(mission, project):
|
|
16
20
|
assert mission.project_id == project.id
|
|
17
21
|
assert list_missions(mission_ids=[mission.id])[0].id == mission.id
|
|
@@ -23,6 +27,7 @@ def test_mission_fixture(mission, project):
|
|
|
23
27
|
)
|
|
24
28
|
|
|
25
29
|
|
|
30
|
+
@pytest.mark.slow
|
|
26
31
|
def test_empty_mission_fixture(empty_mission, project):
|
|
27
32
|
assert empty_mission.project_id == project.id
|
|
28
33
|
assert list_missions(mission_ids=[empty_mission.id])[0].id == empty_mission.id
|
tests/test_utils.py
CHANGED
|
@@ -17,6 +17,7 @@ from kleinkram.utils import parse_path_like
|
|
|
17
17
|
from kleinkram.utils import parse_uuid_like
|
|
18
18
|
from kleinkram.utils import singleton_list
|
|
19
19
|
from kleinkram.utils import split_args
|
|
20
|
+
from kleinkram.utils import upper_camel_case_to_words
|
|
20
21
|
|
|
21
22
|
|
|
22
23
|
def test_split_args():
|
|
@@ -135,3 +136,14 @@ def test_parse_uuid_like() -> None:
|
|
|
135
136
|
def test_parse_path_like() -> None:
|
|
136
137
|
assert parse_path_like("test") == Path("test")
|
|
137
138
|
assert parse_path_like(Path("test")) == Path("test")
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_upper_camel_case_to_words() -> None:
|
|
142
|
+
assert upper_camel_case_to_words("HelloWorld") == ["Hello", "World"]
|
|
143
|
+
assert upper_camel_case_to_words("HelloWorldAgain") == ["Hello", "World", "Again"]
|
|
144
|
+
assert upper_camel_case_to_words("Hello") == ["Hello"]
|
|
145
|
+
assert upper_camel_case_to_words("hello") == ["hello"]
|
|
146
|
+
assert upper_camel_case_to_words("") == []
|
|
147
|
+
assert upper_camel_case_to_words("not_camel_case") == ["not_camel_case"]
|
|
148
|
+
assert upper_camel_case_to_words("*#?-_") == ["*#?-_"]
|
|
149
|
+
assert upper_camel_case_to_words("helloWorld") == ["hello", "World"]
|
{kleinkram-0.38.1.dev20250113080249.dist-info → kleinkram-0.38.1.dev20250207122632.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|