Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:52

0001 
0002 from builtins import range
0003 class difference :
0004     
0005     def __init__(self,v):
0006         self.verbose = int(v)
0007         self._diffprocess=[]
0008         self._sameprocess=()
0009     def list_diff(self,aList1, aList2, string1, string2):
0010         "Searches for differences between two modules of the same kind"
0011         differences=[]
0012         for i in range(2,len(aList1)):
0013             for j in range(2,len(aList2)):
0014                 if (i==j) and (aList1[i]!=aList2[j]):
0015                     if aList1[i][:(aList1[i].index('=')+1)] == aList2[j][:(aList2[j].index('=')+1)]:
0016                         if self.verbose==2 or self.verbose==1:
0017                             str1 = aList1[i][2:aList1[i].index('=')+1] + aList1[i][aList1[i].index('=')+1:]+'  ['+ string1+']'
0018                             str2 = len(aList1[i][2:aList1[i].index('=')+1])*' '+aList2[j][aList2[j].index('=')+1:]+'  ['+string2+']'
0019                             print(str1,'\n',str2,'\n')
0020                             differences.append(str1)
0021                             differences.append(str2)
0022                    
0023         return differences 
0024                                                     
0025     def module_diff(self,module1,module2, string1, string2):
0026         "Searches for modules which are in both the files but whose parameters are setted at different values"
0027         print('\nList of modules present in both the files with different parameter values\n')
0028         for i in module1.keys():
0029             for j in module2.keys():
0030                 if (i==j) and (i=='Processing'):
0031                     list= module1[i]
0032                     for k in range(len(list)):
0033                         process1=module1[i][k].split()
0034                         process2=module2[i][k].split()
0035                         if process1[0]!= process2[0]:
0036                             key1=process1[0]
0037                             key2=process2[0]
0038                             self._diffprocess.append( (key1,key2) )
0039                             
0040                     if len(self._diffprocess)>1:
0041                         print('Differences in the processing history')
0042                         for l,m in self._diffprocess:         
0043                             print(l+'  ['+string1+']')
0044                             print(m+'  ['+string2+']')
0045                             print('')
0046                     if len(self._diffprocess)==1:
0047                         self._sameprocess=self._diffprocess[0]
0048                                                              
0049                 elif ( (i==j)or (i,j)==self._sameprocess ) and (i!='Processing'):
0050                     for name1,value1 in module1[i]:
0051                         for name2,value2 in module2[j]:
0052                             if  (name1==name2) and (value1[1:]!=value2[1:]):
0053                                 print('Process: '+'"'+i+'"'+'\n'+'Module: '+'"'+name1+'"'+'\n')
0054                                 d=difference(self.verbose) 
0055                                 d.firstvalue=value1
0056                                 d.secondvalue=value2
0057                                 self.list_diff(d.firstvalue,d.secondvalue, string1, string2)
0058                     
0059         self.onefilemodules(module1,module2,'first')
0060         self.onefilemodules(module2,module1,'second')
0061     
0062 
0063     def onefilemodules(self,module1,module2,string):
0064         "Searches for modules present only in one of the two files"
0065         print('\nModules run only on the '+string+ ' edmfile:'+'\n')
0066         for i in module1.keys():
0067             labelList=[]
0068             if (i not in module2.keys())and (i not in self._sameprocess):
0069                 print('\n Process '+i+' not run on edmfile '+string +'\n')
0070             elif i!='Processing':
0071                 k=i
0072                 if i in self._sameprocess:
0073                     if i==self._sameprocess[0]:
0074                         k= self._sameprocess[1]
0075                     elif i==self._sameprocess[1]:
0076                         k= self._sameprocess[0]
0077                 labelList2=[module[0] for module in module2[k]]
0078                 labelList1=[module[0] for module in module1[i]]
0079                 for name, value in module1[i] :
0080                     if (name not in labelList2):
0081                         print('Process: '+'"'+i+'"'+'\n'+'Module: '+'"'+name+'"')
0082                         if  self.verbose==2:
0083                             for k in value[1:]:
0084                                 print(k)
0085                                 
0086 
0087