Exemple #1
0
def upgrade():
    people = Person.query.all()
    for person in people:
        name_en = translit(person.name, 'ko', 'en', 'name')
        op.execute(person_t.update().\
                where(person_t.c.id == person.id).\
                values({'name_en': op.inline_literal(name_en)})
        )
Exemple #2
0
def upgrade():
    people = Person.query.all()
    for person in people:
        name_en = translit(person.name, 'ko', 'en', 'name')
        op.execute(person_t.update().\
                where(person_t.c.id == person.id).\
                values({'name_en': op.inline_literal(name_en)})
        )
Exemple #3
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)
Exemple #4
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)
Exemple #5
0
def insert_person(session, r):
    person = guess_person(r)

    if person:
        extra_vars = json.loads(person.extra_vars)
        extra_vars.update(r)
        extra_vars['assembly']['19'] = 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()
        extra_vars['assembly'] = {}
        extra_vars['assembly']['19'] = 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
Exemple #6
0
def insert_person(session, r):
    person = guess_person(r)

    if person:
        extra_vars = json.loads(person.extra_vars)
        extra_vars.update(r)
        extra_vars['assembly']['19'] = 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()
        extra_vars['assembly'] = {}
        extra_vars['assembly']['19'] = 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
Exemple #7
0
def insert_person(session, r):
    person = guess_person(r)

    if person:
        extra_vars = json.loads(person.extra_vars)
        extra_vars.update(r)
        extra_vars["assembly"]["19"] = 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()
        extra_vars["assembly"] = {}
        extra_vars["assembly"]["19"] = 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