Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:58

0001 #!/usr/bin/env python3
0002 #  This compares the content of two Python files,
0003 #  ignoring trivial differences like order within
0004 #  dictionaries or escape characters
0005 
0006 import sys
0007 from argparse import ArgumentParser
0008 
0009 parser = ArgumentParser()
0010 parser.add_argument("file1",type=str)
0011 parser.add_argument("file2",type=str)
0012 options = parser.parse_args()
0013 
0014 cfg1 = eval(file(options.file1).read())
0015 cfg2 = eval(file(options.file2).read())
0016 if cfg1 != cfg2:
0017     print(options.file1, " and ", options.file2, " do not match")
0018     k1 = set(cfg1.keys())
0019     k2 = set(cfg2.keys()) 
0020     if k1-k2 :
0021       print("Different keys " , k1-k2) 
0022     else: 
0023       print("Keys match ")
0024       for key in k1:
0025         # skip schedule, because it could get parentheses
0026         if cfg1[key] != cfg2[key]: 
0027           # skip schedule, because it could get parentheses
0028           if key == "schedule":
0029             exit(0)
0030           else:
0031             print("The value of key ", key , " does not match")
0032 
0033     sys.exit(-1)
0034 print("matched")