Skip to content

Commit 5b7b1b8

Browse files
committed
changing app inputs to required input directory/file list
1 parent 8fcd034 commit 5b7b1b8

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

src/diffpy/labpdfproc/labpdfprocapp.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,20 @@
1111
def get_args(override_cli_inputs=None):
1212
p = ArgumentParser()
1313
p.add_argument("mud", help="Value of mu*D for your " "sample. Required.", type=float)
14-
p.add_argument("-i", "--input-file", help="The filename of the " "datafile to load.")
14+
p.add_argument(
15+
"input",
16+
nargs="+",
17+
help="The filename(s) or folder(s) of the datafile(s) to load. "
18+
"Required.\nSupply a space-separated list of files or directories."
19+
"Long lists can be supplied, one per line, in a file with name "
20+
"file_list.txt. If one or more directory is provided, all valid "
21+
"data-files in that directory will be processed. Examples of valid "
22+
"inputs are 'file.xy', 'data/file.xy', 'file.xy, data/file.xy', "
23+
"'.' (load everything in the current directory), 'data' (load"
24+
"everything in the folder ./data', 'data/file_list.txt' (load"
25+
" the list of files contained in the text-file called "
26+
"file_list.txt that can be found in the folder ./data).",
27+
)
1528
p.add_argument(
1629
"-a",
1730
"--anode-type",

src/diffpy/labpdfproc/tests/test_tools.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
@pytest.mark.parametrize("inputs, expected", params1)
1818
def test_set_output_directory(inputs, expected, user_filesystem):
1919
expected_output_directory = Path(user_filesystem) / expected[0]
20-
cli_inputs = ["2.5"] + inputs
20+
cli_inputs = ["2.5", "data.xy"] + inputs
2121
actual_args = get_args(cli_inputs)
2222
actual_args.output_directory = set_output_directory(actual_args)
2323
assert actual_args.output_directory == expected_output_directory
@@ -26,7 +26,7 @@ def test_set_output_directory(inputs, expected, user_filesystem):
2626

2727

2828
def test_set_output_directory_bad(user_filesystem):
29-
cli_inputs = ["2.5", "--output-directory", "good_data.chi"]
29+
cli_inputs = ["2.5", "data.xy", "--output-directory", "good_data.chi"]
3030
actual_args = get_args(cli_inputs)
3131
with pytest.raises(FileExistsError):
3232
actual_args.output_directory = set_output_directory(actual_args)
@@ -45,7 +45,7 @@ def test_set_output_directory_bad(user_filesystem):
4545
@pytest.mark.parametrize("inputs, expected", params2)
4646
def test_set_wavelength(inputs, expected):
4747
expected_wavelength = expected[0]
48-
cli_inputs = ["2.5"] + inputs
48+
cli_inputs = ["2.5", "data.xy"] + inputs
4949
actual_args = get_args(cli_inputs)
5050
actual_args.wavelength = set_wavelength(actual_args)
5151
assert actual_args.wavelength == expected_wavelength
@@ -69,7 +69,7 @@ def test_set_wavelength(inputs, expected):
6969

7070
@pytest.mark.parametrize("inputs, msg", params3)
7171
def test_set_wavelength_bad(inputs, msg):
72-
cli_inputs = ["2.5"] + inputs
72+
cli_inputs = ["2.5", "data.xy"] + inputs
7373
actual_args = get_args(cli_inputs)
7474
with pytest.raises(ValueError, match=re.escape(msg[0])):
7575
actual_args.wavelength = set_wavelength(actual_args)
@@ -87,12 +87,12 @@ def test_set_wavelength_bad(inputs, msg):
8787

8888
@pytest.mark.parametrize("inputs, expected", params5)
8989
def test_load_user_metadata(inputs, expected):
90-
expected_args = get_args(["2.5"])
90+
expected_args = get_args(["2.5", "data.xy"])
9191
for expected_pair in expected:
9292
setattr(expected_args, expected_pair[0], expected_pair[1])
9393
delattr(expected_args, "user_metadata")
9494

95-
cli_inputs = ["2.5"] + inputs
95+
cli_inputs = ["2.5", "data.xy"] + inputs
9696
actual_args = get_args(cli_inputs)
9797
actual_args = load_user_metadata(actual_args)
9898
assert actual_args == expected_args
@@ -129,7 +129,7 @@ def test_load_user_metadata(inputs, expected):
129129

130130
@pytest.mark.parametrize("inputs, msg", params6)
131131
def test_load_user_metadata_bad(inputs, msg):
132-
cli_inputs = ["2.5"] + inputs
132+
cli_inputs = ["2.5", "data.xy"] + inputs
133133
actual_args = get_args(cli_inputs)
134134
with pytest.raises(ValueError, match=msg[0]):
135135
actual_args = load_user_metadata(actual_args)

0 commit comments

Comments
 (0)