def match_names(state, term): nm = NameMatcher(state, term) for t in metadata(state)['terms']: if t['name'] == term: sessions = t['sessions'] break else: print 'No such term for %s: %s' % (state, term) return for session in sessions: bills = db.bills.find({'state': state, 'session': session}) for bill in bills: for sponsor in bill['sponsors']: if not sponsor['leg_id']: sponsor['leg_id'] = nm.match(sponsor['name'], bill['chamber']) for vote in bill['votes']: for type in ('yes_votes', 'no_votes', 'other_votes'): for voter in vote[type]: if not voter['leg_id']: voter['leg_id'] = nm.match(voter['name'], vote['chamber']) db.bills.save(bill, safe=True)
def handle(self, args): level = metadata(args.abbr)['level'] nm = NameMatcher(args.abbr, args.term, level) for t in metadata(args.abbr)['terms']: if t['name'] == args.term: sessions = t['sessions'] break else: print 'No such term for %s: %s' % (args.abbr, args.term) return for session in sessions: bills = db.bills.find({ 'level': level, level: args.abbr, 'session': session }) for bill in bills: for sponsor in bill['sponsors']: if not sponsor['leg_id']: sponsor['leg_id'] = nm.match(sponsor['name'], bill['chamber']) for vote in bill['votes']: for type in ('yes_votes', 'no_votes', 'other_votes'): for voter in vote[type]: if not voter['leg_id']: voter['leg_id'] = nm.match( voter['name'], vote['chamber']) db.bills.save(bill, safe=True)
def handle(self, args): level = metadata(args.abbr)['level'] nm = NameMatcher(args.abbr, args.term, level) for t in metadata(args.abbr)['terms']: if t['name'] == args.term: sessions = t['sessions'] break else: print 'No such term for %s: %s' % (args.abbr, args.term) return for session in sessions: bills = db.bills.find({'level': level, level: args.abbr, 'session': session}) for bill in bills: for sponsor in bill['sponsors']: if not sponsor['leg_id']: sponsor['leg_id'] = nm.match(sponsor['name'], bill['chamber']) for vote in bill['votes']: for type in ('yes_votes', 'no_votes', 'other_votes'): for voter in vote[type]: if not voter['leg_id']: voter['leg_id'] = nm.match(voter['name'], vote['chamber']) db.bills.save(bill, safe=True)
def handle(self, args): nm = NameMatcher(args.abbr, args.term) for t in metadata(args.abbr)['terms']: if t['name'] == args.term: sessions = t['sessions'] break else: print 'No such term for %s: %s' % (args.abbr, args.term) return for session in sessions: bills = db.bills.find({settings.LEVEL_FIELD: args.abbr, 'session': session}) for bill in bills: for sponsor in bill['sponsors']: sponsor['leg_id'] = nm.match(sponsor['name'], bill['chamber']) db.bills.save(bill, safe=True) votes = db.votes.find({settings.LEVEL_FIELD: args.abbr, 'session': session}) for vote in votes: vote['_voters'] = [] for type in ('yes_votes', 'no_votes', 'other_votes'): for voter in vote[type]: voter['leg_id'] = nm.match(voter['name'], vote['chamber']) if voter['leg_id']: vote['_voters'].append(voter['leg_id']) db.votes.save(vote, safe=True)