@@ -39,97 +39,82 @@ def isMac():
39
39
Released under a GPLv3+ license.
40
40
""" ,
41
41
)
42
- # TODO: add info about output files to be created ...
43
42
parser .add_argument (
44
43
"-f" ,
45
44
"--dataFile" ,
46
45
type = lambda p : Path (p ).absolute (),
47
- # FIXME: this default does not work for installed package
48
- default = Path (__file__ ).absolute ().parent / "testdata" / "quickstartdemo1.csv" ,
49
- help = "Path to the filename with the SAXS data" ,
50
- # required=True,
46
+ help = """Path to the filename with the SAXS data, an example file can be found at
47
+ 'testdata/quickstartdemo1.csv' of the source distribution.""" ,
51
48
)
52
49
parser .add_argument (
53
50
"-F" ,
54
51
"--readConfigFile" ,
55
52
type = lambda p : Path (p ).absolute (),
56
- default = Path (__file__ ).absolute ().parent
57
- / "example_configurations"
58
- / "read_config_csv.yaml" ,
59
- help = "Path to the config file how to read the input data" ,
60
- # required=True,
53
+ help = """Path to the config file how to read the input data, an example file can be found
54
+ at 'example_configurations/read_config_csv.yaml' of the source distribution.""" ,
61
55
)
56
+ outpathDefault = Path ().absolute () / "output.nxs"
62
57
parser .add_argument (
63
58
"-r" ,
64
59
"--resultFile" ,
65
60
type = lambda p : Path (p ).absolute (),
66
- default = Path ( __file__ ). absolute (). parent / "test.nxs" ,
67
- help = " Path to the file to create and store the McSAS3 result in" ,
68
- # required=True ,
61
+ default = outpathDefault ,
62
+ help = f""" Path to the file to create and store the McSAS3 result in,
63
+ the default is ' { outpathDefault } '.""" ,
69
64
)
70
65
parser .add_argument (
71
66
"-R" ,
72
67
"--runConfigFile" ,
73
68
type = lambda p : Path (p ).absolute (),
74
- default = Path (__file__ ).absolute ().parent
75
- / "example_configurations"
76
- / "run_config_spheres_auto.yaml" ,
77
- help = "Path to the configuration file containing the model parameters" ,
78
- # required=True,
69
+ help = """Path to the configuration file containing the model parameters, an example file can
70
+ be found at 'example_configurations/run_config_spheres_auto.yaml' of the source
71
+ distribution.""" ,
79
72
)
80
73
parser .add_argument (
81
74
"-H" ,
82
75
"--histConfigFile" ,
83
76
type = lambda p : Path (p ).absolute (),
84
- default = Path ("./example_configurations/hist_config_dual.yaml" ),
85
- help = "Path to the filename with the histogramming configuration" ,
86
- # required=True,
77
+ help = """Path to the filename with the histogramming configuration, an example file can be
78
+ found at 'example_configurations/hist_config_dual.yaml' of the source distribution.""" ,
87
79
)
88
80
parser .add_argument (
89
81
"-i" ,
90
82
"--resultIndex" ,
91
83
type = int ,
92
84
default = 1 ,
93
85
help = "The result index to work on, in case you want multiple McSAS runs on the same data" ,
94
- # required=True,
95
86
)
96
87
parser .add_argument (
97
88
"-d" ,
98
89
"--deleteIfExists" ,
99
- # type=bool,
100
- # default=False,
90
+ default = False ,
101
91
action = "store_true" ,
102
- help = (
103
- "Delete the output file if it exists. This will need to be activated if you are"
104
- " overwriting previous optimizations "
105
- ),
106
- # required=True,
92
+ help = """Delete the output file if it exists. This will need to be activated if you are
93
+ overwriting previous optimizations""" ,
107
94
)
108
95
parser .add_argument (
109
96
"-t" ,
110
97
"--nThreads" ,
111
98
type = int ,
112
99
default = 0 ,
113
- help = (
114
- "The number (n>0) of cores/threads used for optimization."
115
- " If omitted, the value from the config file is used (default)."
116
- " Never more threads are used as cores exist."
117
- ),
100
+ help = """The number (n>0) of cores/threads used for optimization. If omitted, the value from
101
+ the config file is used (default). Never more threads are used as cores exist.""" ,
118
102
)
119
103
if isMac ():
120
104
# on OSX remove automatically provided PID,
121
105
# otherwise argparse exits and the bundle start fails silently
122
106
for i in range (len (sys .argv )):
123
107
if sys .argv [i ].startswith ("-psn" ): # PID provided by osx
124
108
del sys .argv [i ]
125
- try :
126
- args = parser .parse_args ()
127
- except SystemExit :
128
- raise
109
+ args = parser .parse_args ()
129
110
# initiate logging (to console stdout for now)
130
111
logging .basicConfig (level = logging .INFO , stream = sys .stdout )
131
112
# replaceStdOutErr() # replace all text output with our sinks
132
113
133
114
adict = vars (args )
134
- m = McSAS3_cli_optimize (** adict )
135
- m = McSAS3_cli_histogram (** adict )
115
+ try :
116
+ m = McSAS3_cli_optimize (** adict )
117
+ m = McSAS3_cli_histogram (** adict )
118
+ except TypeError as e : # for wrong cmdline arguments supplied
119
+ print (f"ERROR: { str (e )} \n " , file = sys .stderr )
120
+ parser .print_help ()
0 commit comments