410 """loads config file into a dictionary, supports several modifications of the input switched on via additional arguments
411 Supports reading: Pickled file with the CA or properties & JSON
414 print(
"Debugging info from reading ", fname,
" in ", logger.handlers[0].baseFilename)
415 logger.setLevel(logging.DEBUG)
418 if fname.endswith(
".pkl"):
419 with open(fname,
"rb")
as input_file:
421 cfg = pickle.load(input_file)
422 logger.info(
"... Read %s from %s", cfg.__class__.__name__, fname)
423 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
424 if isinstance(cfg, ComponentAccumulator):
425 props = cfg.gatherProps()
429 for comp, name, value
in jos_props:
430 to_json.setdefault(comp, {})[name] = value
431 to_json[comp][name] = value
433 conf[
'ApplicationMgr'] = props[0]
434 conf[
'MessageSvc'] = props[1]
437 cfg, (collections.defaultdict, dict)
440 conf.update(pickle.load(input_file))
442 elif isinstance(cfg, (collections.Sequence)):
445 logger.info(
"... Read %d items from python pickle file: %s", len(conf), fname)
447 elif fname.endswith(
".json"):
449 def __keepPlainStrings(element):
450 if isinstance(element, str):
452 if isinstance(element, list):
453 return [__keepPlainStrings(x)
for x
in element]
454 if isinstance(element, dict):
456 __keepPlainStrings(key): __keepPlainStrings(value)
457 for key, value
in element.items()
461 with open(fname,
"r")
as input_file:
462 cfg = json.load(input_file, object_hook=__keepPlainStrings)
471 if 'properties' in conf:
472 conf = conf[
'properties']
474 logger.info(
"... Read %d items from json file: %s", len(conf), fname)
477 sys.exit(
"File format not supported.")
480 sys.exit(
"Unable to load %s file" % fname)
482 if args.includeComps
or args.excludeComps
or args.includeClasses
or args.excludeClasses:
483 logger.info(f
"include/exclude comps like {args.includeComps}/{args.excludeComps}")
486 if args.ignoreIrrelevant:
489 if args.renameComps
or args.renameCompsFile:
492 if args.ignoreDefaults:
496 if args.shortenDefaultComponents:
499 if args.skipProperties: