411 """loads config file into a dictionary, supports several modifications of the input switched on via additional arguments
412 Supports reading: Pickled file with the CA or properties & JSON
415 print(
"Debugging info from reading ", fname,
" in ", logger.handlers[0].baseFilename)
416 logger.setLevel(logging.DEBUG)
419 if fname.endswith(
".pkl"):
420 with open(fname,
"rb")
as input_file:
422 cfg = pickle.load(input_file)
423 logger.info(
"... Read %s from %s", cfg.__class__.__name__, fname)
424 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
425 if isinstance(cfg, ComponentAccumulator):
426 props = cfg.gatherProps()
430 for comp, name, value
in jos_props:
431 to_json.setdefault(comp, {})[name] = value
432 to_json[comp][name] = value
434 conf[
'ApplicationMgr'] = props[0]
435 conf[
'MessageSvc'] = props[1]
438 cfg, (collections.defaultdict, dict)
441 conf.update(pickle.load(input_file))
443 elif isinstance(cfg, (collections.Sequence)):
446 logger.info(
"... Read %d items from python pickle file: %s", len(conf), fname)
448 elif fname.endswith(
".json"):
450 def __keepPlainStrings(element):
451 if isinstance(element, str):
453 if isinstance(element, list):
454 return [__keepPlainStrings(x)
for x
in element]
455 if isinstance(element, dict):
457 __keepPlainStrings(key): __keepPlainStrings(value)
458 for key, value
in element.items()
462 with open(fname,
"r")
as input_file:
463 cfg = json.load(input_file, object_hook=__keepPlainStrings)
472 if 'properties' in conf:
473 conf = conf[
'properties']
475 logger.info(
"... Read %d items from json file: %s", len(conf), fname)
478 sys.exit(
"File format not supported.")
481 sys.exit(
"Unable to load %s file" % fname)
483 if args.includeComps
or args.excludeComps
or args.includeClasses
or args.excludeClasses:
484 logger.info(f
"include/exclude comps like {args.includeComps}/{args.excludeComps}")
487 if args.ignoreIrrelevant:
490 if args.renameComps
or args.renameCompsFile:
493 if args.ignoreDefaults:
497 if args.shortenDefaultComponents:
500 if args.skipProperties: