-
Notifications
You must be signed in to change notification settings - Fork 2
/
check_opencong.py
54 lines (42 loc) · 1.41 KB
/
check_opencong.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python
import os
#import socrata_rows as soc
import Current_members_of_the_United_States_House_of_Representatives as reps
import Ballotpedia_house as breps
import List_of_current_United_States_Senators as sens
import Ballotpedia_senator as bsens
import cache
import legislators_current as leg
from cStringIO import StringIO
rep= cache.cache('reps',reps.parse_rep)
brep= cache.cache('breps',breps.parse)
sen= cache.cache('sen',sens.parse)
bsen= cache.cache('bsen',bsens.parse)
congress = { 'wp' : rep['wp'].copy() }
congress['wp'].update(sen['wp'])
legs= leg.load()
def compare(a,b,name,link) :
for x in sorted(a['wp'].keys()):
aobj = a['wp'][x]
# print aobj['id']
if link not in aobj['id']:
pass
else:
bid = aobj['id'][link]
bid = bid.replace(" ","_")
if bid not in b['wp'] :
# print "missing in B ", bid
# print sorted(b['wp'].keys())
continue
bobj = b['wp'][bid]
if name in bobj['links']:
val = bobj['links'][name]
a['wp'][x]['id'][name]=val
print "transfered",name,link,val
compare(legs,rep,'opencong','wikipedia')
compare(legs,sen,'opencong','wikipedia')
compare(legs,brep,'opencong','ballotpedia')
compare(legs,bsen,'opencong','ballotpedia')
import dump
leg.apply(legs)
dump.dump(legs)