8 parser = argparse.ArgumentParser(description=
'Get the inputs for activating only the prescale of a given group')
10 parser.add_argument(
'-g',
'--group',
13 help=
'Which group we are selecting')
14 parser.add_argument(
'-p',
'--prescale_json',
16 help=
'Which prescale json we are modifying')
17 parser.add_argument(
'-m',
'--menu_json',
19 help=
'Name of the menu file')
21 args = parser.parse_args()
22 the_groups = args.group
24 prescale_json = args.prescale_json
25 prescale_file =
open(prescale_json)
26 the_prescale = json.load(prescale_file)
29 menu_json = args.menu_json
30 menu_file =
open(menu_json)
31 the_menu = json.load(menu_file)
34 list_of_good_chains = []
35 for chain
in the_menu[
'chains']:
36 for group
in the_groups:
37 if group
in the_menu[
'chains'][chain][
'groups']:
38 list_of_good_chains.append(chain)
40 if len(list_of_good_chains)==0:
41 raise Exception(
"There are no chains with the specified group in the Menu file.")
43 print(
"[modify_prescale_json] resetting all the chains that do not contain the groups:", the_groups)
44 print(
"[modify_prescale_json] number of chains found with the selected groups:", len(list_of_good_chains))
46 for chain
in the_prescale[
'prescales']:
47 if chain
not in list_of_good_chains:
48 the_prescale[
'prescales'][chain][
'prescale'] = 0
49 the_prescale[
'prescales'][chain][
'enabled'] =
False
51 print(
"[modify_prescale_json] overwriting the prescale json file:", prescale_json)
52 with open( prescale_json,
'w' )
as fp:
53 json.dump( the_prescale, fp, indent=4, sort_keys=
False )