409def loadConfigFile(fname, args) -> Dict:
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
412 """
413 if args.debug:
414 print(
"Debugging info from reading ", fname,
" in ", logger.handlers[0].baseFilename)
415 logger.setLevel(logging.DEBUG)
416
417 conf = {}
418 if fname.endswith(".pkl"):
419 with open(fname, "rb") as input_file:
420
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()
426
427 jos_props = props[2]
428 to_json = {}
429 for comp, name, value in jos_props:
430 to_json.setdefault(comp, {})[name] = value
431 to_json[comp][name] = value
432 conf.update(to_json)
433 conf['ApplicationMgr'] = props[0]
434 conf['MessageSvc'] = props[1]
435
436 elif isinstance(
437 cfg, (collections.defaultdict, dict)
438 ):
439 conf.update(cfg)
440 conf.update(pickle.load(input_file))
441
442 elif isinstance(cfg, (collections.Sequence)):
443 for c in cfg:
444 conf.update(c)
445 logger.info("... Read %d items from python pickle file: %s", len(conf), fname)
446
447 elif fname.endswith(".json"):
448
449 def __keepPlainStrings(element):
450 if isinstance(element, str):
451 return str(element)
452 if isinstance(element, list):
453 return [__keepPlainStrings(x) for x in element]
454 if isinstance(element, dict):
455 return {
456 __keepPlainStrings(key): __keepPlainStrings(value)
457 for key, value in element.items()
458 }
459 return element
460
461 with open(fname, "r") as input_file:
462 cfg = json.load(input_file, object_hook=__keepPlainStrings)
463 for c in cfg:
464 conf.update(cfg)
465
466
467
468
469
470
471 if 'properties' in conf:
472 conf = conf['properties']
473
474 logger.info("... Read %d items from json file: %s", len(conf), fname)
475
476 else:
477 sys.exit("File format not supported.")
478
479 if conf is None:
480 sys.exit("Unable to load %s file" % fname)
481
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}")
484 conf = excludeIncludeComps(conf, args, args.follow)
485
486 if args.ignoreIrrelevant:
487 conf = ignoreIrrelevant(conf, args)
488
489 if args.renameComps or args.renameCompsFile:
490 conf = renameComps(conf, args)
491
492 if args.ignoreDefaults:
493 known_types = collect_types(conf)
494 conf = ignoreDefaults(conf, args, known_types)
495
496 if args.shortenDefaultComponents:
497 conf = shortenDefaultComponents(conf, args)
498
499 if args.skipProperties:
500 conf = skipProperties(conf, args)
501 return conf
502
void print(char *figname, TCanvas *c1)