kleinkram 0.52.0.dev20251010062623__py3-none-any.whl → 0.52.0.dev20251015122123__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/deser.py CHANGED
@@ -54,6 +54,8 @@ class MissionObjectKeys(str, Enum):
54
54
  CREATED_AT = "createdAt"
55
55
  UPDATED_AT = "updatedAt"
56
56
  TAGS = "tags"
57
+ FILESIZE = "size"
58
+ FILECOUNT = "filesCount"
57
59
 
58
60
 
59
61
  class ProjectObjectKeys(str, Enum):
@@ -135,6 +137,8 @@ def _parse_mission(mission: MissionObject) -> Mission:
135
137
  created_at = _parse_datetime(mission[MissionObjectKeys.CREATED_AT])
136
138
  updated_at = _parse_datetime(mission[MissionObjectKeys.UPDATED_AT])
137
139
  metadata = _parse_metadata(mission[MissionObjectKeys.TAGS])
140
+ file_count = mission[MissionObjectKeys.FILECOUNT]
141
+ filesize = mission[MissionObjectKeys.FILESIZE]
138
142
 
139
143
  project_id, project_name = _get_nested_info(mission, PROJECT)
140
144
 
@@ -146,6 +150,8 @@ def _parse_mission(mission: MissionObject) -> Mission:
146
150
  metadata=metadata,
147
151
  project_id=project_id,
148
152
  project_name=project_name,
153
+ number_of_files=file_count,
154
+ size=filesize,
149
155
  )
150
156
  except Exception as e:
151
157
  raise ParsingError(f"error parsing mission: {mission}") from e
kleinkram/api/routes.py CHANGED
@@ -43,6 +43,7 @@ from kleinkram.errors import MissionNotFound
43
43
  from kleinkram.errors import MissionValidationError
44
44
  from kleinkram.errors import ProjectExists
45
45
  from kleinkram.errors import ProjectNotFound
46
+ from kleinkram.errors import ProjectValidationError
46
47
  from kleinkram.models import File
47
48
  from kleinkram.models import Mission
48
49
  from kleinkram.models import Project
@@ -256,7 +257,7 @@ def _validate_mission_name(
256
257
  def _project_name_is_available(client: AuthenticatedClient, project_name: str) -> bool:
257
258
  project_query = ProjectQuery(patterns=[project_name])
258
259
  try:
259
- _ = get_project(client, project_query)
260
+ _ = get_project(client, project_query, exact_match=True)
260
261
  except ProjectNotFound:
261
262
  return True
262
263
  return False
@@ -350,10 +351,8 @@ def _create_mission(
350
351
  def _create_project(
351
352
  client: AuthenticatedClient, project_name: str, description: str
352
353
  ) -> UUID:
353
- if not _project_name_is_available(client, project_name):
354
- raise ProjectExists(f"Project with name: `{project_name}` already exists")
355
354
 
356
- # TODO: check name and description are valid
355
+ _validate_project_name(client, project_name, description)
357
356
  payload = {"name": project_name, "description": description}
358
357
  resp = client.post(CREATE_PROJECT, json=payload)
359
358
  resp.raise_for_status()
@@ -361,6 +360,21 @@ def _create_project(
361
360
  return UUID(resp.json()["uuid"], version=4)
362
361
 
363
362
 
363
+ def _validate_project_name(
364
+ client: AuthenticatedClient, project_name: str, description: str
365
+ ) -> None:
366
+ if not _project_name_is_available(client, project_name):
367
+ raise ProjectExists(f"Project with name: `{project_name}` already exists")
368
+
369
+ if project_name.endswith(" "):
370
+ raise ProjectValidationError(
371
+ f"Project name must not end with a tailing whitespace: `{project_name}`"
372
+ )
373
+
374
+ if not description:
375
+ raise ProjectValidationError("Project description is required")
376
+
377
+
364
378
  def _validate_tag_value(tag_value, tag_datatype) -> None:
365
379
  if tag_datatype == "NUMBER":
366
380
  try:
kleinkram/cli/_mission.py CHANGED
@@ -46,7 +46,7 @@ def create(
46
46
  metadata_dct = load_metadata(Path(metadata)) if metadata else {} # noqa
47
47
 
48
48
  client = AuthenticatedClient()
49
- project = get_project(client, project_query)
49
+ project = get_project(client, project_query, exact_match=True)
50
50
  project_id = project.id
51
51
  project_required_tags = project.required_tags
52
52
  mission_id = kleinkram.api.routes._create_mission(
kleinkram/cli/_project.py CHANGED
@@ -73,7 +73,7 @@ def update(
73
73
  project_query = ProjectQuery(ids=project_ids, patterns=project_patterns)
74
74
 
75
75
  client = AuthenticatedClient()
76
- project_id = get_project(client=client, query=project_query).id
76
+ project_id = get_project(client=client, query=project_query, exact_match=True).id
77
77
  kleinkram.core.update_project(
78
78
  client=client, project_id=project_id, description=description, new_name=new_name
79
79
  )
kleinkram/core.py CHANGED
@@ -107,7 +107,9 @@ def upload(
107
107
 
108
108
  if create and mission is None:
109
109
  # check if project exists and get its id at the same time
110
- project = kleinkram.api.routes.get_project(client, query=query.project_query)
110
+ project = kleinkram.api.routes.get_project(
111
+ client, query=query.project_query, exact_match=True
112
+ )
111
113
  project_id = project.id
112
114
  project_required_tags = project.required_tags
113
115
  mission_name = check_mission_query_is_creatable(query)
kleinkram/errors.py CHANGED
@@ -52,6 +52,9 @@ class InvalidMissionMetadata(Exception): ...
52
52
  class MissionValidationError(Exception): ...
53
53
 
54
54
 
55
+ class ProjectValidationError(Exception): ...
56
+
57
+
55
58
  class NotAuthenticated(Exception):
56
59
  def __init__(self) -> None:
57
60
  super().__init__(LOGIN_MESSAGE)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: kleinkram
3
- Version: 0.52.0.dev20251010062623
3
+ Version: 0.52.0.dev20251015122123
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
@@ -3,8 +3,8 @@ kleinkram/__main__.py,sha256=B9RiZxfO4jpCmWPUHyKJ7_EoZlEG4sPpH-nz7T_YhhQ,125
3
3
  kleinkram/_version.py,sha256=QYJyRTcqFcJj4qWYpqs7WcoOP6jxDMqyvxLY-cD6KcE,129
4
4
  kleinkram/auth.py,sha256=PdSYZZO8AauNLZbn9PBgPM3o-O_nwoOKTj94EGnPRE8,3003
5
5
  kleinkram/config.py,sha256=nx6uSM5nLP4SKe8b9VAx4KDtCCwtyshXmzbEJcUwpsY,7411
6
- kleinkram/core.py,sha256=N91W_IRw7yH9pR-_wAmaVjcGgiz0xF7QwG20863oOiY,9760
7
- kleinkram/errors.py,sha256=C0P7Clw-wLIo9v03aRP2B5_2GjctzlinIFIFe7qZ9OQ,1057
6
+ kleinkram/core.py,sha256=t3kUVwGiTlwJQRjvM8NyOIEkCyoH97y5tmtXe5Jge9o,9800
7
+ kleinkram/errors.py,sha256=vb_yv7dKyx8Osngn3S4_0k40wboGiCyGiuWn4II5TyU,1104
8
8
  kleinkram/main.py,sha256=BTE0mZN__xd46wBhFi6iBlK9eGGQvJ1LdUMsbnysLi0,172
9
9
  kleinkram/models.py,sha256=0C_TharLDHA4RCe6Plas9N_uO_teN1Z4iP70WljOAfs,1899
10
10
  kleinkram/printing.py,sha256=9o4UQq9MYkGwMIlTchbdMLjUROdJWB100Lq1b3OFfko,12280
@@ -14,18 +14,18 @@ kleinkram/utils.py,sha256=AtaTvEQ0TrGaQtZylwniE9l1u7_IRYigLT2bc_jc-lQ,6790
14
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
- kleinkram/api/deser.py,sha256=6ar6_WbgvTIkx1rNRzvVP9YNa5BrFD4181q1fml1KwU,5637
17
+ kleinkram/api/deser.py,sha256=pUahCRlPSWBNS-vEMVSTUCzASkabMR2Y4w6jFUC0PVk,5868
18
18
  kleinkram/api/file_transfer.py,sha256=Ija34JXaszZR7_hvb08aVzq-DB2KG3ze-qqb7zjrchQ,19985
19
19
  kleinkram/api/pagination.py,sha256=VqjIPMzcD2FY3yeBmP76S7vprUGnuFfTLOzbskqnl0U,1511
20
20
  kleinkram/api/query.py,sha256=9Exi4hJR7Ml38_zjAcOvSEoIAxZLlpM6QwwzO9fs5Gk,3293
21
- kleinkram/api/routes.py,sha256=buWu4BKdAF1Tk3fmT-MiuG_otJ2Sv4lIcEVE9cZ8isg,15264
21
+ kleinkram/api/routes.py,sha256=8UShj36X6hUSJ5Ud8u6rInptc_P-an1XGAReEFbkfRI,15723
22
22
  kleinkram/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
23
23
  kleinkram/cli/_download.py,sha256=e0fDyp_CFOdbKIUGKmtITvAVINa6STYJk5w5QlElXSs,2394
24
24
  kleinkram/cli/_endpoint.py,sha256=oY0p4bnuHLEDJCXtTmir4AHswcKAygZ8I4IWC3RFcKc,1796
25
25
  kleinkram/cli/_file.py,sha256=Q2fLDdUyfHFmdGC6wIxMqgEl0F76qszhzWJrRV5rTBM,2973
26
26
  kleinkram/cli/_list.py,sha256=5gI3aIUeKC0_eWPQqdFXSBBFvpkTTJSm31TamHa197c,3090
27
- kleinkram/cli/_mission.py,sha256=3ZMPRlPZIvJwmFQqeXu6N8DcmYtSVGj4xWHuAdKAlsc,5845
28
- kleinkram/cli/_project.py,sha256=tvVwcNaBYKZhIh6KjPcdyyTmaep6y-GvG_sV7O49Ov0,3416
27
+ kleinkram/cli/_mission.py,sha256=cXtBaL2w5p4B7xxwuvOa-eqnzLNC1FZMbnNuO87VlLE,5863
28
+ kleinkram/cli/_project.py,sha256=FDF-FH26nTZf4Y_7DZoFsRnybQr4W6LNAppXqWdAZ1c,3434
29
29
  kleinkram/cli/_upload.py,sha256=EFxbf4SNLuse_lPt0EIpfQLB-1pw7-oHNLdjxLrdMYE,3491
30
30
  kleinkram/cli/_verify.py,sha256=n9QThY0JnqaIqw6udYXdRQGcpUl2lIbFXGQIgpTnDPE,2112
31
31
  kleinkram/cli/app.py,sha256=Yetkt2jd6cggor7mPpV9Lcp6aLd45rACdF1nBW0uy9k,7546
@@ -43,8 +43,8 @@ tests/test_printing.py,sha256=kPzpIQOtQJ9yQ32mM8cMGDVOGsbrZZLQhfsXN1Pe68Q,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.52.0.dev20251010062623.dist-info/METADATA,sha256=nUeOO2IRhaAaKUSfzlsxutXKax3AjdnWub8NQMVo6NU,2846
47
- kleinkram-0.52.0.dev20251010062623.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
- kleinkram-0.52.0.dev20251010062623.dist-info/entry_points.txt,sha256=SaB2l5aqhSr8gmaMw2kvQU90a8Bnl7PedU8cWYxkfYo,46
49
- kleinkram-0.52.0.dev20251010062623.dist-info/top_level.txt,sha256=N3-sJagEHu1Tk1X6Dx1X1q0pLDNbDZpLzRxVftvepds,24
50
- kleinkram-0.52.0.dev20251010062623.dist-info/RECORD,,
46
+ kleinkram-0.52.0.dev20251015122123.dist-info/METADATA,sha256=ced216npmVeMIUao-BioYUIxvPrvNHHT25eWMxmY_04,2846
47
+ kleinkram-0.52.0.dev20251015122123.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
48
+ kleinkram-0.52.0.dev20251015122123.dist-info/entry_points.txt,sha256=SaB2l5aqhSr8gmaMw2kvQU90a8Bnl7PedU8cWYxkfYo,46
49
+ kleinkram-0.52.0.dev20251015122123.dist-info/top_level.txt,sha256=N3-sJagEHu1Tk1X6Dx1X1q0pLDNbDZpLzRxVftvepds,24
50
+ kleinkram-0.52.0.dev20251015122123.dist-info/RECORD,,