dsp-tools 17.0.0.post25__py3-none-any.whl → 17.0.0.post26__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 dsp-tools might be problematic. Click here for more details.

@@ -31,6 +31,8 @@ from dsp_tools.commands.xmlupload.xmlupload import xmlupload
31
31
  from dsp_tools.error.exceptions import DockerNotReachableError
32
32
  from dsp_tools.error.exceptions import DspApiNotReachableError
33
33
  from dsp_tools.error.exceptions import InputError
34
+ from dsp_tools.error.exceptions import UserDirectoryNotFoundError
35
+ from dsp_tools.error.exceptions import UserFilepathNotFoundError
34
36
  from dsp_tools.utils.xml_parsing.parse_clean_validate_xml import parse_and_validate_xml_file
35
37
 
36
38
  LOCALHOST_API = "http://0.0.0.0:3333"
@@ -119,6 +121,8 @@ def _call_start_stack(args: argparse.Namespace) -> bool:
119
121
 
120
122
 
121
123
  def _call_id2iri(args: argparse.Namespace) -> bool:
124
+ _check_filepath_exists(Path(args.xmlfile))
125
+ _check_filepath_exists(Path(args.mapping))
122
126
  return id2iri(
123
127
  xml_file=args.xmlfile,
124
128
  json_file=args.mapping,
@@ -127,6 +131,7 @@ def _call_id2iri(args: argparse.Namespace) -> bool:
127
131
 
128
132
 
129
133
  def _call_excel2properties(args: argparse.Namespace) -> bool:
134
+ _check_filepath_exists(Path(args.excelfile))
130
135
  _, _, success = excel2properties(
131
136
  excelfile=args.excelfile,
132
137
  path_to_output_file=args.properties_section,
@@ -135,6 +140,7 @@ def _call_excel2properties(args: argparse.Namespace) -> bool:
135
140
 
136
141
 
137
142
  def _call_excel2resources(args: argparse.Namespace) -> bool:
143
+ _check_filepath_exists(Path(args.excelfile))
138
144
  _, _, success = excel2resources(
139
145
  excelfile=args.excelfile,
140
146
  path_to_output_file=args.resources_section,
@@ -143,6 +149,7 @@ def _call_excel2resources(args: argparse.Namespace) -> bool:
143
149
 
144
150
 
145
151
  def _call_old_excel2lists(args: argparse.Namespace) -> bool:
152
+ _check_directory_exists(Path(args.excelfolder))
146
153
  _, success = old_excel2lists(
147
154
  excelfolder=args.excelfolder,
148
155
  path_to_output_file=args.lists_section,
@@ -152,6 +159,7 @@ def _call_old_excel2lists(args: argparse.Namespace) -> bool:
152
159
 
153
160
 
154
161
  def _call_excel2lists(args: argparse.Namespace) -> bool:
162
+ _check_directory_exists(Path(args.excelfolder))
155
163
  _, success = excel2lists(
156
164
  excelfolder=args.excelfolder,
157
165
  path_to_output_file=args.lists_section,
@@ -160,6 +168,7 @@ def _call_excel2lists(args: argparse.Namespace) -> bool:
160
168
 
161
169
 
162
170
  def _call_excel2json(args: argparse.Namespace) -> bool:
171
+ _check_directory_exists(Path(args.excelfolder))
163
172
  return excel2json(
164
173
  data_model_files=args.excelfolder,
165
174
  path_to_output_file=args.project_definition,
@@ -167,6 +176,7 @@ def _call_excel2json(args: argparse.Namespace) -> bool:
167
176
 
168
177
 
169
178
  def _call_old_excel2json(args: argparse.Namespace) -> bool:
179
+ _check_directory_exists(Path(args.excelfolder))
170
180
  return old_excel2json(
171
181
  data_model_files=args.excelfolder,
172
182
  path_to_output_file=args.project_definition,
@@ -175,8 +185,10 @@ def _call_old_excel2json(args: argparse.Namespace) -> bool:
175
185
 
176
186
  def _call_upload_files(args: argparse.Namespace) -> bool:
177
187
  _check_health_with_docker_on_localhost(args.server)
188
+ xml_path = Path(args.xml_file)
189
+ _check_filepath_exists(xml_path)
178
190
  return upload_files(
179
- xml_file=Path(args.xml_file),
191
+ xml_file=xml_path,
180
192
  creds=_get_creds(args),
181
193
  imgdir=Path(args.imgdir),
182
194
  )
@@ -189,9 +201,11 @@ def _call_ingest_files(args: argparse.Namespace) -> bool:
189
201
 
190
202
  def _call_ingest_xmlupload(args: argparse.Namespace) -> bool:
191
203
  _check_health_with_docker(args.server)
204
+ xml_path = Path(args.xml_file)
205
+ _check_filepath_exists(xml_path)
192
206
  interrupt_after = args.interrupt_after if args.interrupt_after > 0 else None
193
207
  return ingest_xmlupload(
194
- xml_file=Path(args.xml_file),
208
+ xml_file=xml_path,
195
209
  creds=_get_creds(args),
196
210
  interrupt_after=interrupt_after,
197
211
  skip_validation=args.skip_validation,
@@ -202,8 +216,13 @@ def _call_ingest_xmlupload(args: argparse.Namespace) -> bool:
202
216
 
203
217
  def _call_xmlupload(args: argparse.Namespace) -> bool:
204
218
  _check_health_with_docker(args.server)
219
+ xml_path = Path(args.xmlfile)
220
+ _check_filepath_exists(xml_path)
221
+ id_2_iri_file = args.id2iri_replacement_with_file
222
+ if id_2_iri_file:
223
+ _check_filepath_exists(Path(id_2_iri_file))
205
224
  if args.validate_only:
206
- success = parse_and_validate_xml_file(Path(args.xmlfile))
225
+ success = parse_and_validate_xml_file(xml_path)
207
226
  print("The XML file is syntactically correct.")
208
227
  return success
209
228
  else:
@@ -221,7 +240,7 @@ def _call_xmlupload(args: argparse.Namespace) -> bool:
221
240
  f"is not part of the allowed values: info, warning, error."
222
241
  )
223
242
  return xmlupload(
224
- input_file=Path(args.xmlfile),
243
+ input_file=xml_path,
225
244
  creds=_get_creds(args),
226
245
  imgdir=args.imgdir,
227
246
  config=UploadConfig(
@@ -231,15 +250,17 @@ def _call_xmlupload(args: argparse.Namespace) -> bool:
231
250
  ignore_duplicate_files_warning=args.ignore_duplicate_files_warning,
232
251
  validation_severity=severity,
233
252
  skip_ontology_validation=args.skip_ontology_validation,
234
- id2iri_replacement_file=args.id2iri_replacement_with_file,
253
+ id2iri_replacement_file=id_2_iri_file,
235
254
  ),
236
255
  )
237
256
 
238
257
 
239
258
  def _call_validate_data(args: argparse.Namespace) -> bool:
240
259
  _check_health_with_docker(args.server)
260
+ xml_path = Path(args.xmlfile)
261
+ _check_filepath_exists(xml_path)
241
262
  return validate_data(
242
- filepath=Path(args.xmlfile),
263
+ filepath=xml_path,
243
264
  creds=_get_creds(args),
244
265
  save_graphs=args.save_graphs,
245
266
  ignore_duplicate_files_warning=args.ignore_duplicate_files_warning,
@@ -259,6 +280,7 @@ def _call_resume_xmlupload(args: argparse.Namespace) -> bool:
259
280
 
260
281
  def _call_get(args: argparse.Namespace) -> bool:
261
282
  _check_health_with_docker_on_localhost(args.server)
283
+ _check_directory_exists(Path(args.project_definition).parent)
262
284
  return get_project(
263
285
  project_identifier=args.project,
264
286
  outfile_path=args.project_definition,
@@ -269,6 +291,7 @@ def _call_get(args: argparse.Namespace) -> bool:
269
291
 
270
292
  def _call_create(args: argparse.Namespace) -> bool:
271
293
  _check_health_with_docker_on_localhost(args.server)
294
+ _check_filepath_exists(Path(args.project_definition))
272
295
  success = False
273
296
  match args.lists_only, args.validate_only:
274
297
  case True, True:
@@ -340,3 +363,13 @@ def _check_api_health(api_url: str) -> None:
340
363
  msg = "The DSP-API responded with a request exception. Please contact the DaSCH engineering team for help."
341
364
  logger.error(msg)
342
365
  raise DspApiNotReachableError(msg) from None
366
+
367
+
368
+ def _check_filepath_exists(file_path: Path) -> None:
369
+ if not file_path.exists():
370
+ raise UserFilepathNotFoundError(file_path)
371
+
372
+
373
+ def _check_directory_exists(dir_path: Path) -> None:
374
+ if not dir_path.is_dir():
375
+ raise UserDirectoryNotFoundError(dir_path)
@@ -77,6 +77,14 @@ class UserFilepathNotFoundError(InputError):
77
77
  super().__init__(msg)
78
78
 
79
79
 
80
+ class UserDirectoryNotFoundError(InputError):
81
+ """This error is raised if a directory from the user does not exist."""
82
+
83
+ def __init__(self, directory: str | Path) -> None:
84
+ msg = f"The provided directory does not exist: {directory}"
85
+ super().__init__(msg)
86
+
87
+
80
88
  class JSONFileParsingError(InputError):
81
89
  """This error should be raised if the user provided input file cannot be parsed."""
82
90
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: dsp-tools
3
- Version: 17.0.0.post25
3
+ Version: 17.0.0.post26
4
4
  Summary: DSP-TOOLS is a Python package with a command line interface that helps you interact with a DaSCH service platform (DSP) server.
5
5
  Author: DaSCH - Swiss National Data and Service Center for the Humanities
6
6
  Author-email: DaSCH - Swiss National Data and Service Center for the Humanities <info@dasch.swiss>
@@ -1,7 +1,7 @@
1
1
  dsp_tools/__init__.py,sha256=XdzLhY_8FUFmPtUEawAvEA8apQ_jlgspb2HpmNjlDV8,158
2
2
  dsp_tools/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  dsp_tools/cli/args.py,sha256=tS16NvgIMdQuaDWb0cNC8TIK7wY-i4pQe7NFYrzt5Bo,694
4
- dsp_tools/cli/call_action.py,sha256=i0VS1qkokvxtcxKj_4V0QWe49sLMZxa8eEqMnl2yr9E,12556
4
+ dsp_tools/cli/call_action.py,sha256=2yBnZqNPWy0swC-YTA_CvhPOMh0cKBUHgQXPFGfDpvU,13826
5
5
  dsp_tools/cli/create_parsers.py,sha256=zi0E7AHV25B_wXt_8Jcan0Tc6y7aG0vipS5rya5gP9s,17764
6
6
  dsp_tools/cli/entry_point.py,sha256=gdexHqVDAy8_Atf0oUxvPVQyDGWUSUhio396U5Oc0RI,10331
7
7
  dsp_tools/clients/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -186,7 +186,7 @@ dsp_tools/config/logger_config.py,sha256=Bw2Gu5F2d8un_KNk0hvNtV7fvN2TlThqo6gSwqe
186
186
  dsp_tools/config/warnings_config.py,sha256=15_Lt227HLqhdn6v-zJbi1KG9Fo6Zi1_4fp_a-iY72w,1142
187
187
  dsp_tools/error/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
188
188
  dsp_tools/error/custom_warnings.py,sha256=7C2DscIz9k7IfM8uebIsKWPcWcSjwpDqbIRDaPw7bI8,1053
189
- dsp_tools/error/exceptions.py,sha256=giLM6Hx17lMdCjNdlwMr4zqdGcqUHypAxESSAtkvvnU,4853
189
+ dsp_tools/error/exceptions.py,sha256=jaKZE1aDWavHPIjYxc_upK9_tcPPEpaCd7PaIPuazNQ,5131
190
190
  dsp_tools/error/problems.py,sha256=DotzVg3MYvMJmernd9tTBmDHoT1MOkHdiWVv8iMoFSk,265
191
191
  dsp_tools/error/xmllib_errors.py,sha256=DpYCsBIx_GmsBAUlfk2VMqtzD5IGMRbd2yXTcrJFHR4,549
192
192
  dsp_tools/error/xmllib_warnings.py,sha256=sS9jJXGJtQqCiJ9P2zCM5gpIhTpChbujQz_fPvxLm8g,1557
@@ -260,7 +260,7 @@ dsp_tools/xmllib/models/res.py,sha256=c3edvilYZVDmv2O6Z36sSkHXcuKPAJLfWVpStDTMuJ
260
260
  dsp_tools/xmllib/models/root.py,sha256=x8_vrDSJ1pZUJUL8LR460dZe4Cg57G_Hy-Zfr2S29dw,13562
261
261
  dsp_tools/xmllib/value_checkers.py,sha256=Yx3r6_WoZ5Lev8Orp8yDzd03JvP2GBmFNSFT2dzrycM,10712
262
262
  dsp_tools/xmllib/value_converters.py,sha256=WMYS5hd1VlrLLBXnf6pv9yYoPBsv_2MxOO6xv-QsRW4,29218
263
- dsp_tools-17.0.0.post25.dist-info/WHEEL,sha256=M6du7VZflc4UPsGphmOXHANdgk8zessdJG0DBUuoA-U,78
264
- dsp_tools-17.0.0.post25.dist-info/entry_points.txt,sha256=qjRfEbkeAwLU_AE2Q-l4Y9irPNmu4Wna-3bfRp1bqV4,62
265
- dsp_tools-17.0.0.post25.dist-info/METADATA,sha256=5P4ptenAkzZ86S1o7Uza-FbGFjpMl1nJQScnoipR_1s,4285
266
- dsp_tools-17.0.0.post25.dist-info/RECORD,,
263
+ dsp_tools-17.0.0.post26.dist-info/WHEEL,sha256=M6du7VZflc4UPsGphmOXHANdgk8zessdJG0DBUuoA-U,78
264
+ dsp_tools-17.0.0.post26.dist-info/entry_points.txt,sha256=qjRfEbkeAwLU_AE2Q-l4Y9irPNmu4Wna-3bfRp1bqV4,62
265
+ dsp_tools-17.0.0.post26.dist-info/METADATA,sha256=MVoGCBmqa_mR3gpWNETKJMEoBPX8YmBK0wOG_hr-UQs,4285
266
+ dsp_tools-17.0.0.post26.dist-info/RECORD,,