CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
diffProv.py
Go to the documentation of this file.
1 
2 class difference :
3 
4  def __init__(self,v):
5  self.verbose = v
6  self._diffprocess=[]
7  self._sameprocess=()
8  def list_diff(self,aList1, aList2, string1, string2):
9  "Searches for differences between two modules of the same kind"
10  differences=[]
11  for i in range(2,len(aList1)):
12  for j in range(2,len(aList2)):
13  if (i==j) and (aList1[i]!=aList2[j]):
14  if aList1[i][:(aList1[i].index('=')+1)] == aList2[j][:(aList2[j].index('=')+1)]:
15  if self.verbose==str(2) or self.verbose==str(1):
16  str1 = aList1[i][2:aList1[i].index('=')+1] + aList1[i][aList1[i].index('=')+1:]+' ['+ string1+']'
17  str2 = len(aList1[i][2:aList1[i].index('=')+1])*' '+aList2[j][aList2[j].index('=')+1:]+' ['+string2+']'
18  print str1,'\n',str2,'\n'
19  differences.append(str1)
20  differences.append(str2)
21 
22  return differences
23 
24  def module_diff(self,module1,module2, string1, string2):
25  "Searches for modules which are in both the files but whose parameters are setted at different values"
26  print '\nList of modules present in both the files with different parameter values\n'
27  for i in module1.keys():
28  for j in module2.keys():
29  if (i==j) and (i=='Processing'):
30  list= module1[i]
31  for k in range(len(list)):
32  process1=module1[i][k].split()
33  process2=module2[i][k].split()
34  if process1[0]!= process2[0]:
35  key1=process1[0]
36  key2=process2[0]
37  self._diffprocess.append( (key1,key2) )
38 
39  if len(self._diffprocess)>1:
40  print 'Differences in the processing history'
41  for l,m in self._diffprocess:
42  print l+' ['+string1+']'
43  print m+' ['+string2+']'
44  print ''
45  if len(self._diffprocess)==1:
46  self._sameprocess=self._diffprocess[0]
47 
48  elif ( (i==j)or (i,j)==self._sameprocess ) and (i!='Processing'):
49  for name1,value1 in module1[i]:
50  for name2,value2 in module2[j]:
51  if (name1==name2) and (value1[1:]!=value2[1:]):
52  print 'Process: '+'"'+i+'"'+'\n'+'Module: '+'"'+name1+'"'+'\n'
53  d=difference(self.verbose)
54  d.firstvalue=value1
55  d.secondvalue=value2
56  self.list_diff(d.firstvalue,d.secondvalue, string1, string2)
57 
58  self.onefilemodules(module1,module2,'first')
59  self.onefilemodules(module2,module1,'second')
60 
61 
62  def onefilemodules(self,module1,module2,string):
63  "Searches for modules present only in one of the two files"
64  print '\nModules run only on the '+string+ ' edmfile:'+'\n'
65  for i in module1.keys():
66  labelList=[]
67  if (i not in module2.keys())and (i not in self._sameprocess):
68  print '\n Process '+i+' not run on edmfile '+string +'\n'
69  elif i!='Processing':
70  k=i
71  if i in self._sameprocess:
72  if i==self._sameprocess[0]:
73  k= self._sameprocess[1]
74  elif i==self._sameprocess[1]:
75  k= self._sameprocess[0]
76  labelList2=[module[0] for module in module2[k]]
77  labelList1=[module[0] for module in module1[i]]
78  for name, value in module1[i] :
79  if (name not in labelList2):
80  print 'Process: '+'"'+i+'"'+'\n'+'Module: '+'"'+name+'"'
81  if self.verbose==str(2):
82  for k in value[1:]:
83  print k
84 
85 
86 
double split
Definition: MVATrainer.cc:139