CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
diff_provenance.py
Go to the documentation of this file.
1 class difference :
2 
3  def __init__(self,v):
4  self.verbose = v
5 
6  def list_diff(self,aList1, aList2, string1, string2):
7  "Searches for differences between two modules of the same kind"
8  for i in range(2,len(aList1)):
9  for j in range(2,len(aList2)):
10  if (i==j) and (aList1[i]!=aList2[j]):
11  if aList1[i][:(aList1[i].index('=')+1)] == aList2[j][:(aList2[j].index('=')+1)]:
12  if self.verbose==str(2) or self.verbose==str(1):
13  print aList1[i][2:aList1[i].index('=')+1] + aList1[i][aList1[i].index('=')+1:]+' ['+ string1+']'
14  print len(aList1[i][2:aList1[i].index('=')+1])*' '+aList2[j][aList2[j].index('=')+1:]+' ['+string2+']'
15  print ''
16 
17 
18  def module_diff(self,module1,module2, string1, string2):
19  "Searches for modules which are in both the files but whose parameters are setted at different values"
20  modulesfile1=[]
21  modulesfile2=[]
22  print '\nList of modules present in both the files with different parameter values\n'
23  for i in module1.keys():
24  for j in module2.keys():
25  if (i==j) and (module1[i]!=module2[j]):
26  print 'Module: '+'"'+i+'"'
27  d=difference(self.verbose)
28  d.module=i
29  d.firstvalue=module1[i]
30  d.secondvalue=module2[j]
31  self.list_diff(d.firstvalue,d.secondvalue, string1, string2)
32  else: pass
33 
34  self.onefilemodules(module1,module2,'first')
35  self.onefilemodules(module2,module1,'second')
36 
37 
38  def onefilemodules(self,module1,module2,string):
39  "Searches for modules present only in one of the two files"
40  onlyonefile=False
41  for i in module1.keys():
42  if not module2.has_key(i):
43  if not onlyonefile:
44  print '\nModule present only in the '+string+ ' file:'+'\n'
45  onlyonefile = True
46  print 'Module: '+'"'+i+'"'
47  if self.verbose==str(2):
48  for k in range(1,len(module1[i])):
49  print module1[i][k]
50 
51