Beispiel #1
0
def filter_translit(*args, **kwargs):
    locale = str(get_locale())
    _type = kwargs.get('type')
    if len(args) == 1:
        string = args[0]
        return translit(string, 'ko', locale, _type) if locale != 'ko' else string
    elif args:
        raise Exception('filter_translit() only accepts one or zero argument')
    else:
        return lambda x: filter_translit(x, type=_type)
Beispiel #2
0
def filter_translit(*args, **kwargs):
    locale = str(get_locale())
    _type = kwargs.get('type')
    if len(args) == 1:
        string = args[0]
        return translit(string, 'ko', locale,
                        _type) if locale != 'ko' else string
    elif args:
        raise Exception('filter_translit() only accepts one or zero argument')
    else:
        return lambda x: filter_translit(x, type=_type)
Beispiel #3
0
def insert_person(session, election_type, assembly_id, r):
    person = guess_person(r)

    if person:
        extra_vars = json.loads(person.extra_vars)
        extra_vars.update(r)
        extra_vars[election_type][assembly_id] = r
        person.extra_vars = json.dumps(extra_vars)

    else:
        person_id = get_person_id(r)
        name_en = translit(r['name_kr'], 'ko', 'en', 'name')
        gender = map_gender[r['sex']]
        birthday = '%04d%02d%02d' % (
                int(r.get('birthyear', 0)),
                int(r.get('birthmonth', 0)),
                int(r.get('birthday', 0))
                )
        education = markup(r['education'], 'education') if 'education' in r else []
        address = markup(r['address'], 'district') if 'address' in r else []
        extra_vars = r.copy()
        # FIXME: THIS_ASSEMBLY를 쓰면 시점을 제대로 못잡음
        extra_vars['assembly'] = {}
        extra_vars['assembly'][THIS_ASSEMBLY] = r

        person = Person(
                id=person_id,
                name=r['name_kr'],
                name_en=name_en,
                name_cn=r['name_cn'],
                gender=gender,
                birthday=birthday,
                education=[term[0] for term in education],
                education_id=[term[1] for term in education],
                address=[term[0] for term in address],
                address_id=[term[1] for term in address],
                image=r.get('image', None),
                twitter=r.get('twitter', None),
                facebook=r.get('facebook', None),
                blog=r.get('blog', None),
                homepage=r.get('homepage', None),
                extra_vars=json.dumps(extra_vars)
                )

        session.add(person)
        session.flush()

    return person.id
Beispiel #4
0
def insert_person(session, election_type, assembly_id, r):
    person = guess_person(r)

    if person:
        extra_vars = json.loads(person.extra_vars)
        extra_vars.update(r)
        extra_vars[election_type][assembly_id] = r
        person.extra_vars = json.dumps(extra_vars)

    else:
        person_id = get_person_id(r)
        name_en = translit(r['name_kr'], 'ko', 'en', 'name')
        gender = map_gender[r['sex']]
        birthday = '%04d%02d%02d' % (int(r.get(
            'birthyear', 0)), int(r.get('birthmonth',
                                        0)), int(r.get('birthday', 0)))
        education = markup(r['education'],
                           'education') if 'education' in r else []
        address = markup(r['address'], 'district') if 'address' in r else []
        extra_vars = r.copy()
        # FIXME: THIS_ASSEMBLY를 쓰면 시점을 제대로 못잡음
        extra_vars['assembly'] = {}
        extra_vars['assembly'][THIS_ASSEMBLY] = r

        person = Person(id=person_id,
                        name=r['name_kr'],
                        name_en=name_en,
                        name_cn=r['name_cn'],
                        gender=gender,
                        birthday=birthday,
                        education=[term[0] for term in education],
                        education_id=[term[1] for term in education],
                        address=[term[0] for term in address],
                        address_id=[term[1] for term in address],
                        image=r.get('image', None),
                        twitter=r.get('twitter', None),
                        facebook=r.get('facebook', None),
                        blog=r.get('blog', None),
                        homepage=r.get('homepage', None),
                        extra_vars=json.dumps(extra_vars))

        session.add(person)
        session.flush()

    return person.id