Beispiel #1
0
def get_attendees(meeting, names, session=None):
    for name in names:
        try:
            person = guess_person(name=name, assembly_id=meeting.parliament_id, is_elected=True)
            # FIXME: workaround different session binding problem
            yield session.query(Person).filter_by(id=person.id).one()
        except MultipleResultsFound as e:
            logging.warning("Multiple result found for: %s" % name)
        except NoResultFound as e:
            logging.warning("No result found for: %s" % name)
def get_attendees(meeting, names, session=None):
    for name in names:
        try:
            person = guess_person(name=name,
                                  assembly_id=meeting.parliament_id,
                                  is_elected=True)
            # FIXME: workaround different session binding problem
            yield session.query(Person).filter_by(id=person.id).one()
        except MultipleResultsFound as e:
            logging.warning('Multiple result found for: %s' % name)
        except NoResultFound as e:
            logging.warning('No result found for: %s' % name)
Beispiel #3
0
def update_person(session, record):
    name = record['name_kr']
    person = None
    try:
        person = guess_person(name=name,
                              birthday=record['birthday'],
                              is_elected=True)
    except MultipleResultsFound as e:
        logging.warning('Multiple result found for: %s' % name)
    except NoResultFound as e:
        logging.warning('No result found for: %s' % name)

    if not person:
        return

    person = session.query(Person).filter_by(id=person.id).first()
    for key, val in record.items():
        if key != 'id' and hasattr(person, key):
            setattr(person, key, val)

    return person.id
Beispiel #4
0
def update_person(session, record):
    name = record['name_kr']
    person = None
    try:
        person = guess_person(name=name,
                              birthday=record['birthday'],
                              is_elected=True)
    except MultipleResultsFound as e:
        logging.warning('Multiple result found for: %s' % name)
    except NoResultFound as e:
        logging.warning('No result found for: %s' % name)

    if not person:
        return

    person = session.query(Person).filter_by(id=person.id).first()
    for key, val in record.items():
        if key != 'id' and hasattr(person, key):
            setattr(person, key, val)

    return person.id