Skip to content

Commit 2610b60

Browse files
authored
Merge pull request #404 from FAIRmat-NFDI/fix_clickopt_configfile_default
2 parents 2d678b5 + 5fd863a commit 2610b60

File tree

2 files changed

+19
-33
lines changed

2 files changed

+19
-33
lines changed

src/pynxtools/dataconverter/README.md

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,6 @@ user@box:~$ pip install pynxtools[convert]
2020
```console
2121
Usage: dataconverter [OPTIONS] COMMAND [ARGS]...
2222

23-
Options:
24-
--help Show this message and exit.
25-
--input-file TEXT Deprecated: Please use the positional file
26-
arguments instead. The path to the input
27-
data file to read. (Repeat for more than one
28-
file.)
29-
--reader [example|json_map|json_yml]
30-
The reader to use. default="example"
31-
--nxdl TEXT The name of the NXDL file to use without
32-
extension.This option is required if no '--
33-
params-file' is supplied.
34-
--output TEXT The path to the output NeXus file to be
35-
generated.
36-
--params-file FILENAME Allows to pass a .yaml file with all the
37-
parameters the converter supports.
38-
--ignore-undocumented Ignore all undocumented fields during
39-
validation.
40-
--fail Fail conversion and don't create an output
41-
file if the validation fails.
42-
--skip-verify Skips the verification routine during
43-
conversion.
44-
--mapping TEXT Takes a <name>.mapping.json file and
45-
converts data from given input files.
46-
4723
Commands:
4824
convert* This command allows you to use the converter...
4925
generate-template Generates and prints a template to use for your nxdl.

src/pynxtools/dataconverter/convert.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ def convert(
225225
-------
226226
None.
227227
"""
228-
229228
nxdl_root, nxdl_f_path = helpers.get_nxdl_root_and_path(nxdl)
230229

231230
data = transfer_data_into_template(
@@ -288,28 +287,32 @@ def main_cli():
288287
default=[],
289288
multiple=True,
290289
help=(
291-
"Deprecated: Please use the positional file arguments instead. "
292-
"The path to the input data file to read. (Repeat for more than one file.)"
290+
"Deprecated: Please use the positional file arguments instead. The path to the "
291+
"input data file to read. Repeat for more than one file. default=[] This option "
292+
"is required if no '--params-file' is supplied."
293293
),
294294
)
295295
@click.option(
296296
"--reader",
297297
default="json_map",
298298
type=click.Choice(get_names_of_all_readers(), case_sensitive=False),
299-
help='The reader to use. default="example"',
299+
help=(
300+
"The reader to use. Examples are json_map or readers from a pynxtools plugin. "
301+
"default='json_map' This option is required if no '--params-file' is supplied."
302+
),
300303
)
301304
@click.option(
302305
"--nxdl",
303306
default=None,
304307
help=(
305-
"The name of the NXDL file to use without extension."
306-
"This option is required if no '--params-file' is supplied."
308+
"The name of the NeXus application definition file to use without the extension "
309+
"nxdl.xml. This option is required if no '--params-file' is supplied."
307310
),
308311
)
309312
@click.option(
310313
"--output",
311314
default="output.nxs",
312-
help="The path to the output NeXus file to be generated.",
315+
help="The path to the output NeXus file to be generated. default='output.nxs'",
313316
)
314317
@click.option(
315318
"--params-file",
@@ -342,7 +345,9 @@ def main_cli():
342345
@click.option(
343346
"-c",
344347
"--config",
348+
"config_file",
345349
type=click.Path(exists=True, dir_okay=False, file_okay=True, readable=True),
350+
default=None,
346351
help="A json config file for the reader",
347352
)
348353
# pylint: disable=too-many-arguments
@@ -356,8 +361,9 @@ def convert_cli(
356361
ignore_undocumented: bool,
357362
skip_verify: bool,
358363
mapping: str,
359-
config: str,
364+
config_file: str,
360365
fail: bool,
366+
**kwargs,
361367
):
362368
"""This command allows you to use the converter functionality of the dataconverter."""
363369
if params_file:
@@ -379,6 +385,10 @@ def convert_cli(
379385
if mapping:
380386
reader = "json_map"
381387
input_file = input_file + tuple([mapping])
388+
# needs own call
389+
390+
if config_file:
391+
kwargs["config_file"] = config_file
382392

383393
file_list = []
384394
for file in files:
@@ -402,9 +412,9 @@ def convert_cli(
402412
nxdl,
403413
output,
404414
skip_verify,
405-
config_file=config,
406415
ignore_undocumented=ignore_undocumented,
407416
fail=fail,
417+
**kwargs,
408418
)
409419
except FileNotFoundError as exc:
410420
raise click.BadParameter(str(exc)) from exc

0 commit comments

Comments
 (0)