SND@LHC Software
Loading...
Searching...
No Matches
config_tester.py
Go to the documentation of this file.
1#!/usr/bin/env python
2from __future__ import print_function
3import os
4import json
5from ShipGeoConfig import ConfigRegistry
6import logging
7import argparse
8
9logging.info("")
10logger = logging.getLogger()
11logger.setLevel(logging.INFO)
12
13
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
29def 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
38if __name__ == '__main__':
int main()
Definition main.cc:133