1 | |
---|
2 | import shelve |
---|
3 | |
---|
4 | odir = 'sh20150708' |
---|
5 | def sopen( id ): |
---|
6 | sh = shelve.open( '%s/%s' % (odir,id ) ) |
---|
7 | print 'Openned %s' % str( sh['__info__'] ) |
---|
8 | print sh['__cols__'] |
---|
9 | return sh |
---|
10 | |
---|
11 | class rqc(object): |
---|
12 | |
---|
13 | def __init__(self): |
---|
14 | self.refti = sopen( 'refTableItems' ) |
---|
15 | self.revti = sopen( 'revTabItems' ) |
---|
16 | self.vars = sopen( 'cmipVars' ) |
---|
17 | self.grps = sopen( 'groupItems' ) |
---|
18 | self.rqit = sopen( 'requestItems' ) |
---|
19 | self.rqli = sopen( 'requestLinks' ) |
---|
20 | self.rqvg = sopen( 'requestVarGroup' ) |
---|
21 | |
---|
22 | rq = rqc() |
---|
23 | |
---|
24 | def sampl(sh, ns=10): |
---|
25 | k = 0 |
---|
26 | ks = sh.keys()[:100] |
---|
27 | while k < ns: |
---|
28 | if ks[k][0] != '_': |
---|
29 | print sh[ ks[k] ] |
---|
30 | k += 1 |
---|
31 | |
---|
32 | ki=0 |
---|
33 | km=0 |
---|
34 | nok = 0 |
---|
35 | kn = 0 |
---|
36 | for k in rq.revti.keys(): |
---|
37 | if k[0] != '_': |
---|
38 | u = rq.revti[k][3] |
---|
39 | if u == None: |
---|
40 | km += 1 |
---|
41 | elif u == '__inc__': |
---|
42 | ki += 1 |
---|
43 | ## new OMIP variables are mixed up with revised old variables ....... |
---|
44 | elif u == '__new__': |
---|
45 | kn += 1 |
---|
46 | elif not rq.refti.has_key(u): |
---|
47 | print 'ERROR.010.0001: look up key not found: ', rq.revti[k] |
---|
48 | else: |
---|
49 | nok += 1 |
---|
50 | |
---|
51 | print 'CHECK.001.0002: on revTabItems: %s OK, %s missing reference, %s includes [Not managed yet]' % (nok,km, ki) |
---|
52 | |
---|
53 | nok = 0 |
---|
54 | km = 0 |
---|
55 | knf = 0 |
---|
56 | for k in rq.refti.keys(): |
---|
57 | if k[0] != '_': |
---|
58 | r = rq.refti[k] |
---|
59 | if r[-1] != '__none__': |
---|
60 | if rq.vars.has_key(r[-1]): |
---|
61 | nok += 1 |
---|
62 | else: |
---|
63 | print 'NOT FOUND:',r |
---|
64 | knf += 1 |
---|
65 | else: |
---|
66 | km += 1 |
---|
67 | print 'CHECK.001.0003: on refTabItems: %s OK, %s missing reference, not found %s' % (nok,km,knf) |
---|
68 | |
---|
69 | nok1 = 0 |
---|
70 | nok2 = 0 |
---|
71 | nok = 0 |
---|
72 | km = 0 |
---|
73 | kmm = 0 |
---|
74 | knf = 0 |
---|
75 | for k in rq.grps.keys(): |
---|
76 | if k[0] != '_': |
---|
77 | r = rq.grps[k] |
---|
78 | if r[-3][0] != '_': |
---|
79 | if r[-4] == 0: |
---|
80 | if rq.vars.has_key(r[-3]): |
---|
81 | nok1 += 1 |
---|
82 | else: |
---|
83 | print 'NOT FOUND:',r |
---|
84 | knf += 1 |
---|
85 | elif r[-4] == 1: |
---|
86 | if rq.rqvg.has_key(r[-3]): |
---|
87 | nok2 += 1 |
---|
88 | else: |
---|
89 | print 'NOT FOUND:',r |
---|
90 | knf += 1 |
---|
91 | else: |
---|
92 | kmm += 1 |
---|
93 | else: |
---|
94 | ##print '!GROUP: ',r |
---|
95 | km += 1 |
---|
96 | print 'CHECK.001.0004: on groupItems: %s,%s OK, %s missing reference, not found %s, bad "new" key %s ' % (nok1,nok2,km,knf,kmm) |
---|
97 | |
---|
98 | nok1 = 0 |
---|
99 | nok2 = 0 |
---|
100 | nok = 0 |
---|
101 | km = 0 |
---|
102 | kmm = 0 |
---|
103 | knf = 0 |
---|
104 | for k in rq.grps.keys(): |
---|
105 | if k[0] != '_': |
---|
106 | r = rq.grps[k] |
---|
107 | ## new variables |
---|
108 | if r[-2] == 0: |
---|
109 | if rq.vars.has_key(r[-1]): |
---|
110 | nok1 += 1 |
---|
111 | else: |
---|
112 | print 'NOT FOUND:',r |
---|
113 | knf += 1 |
---|
114 | ## old vars |
---|
115 | elif r[-2] == 1: |
---|
116 | if rq.refti.has_key(r[-1]): |
---|
117 | nok2 += 1 |
---|
118 | else: |
---|
119 | print 'NOT FOUND:',r |
---|
120 | knf += 1 |
---|
121 | else: |
---|
122 | kmm += 1 |
---|
123 | print 'CHECK.001.0005: on groupItems -- for variable defs: %s,%s OK, %s missing reference, not found %s, bad "new" key %s ' % (nok1,nok2,km,knf,kmm) |
---|
124 | |
---|
125 | nok = 0 |
---|
126 | nm = 0 |
---|
127 | for k in rq.rqit.keys(): |
---|
128 | if k[0] != '_': |
---|
129 | r = rq.rqit[k] |
---|
130 | rid = r[3] |
---|
131 | if rq.rqli.has_key(rid): |
---|
132 | nok += 1 |
---|
133 | else: |
---|
134 | nm += 1 |
---|
135 | print 'CHECK.001.0006: on request links: %s OK, %s missing' % (nok,nm) |
---|
136 | |
---|
137 | nok = 0 |
---|
138 | nm = 0 |
---|
139 | nb = 0 |
---|
140 | for k in rq.rqli.keys(): |
---|
141 | if k[0] != '_': |
---|
142 | r = rq.rqli[k] |
---|
143 | rid = r[-1] |
---|
144 | if rid[0] != '_': |
---|
145 | if rq.rqvg.has_key(rid): |
---|
146 | nok += 1 |
---|
147 | else: |
---|
148 | nm += 1 |
---|
149 | else: |
---|
150 | nb += 1 |
---|
151 | print 'CHECK.001.0007: on request links referencing to variable group: %s OK, %s missing, %s unset' % (nok,nm,nb) |
---|
152 | |
---|