SND@LHC Software
Loading...
Searching...
No Matches
config_tester.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
from
__future__
import
print_function
3
import
os
4
import
json
5
from
ShipGeoConfig
import
ConfigRegistry
6
import
logging
7
import
argparse
8
9
logging.info(
""
)
10
logger = logging.getLogger()
11
logger.setLevel(logging.INFO)
12
13
14
def
parse_arguments
():
15
ap = argparse.ArgumentParser(
16
description=
'test configuration file'
)
17
ap.add_argument(
'-d'
,
'--debug'
, action=
'store_true'
)
18
ap.add_argument(
'-p'
,
'--params'
, type=json.loads,
19
help=
"""config parameters in json form '{"a": 1, "b": 2}' """
, default=
None
)
20
21
ap.add_argument(
'config_file'
, help=
'config file to test'
)
22
args = ap.parse_args()
23
if
args.debug:
24
logger.setLevel(logging.DEBUG)
25
assert
os.path.exists(args.config_file)
26
return
args
27
28
29
def
main
(arguments):
30
logger.info(
"file: %s"
% arguments.config_file)
31
if
arguments.params
is
not
None
:
32
logger.info(
"paramters: %s"
% arguments.params)
33
ConfigRegistry.loadpy(arguments.config_file, **arguments.params)
34
# ConfigRegistry.loadpy(arguments.config_file, muShieldDesign=2, targetOpt=5)
35
for
k, v
in
ConfigRegistry
().items():
36
print(
"%s: %s"
% (k, v))
37
38
if
__name__ ==
'__main__'
:
39
main
(
parse_arguments
())
ShipGeoConfig.ConfigRegistry
Definition
ShipGeoConfig.py:41
main
int main()
Definition
main.cc:133
config_tester.parse_arguments
parse_arguments()
Definition
config_tester.py:14
geometry
config_tester.py
Generated by
1.9.8