source: CMIP6dreqbuild/trunk/src/framework/compare.py @ 1187

Subversion URL: http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreqbuild/trunk/src/framework/compare.py@1207
Revision 1187, 2.5 KB checked in by mjuckes, 2 years ago (diff)

01.00.23

Line 
1
2from dreqPy import dreq
3import os
4import urllib2
5
6refVersion = '01.00.22'
7mode = "file"
8if mode == "http":
9  ref = 'http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreq/tags/%s/dreqPy/docs/dreq.xml' % refVersion
10  refi = 'http://proj.badc.rl.ac.uk/svn/exarch/CMIP6dreq/tags/%s/dreqPy/docs/dreq2Defn.xml' % refVersion
11  reqi = urllib2.Request(refi)
12  response = urllib2.urlopen(reqi)
13  the_pagei = response.read()
14
15  req = urllib2.Request(ref)
16  response = urllib2.urlopen(req)
17  the_page = response.read()
18  strings = True
19
20else:
21  strings = False
22  the_page = '/data/svn/exarch/CMIP6dreq/tags/%s/dreqPy/docs/dreq.xml' % refVersion
23  the_pagei = '/data/svn/exarch/CMIP6dreq/tags/%s/dreqPy/docs/dreq2Defn.xml' % refVersion
24
25
26print the_page
27print the_pagei
28dq = dreq.loadDreq( dreqXML=the_page, configdoc=the_pagei, strings=strings, manifest=None )
29print "Current"
30dqc = dreq.loadDreq()
31
32print 'Comparing version %s with current' % refVersion
33
34s0 = set( dqc.coll.keys() )
35s1 = set( dq.coll.keys() )
36if len( s1.difference( s0 ) ) > 0:
37  print 'Sections omitted in current: %s' % str( s1.difference( s0 ) )
38else:
39  print 'No sections removed'
40if len( s0.difference( s1 ) ) > 0:
41  print 'Sections new in current: %s' % str( s0.difference( s1 ) )
42else:
43  print 'No sections added'
44
45ss = s0.intersection( s1 )
46for s in sorted( list(ss) ):
47  lchange = len( dqc.coll[s].items ) - len( dq.coll[s].items )
48  new = {i.uid for i in dqc.coll[s].items if i.uid not in dq.inx.uid}
49  dlab = set()
50  dtd = set()
51  dother = set()
52  for i in dqc.coll[s].items:
53    if i.uid in dq.inx.uid:
54      i1 = dq.inx.uid[i.uid]
55      if i.label != i1.label:
56        dlab.add( i.uid )
57      if i.title != i1.title or ('description' in i.__dict__ and i.description != i1.description):
58        dtd.add( i.uid )
59      for k in i._a.keys():
60         if i.__dict__.get(k,None) != i1.__dict__.get(k,None):
61           dother.add( i.uid )
62     
63  lnew = len( list( new ) )
64  ldlab = len( list( dlab ) )
65  ltd = len( list( dtd ) )
66  lother = len( list( dother ) )
67  print 'Section %16s: changes:: length %4s; records %4s; label %4s; t/d %4s; other %4s' % (s,lchange,lnew,ldlab,ltd,lother)
68  ##if len( dq.coll[s].items ) == len( dqc.coll[s].items ):
69    ##print "Section %s: length unchanged -- %s" % (s,len( dqc.coll[s].items ) )
70  ##elif len( dq.coll[s].items ) < len( dqc.coll[s].items ):
71    ##print "Section %s: expanded %s to %s" % (s,len( dq.coll[s].items ), len( dqc.coll[s].items ))
72  ##else:
73    ##print "Section %s: shrunk %s to %s" % (s,len( dq.coll[s].items ), len( dqc.coll[s].items ))
74
75
76
77
Note: See TracBrowser for help on using the repository browser.