예제 #1
0
         uid = '%s-%s-%02d-CS-%02d' % (
             county_abbr3, election_year, int(match.group('session')),
             int(re.sub('\D', '', meeting['meeting'])))
     sitting = {
         "uid": uid,
         "name":
         u'%s議會%s%s' % (county, meeting['sitting'], meeting['meeting']),
         "county": county,
         "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
예제 #2
0
            "election_year": election_year,
            "session": match.group('session'),
            "date": common.ROC2AD(total_text[match.end():]),
            "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!'
                        })['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()