Back to home page

Project CMSSW displayed by LXR

 
 

    


Warning, /FWCore/Reflection/scripts/edmDumpClassVersion is written in an unsupported language. File is not indexed.

0001 #!/usr/bin/env python3
0002 
0003 import sys
0004 import json
0005 import argparse
0006 
0007 import FWCore.Reflection.ClassesDefXmlUtils as ClassesDefUtils
0008 
0009 def main(args):
0010     ClassesDefUtils.initROOT(args.library)
0011     
0012     ClassesDefUtils.initCheckClass()
0013     try:
0014         p = ClassesDefUtils.XmlParser(args.xmlfile, includeNonVersionedClasses=True, normalizeClassNames=False)
0015     except RuntimeError as e:
0016         print(f"Parsing {args.xmlfile} failed: {e}")
0017         sys.exit(1)
0018 
0019     out = {}
0020     for name, info in p.classes.items():
0021         try:
0022             (error, version, checksum) = ClassesDefUtils.checkClass(name, 0, {})
0023         except RuntimeError as e:
0024             print(f"Ignoring class {name} as could not get its version and checksum, because: {e}")
0025             continue
0026         out[name] = dict(
0027             version = version,
0028             checksum = checksum
0029         )
0030     out_js = json.dumps(out, sort_keys=True, indent=1)
0031     if args.output is None:
0032         print(out_js)
0033     else:
0034         with open(args.output, "w") as f:
0035             f.write(out_js)
0036     return 0
0037 
0038 if __name__ == "__main__":
0039     parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
0040                                      description="Extracts class versions and checksums, in JSON format, for all non-transient clases defined in a given classes_def.xml file")
0041     parser.add_argument("-l","--lib", dest="library", type=str,
0042                          help="specify the library to load. If not set classes are found using the PluginManager")
0043     parser.add_argument("-x","--xml_file", dest="xmlfile",default="./classes_def.xml", type=str,
0044                          help="the classes_def.xml file to read")
0045     parser.add_argument("-o", "--output", type=str, default=None,
0046                         help="File to save the output. If no file is specified, the JSON document is printed in stdout")
0047 
0048     args = parser.parse_args()
0049     sys.exit(main(args))