|
5 | 5 | import sys |
6 | 6 | import math |
7 | 7 |
|
| 8 | +# Define str2bool function |
| 9 | +def str2bool(v): |
| 10 | + if isinstance(v, bool): |
| 11 | + return v |
| 12 | + if v.lower() in ('yes', 'true', 't', 'y', '1'): |
| 13 | + return True |
| 14 | + elif v.lower() in ('no', 'false', 'f', 'n', '0'): |
| 15 | + return False |
| 16 | + else: |
| 17 | + raise argparse.ArgumentTypeError('Boolean value expected.') |
| 18 | + |
8 | 19 | parser = argparse.ArgumentParser() |
9 | 20 |
|
10 | 21 | parser.add_argument("--background", help="Background species formula",default='noinput',required=True) |
11 | 22 | parser.add_argument("--yaml_file",help="yaml file",default='noinput',required=True) |
12 | 23 | parser.add_argument("--spec_file",help="Cantera to FDS species name lookup csv file (default is yaml_file.spec) with column headings FORMULA and NAME ",default='noinput') |
13 | | -parser.add_argument("--fds_prop",help="Set to True (default) to use FDS properties when species is in spec_file. ",type=bool,default=True) |
| 24 | +parser.add_argument("--fds_prop", type=str2bool, nargs='?', const=True, default=True, |
| 25 | + help="Set to True (default) to use FDS properties when species is in spec_file.") |
14 | 26 | parser.add_argument("--radcal",help="Set to True (default) to use the RADCAL ID in the spec_file. ",type=bool,default=True) |
15 | 27 | parser.add_argument("--mf0_file",help="csv file containing MASS_FRACTION_0 with column headings FORMULA and MF0",default='noinput') |
16 | 28 | args = parser.parse_args() |
|
0 commit comments