Skip to content

Commit c8c0071

Browse files
excluded reading _corrected and _cve files
1 parent bfa3d8e commit c8c0071

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/diffpy/labpdfproc/tests/conftest.py

+8
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ def user_filesystem(tmp_path):
2424
f.write(unreadable_data)
2525
with open(base_dir / "binary.pkl", "wb") as f:
2626
f.write(binary_data)
27+
with open(base_dir / "data_corrected.chi", "w") as f:
28+
pass
29+
with open(base_dir / "data_cve.chi", "w") as f:
30+
pass
2731

2832
with open(input_dir / "good_data.chi", "w") as f:
2933
f.write(chi_data)
@@ -35,6 +39,10 @@ def user_filesystem(tmp_path):
3539
f.write(unreadable_data)
3640
with open(input_dir / "binary.pkl", "wb") as f:
3741
f.write(binary_data)
42+
with open(input_dir / "data_corrected.chi", "w") as f:
43+
pass
44+
with open(input_dir / "data_cve.chi", "w") as f:
45+
pass
3846

3947
with open(input_dir / "file_list.txt", "w") as f:
4048
f.write("good_data.chi \n good_data.xy \n good_data.txt \n missing_file.txt")

src/diffpy/labpdfproc/tools.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
WAVELENGTHS = {"Mo": 0.71, "Ag": 0.59, "Cu": 1.54}
44
known_sources = [key for key in WAVELENGTHS.keys()]
5+
EXCLUSION_KEYWORDS = ["file_list", "_corrected", "_cve"]
56

67

78
def set_output_directory(args):
@@ -50,7 +51,11 @@ def _expand_user_input(args):
5051
args.input.remove(file_list_input)
5152
wildcard_inputs = [input_name for input_name in args.input if "*" in input_name]
5253
for wildcard_input in wildcard_inputs:
53-
input_files = [str(file) for file in Path(".").glob(wildcard_input) if "file_list" not in file.name]
54+
input_files = [
55+
str(file)
56+
for file in Path(".").glob(wildcard_input)
57+
if not any(keyword in file.name for keyword in EXCLUSION_KEYWORDS)
58+
]
5459
args.input.extend(input_files)
5560
args.input.remove(wildcard_input)
5661
return args
@@ -84,7 +89,9 @@ def set_input_lists(args):
8489
elif input_path.is_dir():
8590
input_files = input_path.glob("*")
8691
input_files = [
87-
file.resolve() for file in input_files if file.is_file() and "file_list" not in file.name
92+
file.resolve()
93+
for file in input_files
94+
if file.is_file() and not any(keyword in file.name for keyword in EXCLUSION_KEYWORDS)
8895
]
8996
input_paths.extend(input_files)
9097
else:

0 commit comments

Comments
 (0)