kleinkram 0.43.5__py3-none-any.whl → 0.43.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.

Potentially problematic release.


This version of kleinkram might be problematic. Click here for more details.

@@ -309,10 +309,10 @@ def download_file(
309
309
  if path.exists():
310
310
  local_hash = b64_md5(path)
311
311
  if local_hash != file.hash and not overwrite and file.hash is not None:
312
- return DownloadState.SKIPPED_INVALID_HASH
312
+ return DownloadState.SKIPPED_INVALID_HASH, 0
313
313
 
314
314
  elif local_hash == file.hash:
315
- return DownloadState.SKIPPED_OK
315
+ return DownloadState.SKIPPED_OK, 0
316
316
 
317
317
  # this has to be here
318
318
  if verbose:
kleinkram/wrappers.py CHANGED
@@ -9,7 +9,7 @@ conversion to the internal representation
9
9
  from __future__ import annotations
10
10
 
11
11
  from pathlib import Path
12
- from typing import Collection
12
+ from typing import Collection, Any
13
13
  from typing import Dict
14
14
  from typing import List
15
15
  from typing import Literal
@@ -39,6 +39,11 @@ def _args_to_project_query(
39
39
  project_names: Optional[Sequence[str]] = None,
40
40
  project_ids: Optional[Sequence[IdLike]] = None,
41
41
  ) -> ProjectQuery:
42
+
43
+ # verify types of passed arguments
44
+ _verify_string_sequence("project_names", project_names)
45
+ _verify_sequence("project_ids", project_ids)
46
+
42
47
  return ProjectQuery(
43
48
  ids=[parse_uuid_like(_id) for _id in project_ids or []],
44
49
  patterns=list(project_names or []),
@@ -51,6 +56,13 @@ def _args_to_mission_query(
51
56
  project_names: Optional[Sequence[str]] = None,
52
57
  project_ids: Optional[Sequence[IdLike]] = None,
53
58
  ) -> MissionQuery:
59
+
60
+ # verify types of passed arguments
61
+ _verify_string_sequence("mission_names", mission_names)
62
+ _verify_sequence("mission_ids", mission_ids)
63
+ _verify_string_sequence("project_names", project_names)
64
+ _verify_sequence("project_ids", project_ids)
65
+
54
66
  return MissionQuery(
55
67
  ids=[parse_uuid_like(_id) for _id in mission_ids or []],
56
68
  patterns=list(mission_names or []),
@@ -60,6 +72,27 @@ def _args_to_mission_query(
60
72
  )
61
73
 
62
74
 
75
+ def _verify_sequence(arg_name: str, arg_value: Optional[Sequence[Any]]) -> None:
76
+ """Verifies that an argument is either None, or a sequence."""
77
+ if arg_value is not None:
78
+ if not isinstance(arg_value, Sequence):
79
+ raise TypeError(f"{arg_name} must be a Sequence, None, or empty array.")
80
+
81
+
82
+ def _verify_string_sequence(arg_name: str, arg_value: Optional[Sequence[Any]]) -> None:
83
+ """Verifies that an argument is either None, an empty sequence, or a sequence of strings."""
84
+ if arg_value is not None:
85
+ if not isinstance(arg_value, Sequence):
86
+ raise TypeError(f"{arg_name} must be a Sequence, None, or empty array.")
87
+ if isinstance(arg_value, str):
88
+ raise TypeError(
89
+ f"{arg_name} cannot be a string, but a sequence of strings."
90
+ )
91
+ for item in arg_value:
92
+ if not isinstance(item, str):
93
+ raise TypeError(f"{arg_name} must contain strings only.")
94
+
95
+
63
96
  def _args_to_file_query(
64
97
  file_names: Optional[Sequence[str]] = None,
65
98
  file_ids: Optional[Sequence[IdLike]] = None,
@@ -68,6 +101,15 @@ def _args_to_file_query(
68
101
  project_names: Optional[Sequence[str]] = None,
69
102
  project_ids: Optional[Sequence[IdLike]] = None,
70
103
  ) -> FileQuery:
104
+
105
+ # verify types of passed arguments
106
+ _verify_string_sequence("file_names", file_names)
107
+ _verify_sequence("file_ids", file_ids)
108
+ _verify_string_sequence("mission_names", mission_names)
109
+ _verify_sequence("mission_ids", mission_ids)
110
+ _verify_string_sequence("project_names", project_names)
111
+ _verify_sequence("project_ids", project_ids)
112
+
71
113
  return FileQuery(
72
114
  ids=[parse_uuid_like(_id) for _id in file_ids or []],
73
115
  patterns=list(file_names or []),
@@ -288,6 +330,9 @@ def verify(
288
330
  project_names=singleton_list(project_name),
289
331
  project_ids=singleton_list(project_id),
290
332
  )
333
+
334
+ _verify_string_sequence("files", files)
335
+
291
336
  return kleinkram.core.verify(
292
337
  client=AuthenticatedClient(),
293
338
  query=query,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kleinkram
3
- Version: 0.43.5
3
+ Version: 0.43.6
4
4
  Summary: give me your bags
5
5
  Author: Cyrill Püntener, Dominique Garmier, Johann Schwabe
6
6
  Author-email: pucyril@ethz.ch, dgarmier@ethz.ch, jschwab@ethz.ch
@@ -11,11 +11,11 @@ kleinkram/printing.py,sha256=_vIjs-lPVgv21ER5q5iYtx44OTs5y8wyd32w27WqocM,12161
11
11
  kleinkram/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
12
  kleinkram/types.py,sha256=nfDjj8TB1Jn5vqO0Xg6qhLOuKom9DDhe62BrngqnVGM,185
13
13
  kleinkram/utils.py,sha256=AsKZxEGStn03L2tqqiMVCQCrDyl8HhwOfpa3no4dfYc,6767
14
- kleinkram/wrappers.py,sha256=4xXU43eNnvMG2sssU330MmTLSSRdurOpnZ-zNGOGmt0,11342
14
+ kleinkram/wrappers.py,sha256=ZScoEov5Q6D2rvaJJ8E-4f58P_NGWrGc9mRPYxSqOC0,13127
15
15
  kleinkram/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  kleinkram/api/client.py,sha256=VwuT97_WdbDpcVGwMXB0fRnUoQnUSf7BOP5eXUFokfI,5932
17
17
  kleinkram/api/deser.py,sha256=xRpYUFKZ0Luoo7XyAtYblJvprmpjNSZOiFVnFKmOzcM,4819
18
- kleinkram/api/file_transfer.py,sha256=smzT_gQjmJHeVYdlfmpCH6CRS_Swx-Kp-3Q8lvTNrqQ,17452
18
+ kleinkram/api/file_transfer.py,sha256=IqQoKdpK9oqPllE4deell64VoP__vjKOU8lY2gao4vQ,17458
19
19
  kleinkram/api/pagination.py,sha256=P_zPsBKlMWkmAv-YfUNHaGW-XLB_4U8BDMrKyiDFIXk,1370
20
20
  kleinkram/api/query.py,sha256=9Exi4hJR7Ml38_zjAcOvSEoIAxZLlpM6QwwzO9fs5Gk,3293
21
21
  kleinkram/api/routes.py,sha256=x0IfzQO5RAC3rohDSpdUNlVOWl221gh4e0fbMKfGrQA,12251
@@ -43,8 +43,8 @@ tests/test_printing.py,sha256=Jz1AjqmqBRjp1JLm6H1oVJyvGaMPlahVXdKnd7UDQFc,2231
43
43
  tests/test_query.py,sha256=fExmCKXLA7-9j2S2sF_sbvRX_2s6Cp3a7OTcqE25q9g,3864
44
44
  tests/test_utils.py,sha256=eUBYrn3xrcgcaxm1X4fqZaX4tRvkbI6rh6BUbNbu9T0,4784
45
45
  tests/test_wrappers.py,sha256=TbcTyO2L7fslbzgfDdcVZkencxNQ8cGPZm_iB6c9d6Q,2673
46
- kleinkram-0.43.5.dist-info/METADATA,sha256=SSuH0PZniJ2cceZCexQvUGq5n69f54TANO4IWA9FBbY,2807
47
- kleinkram-0.43.5.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
48
- kleinkram-0.43.5.dist-info/entry_points.txt,sha256=SaB2l5aqhSr8gmaMw2kvQU90a8Bnl7PedU8cWYxkfYo,46
49
- kleinkram-0.43.5.dist-info/top_level.txt,sha256=N3-sJagEHu1Tk1X6Dx1X1q0pLDNbDZpLzRxVftvepds,24
50
- kleinkram-0.43.5.dist-info/RECORD,,
46
+ kleinkram-0.43.6.dist-info/METADATA,sha256=UXlKRQqqCEhxWPgaYC8Bd7ujsKiwHc3qjPIxz8hFJ6Y,2807
47
+ kleinkram-0.43.6.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
48
+ kleinkram-0.43.6.dist-info/entry_points.txt,sha256=SaB2l5aqhSr8gmaMw2kvQU90a8Bnl7PedU8cWYxkfYo,46
49
+ kleinkram-0.43.6.dist-info/top_level.txt,sha256=N3-sJagEHu1Tk1X6Dx1X1q0pLDNbDZpLzRxVftvepds,24
50
+ kleinkram-0.43.6.dist-info/RECORD,,