def main(): for pol in voteview.parse(): if not pol.get('district_id'): continue #@@ if not tools.districtp(pol.district_id) and pol.district_id.endswith('01'): pol.district_id = pol.district_id.split('-')[0] + '-' + '00' watchdog_id = tools.getWatchdogID(pol.district_id, pol.last_name) if watchdog_id: db.update('politician', where='id=$watchdog_id', vars=locals(), icpsrid = pol.icpsr_id, nominate = pol.dim1, predictability = 1 - (pol.n_errs / float(pol.n_votes)))
def main(): for pol in voteview.parse(): if not pol.get('district_id'): continue #@@ if not tools.districtp( pol.district_id) and pol.district_id.endswith('01'): pol.district_id = pol.district_id.split('-')[0] + '-' + '00' watchdog_id = tools.getWatchdogID(pol.district_id, pol.last_name) if watchdog_id: db.update('politician', where='id=$watchdog_id', vars=locals(), icpsrid=pol.icpsr_id, nominate=pol.dim1, predictability=1 - (pol.n_errs / float(pol.n_votes)))
from parse import punch import tools from settings import db for can in punch.parse_all(): d = tools.districtp(can.district) if d and can.name.split(',')[0].lower() in d: db.update('politician', where='id = $d', vars=locals(), chips2008=can.chips2008, progressive2008=can.progressive2008, progressiveall=can.progressiveall)
""" import voteview """ import simplejson from parse import voteview import tools out = {} for pol in voteview.parse(): if pol.congress != 110 or not pol.get('district_id'): continue #@@ if not tools.districtp(pol.district_id) and pol.district_id.endswith('01'): pol.district_id = pol.district_id.split('-')[0] + '-' + '00' watchdog_id = tools.getWatchdogID(pol.district_id,pol.last_name) if watchdog_id: out[watchdog_id] = { 'icpsrid': pol.icpsr_id, 'nominate': pol.dim1, 'predictability': 1 - (pol.n_errs / float(pol.n_votes)) } if __name__ == "__main__": print simplejson.dumps(out, indent=2, sort_keys=True)