Skip to content

Commit bdd5139

Browse files
initial commit on loading extra pairs into args, tests not written yet, and the pairs are not written into the header of output files for now
1 parent 842ea89 commit bdd5139

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/diffpy/labpdfproc/labpdfprocapp.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from pathlib import Path
44

55
from diffpy.labpdfproc.functions import apply_corr, compute_cve
6+
from diffpy.labpdfproc.tools import load_additional_info
67
from diffpy.utils.parsers.loaddata import loadData
78
from diffpy.utils.scattering_objects.diffraction_objects import XQUANTITIES, Diffraction_object
89

@@ -56,12 +57,21 @@ def get_args():
5657
action="store_true",
5758
help="outputs will not overwrite existing file unless --force is spacified",
5859
)
60+
p.add_argument(
61+
"-add",
62+
"--additional-info",
63+
metavar=("KEY=VALUE"),
64+
action="append",
65+
help="specify key-value pairs to be loaded into metadata. You can specify multiple "
66+
"paris by calling -add multiple times",
67+
)
5968
args = p.parse_args()
6069
return args
6170

6271

6372
def main():
6473
args = get_args()
74+
args = load_additional_info(args)
6575
wavelength = WAVELENGTHS[args.anode_type]
6676
filepath = Path(args.input_file)
6777
outfilestem = filepath.stem + "_corrected"

src/diffpy/labpdfproc/tools.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
def load_additional_info(args):
2+
if args.additional_info:
3+
for item in args.additional_info:
4+
key, value = item.split("=")
5+
setattr(args, key, value)
6+
delattr(args, "additional_info")
7+
return args

0 commit comments

Comments
 (0)