"start": match.start(), "end": match.end() }) for i in range(0, len(sittings)): # --> sittings, attendance, filelog if i != len(sittings) - 1: one_sitting_text = total_text[ sittings[i]['start']:sittings[i + 1]['start']] else: one_sitting_text = total_text[sittings[i]['start']:] logging.info(sittings[i]['uid']) common.InsertSitting(c, sittings[i]) common.FileLog(c, sittings[i]['name']) present_match = Present_Token.search(one_sitting_text) if present_match: common.Attendance(c, sittings[i], present_match.group('names'), 'CS', 'present') absent_match = Absent_Token.search(one_sitting_text) if absent_match: common.Attendance(c, sittings[i], absent_match.group('names'), 'CS', 'absent') # <-- # --> votes IterVote(one_sitting_text, sittings[i]) # <-- conn.commit() print 'votes, voter done!' print 'update meeting_minutes download links' meetings = json.load( open('../../../data/tcc/meeting_minutes-%s.json' % election_year)) for meeting in meetings:
# --> sittings, attendance, filelog if i != len(sittings)-1: one_sitting_text = total_text[sittings[i]['start']:sittings[i+1]['start']] else: one_sitting_text = total_text[sittings[i]['start']:] print sittings[i] common.InsertSitting(c, sittings[i]) common.FileLog(c, sittings[i]['name']) # absent absent_match = Absent_Token.search(one_sitting_text) exclude = [] if absent_match: names = re.sub(u'(副?議長|議員)', '', absent_match.group('names')) names = re.sub(u'、', ' ', names) if names: exclude = common.Attendance(c, sittings[i], names, 'CS', 'absent') else: print one_sitting_text raise # present for councilor_id in in_office_ids(sittings[i]['date'], exclude): common.AddAttendanceRecord(c, councilor_id, sittings[i]['uid'], 'CS', 'present') # <-- # --> votes IterVote(one_sitting_text, sittings[i]) # <-- conn.commit() print 'votes, voter done!' print 'update meeting_minutes download links' meetings = json.load(open('../../../data/kcc/meeting_minutes-%s.json' % election_year))
if match.group('type') == u'定期': uid = '%s-%s-%02d-CS-%02d' % (county_abbr3, election_years[int(match.group('ad'))], int(match.group('session')), int(meeting['meeting'])) elif match.group('type') == u'臨時': uid = '%s-%s-T%02d-CS-%02d' % (county_abbr3, election_years[int(match.group('ad'))], int(match.group('session')), int(meeting['meeting'])) sitting = {"uid": uid, "name": u'%s議會%s第%s會議' % (county, meeting['sitting'], meeting['meeting']), "county": county, "election_year": election_years[int(match.group('ad'))], "session": match.group('session'), "date": meeting['date']} # --> sittings, attendance, filelog print sitting common.InsertSitting(c, sitting) common.FileLog(c, sitting['name']) # present present_match = Present_Token.search(total_text) exclude = [] if present_match: names = re.sub(u'(副?議長|議員)', '', present_match.group('names')) if names: exclude.extend(common.Attendance(c, sitting, names, 'CS', 'present')) else: print total_text raise # no councilor's name to record if exclude == []: continue # absent for councilor_id in in_office_ids(sitting['date'], exclude): common.AddAttendanceRecord(c, councilor_id, sitting['uid'], 'CS', 'absent') # <-- print 'votes, voter done!' vote_common.person_attendance_param(c, county) conn.commit() print 'Succeed'
"election_year": election_year, "session": match.group('session'), "date": meeting['date'] } # --> sittings, attendance, filelog print sitting common.InsertSitting(c, sitting) common.FileLog(c, sitting['name']) # present present_match = Present_Token.search(total_text) exclude = [] if present_match: names = re.sub(u'(副?議長|議員)', '', present_match.group('names')) if names: exclude.extend( common.Attendance(c, sitting, names, 'CS', 'present')) else: print total_text raise # no councilor's name to record if exclude == []: continue # absent for councilor_id in in_office_ids(sitting['date'], exclude): common.AddAttendanceRecord(c, councilor_id, sitting['uid'], 'CS', 'absent') # <-- print 'votes, voter done!' vote_common.person_attendance_param(c, county) conn.commit()
})['absent'].append(name) # clean holiday records for date, v in d.items(): if len(v['present']) == 0: d.pop(date) sorted(d, key=lambda x: x[0]) match = Session_Token.search(re.sub(u'、', '', f.name)) for i, (k, v) in enumerate(d.items(), 1): if match.group('type') == u'定期': uid = '%s-%s-%02d-CS-%02d' % (county_abbr3, election_year, int(match.group('session')), i) elif match.group('type') == u'臨時': uid = '%s-%s-T%02d-CS-%02d' % (county_abbr3, election_year, int(match.group('session')), i) sitting_dict = { 'county': county, 'election_year': election_year, 'uid': uid, 'name': u'%s第%d次會議' % (re.sub('\s', '', match.group('name')), i), 'date': k } common.InsertSitting(c, sitting_dict) common.FileLog(c, sitting_dict['name']) common.Attendance(c, sitting_dict, ' '.join(v['present']), 'CS', 'present') common.Attendance(c, sitting_dict, ' '.join(v['absent']), 'CS', 'absent') vote_common.person_attendance_param(c, county) conn.commit()