示例#1
0
def simple_transformer(sphere, index, row, lst, field, fields):
    idx = _name_ixd(field["name"], fields)

    input = strutils.build_input(row[idx])
    a = utils.to_action(index, "dict", input, input, row[idx].strip(),
                        {"name": strutils.to_name(row[idx])})
    lst[strutils.to_name(row[idx])] = a
示例#2
0
def name_transformer(sphere, index, row, lst, field, fields):
    idx = field["name"]
    if not row.get(idx):
        return
    inval = strutils.build_input(row[idx])
    a = utils.to_action(index, "dict", inval, inval, row[idx].strip(), {
        "id": row["_id"],
        "name": strutils.to_name(row[idx])
    })
    lst[strutils.to_name(row[idx])] = a
示例#3
0
def location_transformer(sphere, index, row, lst, field, fields):
    val = by_path(row, "location", field.get("json"))

    if not val:
        return

    input = strutils.build_input(val)
    a = utils.to_action(
        index, "dict", input, input, val.strip(), {
            "name": strutils.to_name(val),
            "country": by_path(row, "country", ["data", "location_tree"])
        })
    lst[strutils.to_name(val)] = a
示例#4
0
def list_transformer(sphere, index, row, lst, field, fields):
    fname = field["name"]
    val = by_path(row, fname, field.get("json"))

    if not val:
        return

    for item in val:
        a = utils.to_action(index, "dict", strutils.to_name(item),
                            strutils.build_input(item), item, {
                                "label": item,
                                "name": strutils.to_name(item)
                            })

        uid = uniq_id([strutils.to_name(item)])
        if uid not in lst:
            lst[uid] = a
示例#5
0
def admin1_transformer(sphere, index, row, lst, field, fields):
    val = by_path(row, "admin1", field.get("json"))

    if not val:
        return

    admin1 = strutils.to_name(val)
    country = strutils.to_name(by_path(row, "country", field.get("json")))
    input = strutils.build_input(val)
    a = utils.to_action(index, "dict", admin1, input, val.strip(), {
        "name": admin1,
        "path": [country, admin1, ""]
    })

    uid = uniq_id([country if country else "", admin1 if admin1 else ""])
    if uid not in lst:
        lst[uid] = a
示例#6
0
def mcountry_transformer(sphere, index, row, acc, field, fields):
    fname = field["name"]
    val = by_path(row, fname, field.get("json"))

    if not val:
        return

    for item in val:
        name = item["country"]
        uid = uniq_id([strutils.to_name(name)])
        if uid not in acc:
            inval = strutils.to_name(name)
            a = utils.to_action(index, "dict", strutils.to_name(name), inval,
                                name, {
                                    "label": name,
                                    "name": strutils.to_name(name)
                                })
            acc[uid] = a
示例#7
0
def country_transformer(sphere, index, row, lst, field, fields):
    val = by_path(row, "country", field.get("json"))

    nval = strutils.to_name(val)
    if not nval:
        return
    input = strutils.build_input(val)

    a = utils.to_action(index, "dict", nval, input, val.strip(), {
        "name": nval,
        "path": [nval, "", ""]
    })

    # only unique values must be appended
    uid = uniq_id([val])
    if uid not in lst:
        lst[uid] = a
示例#8
0
def country_conv(lst):
    if not lst:
        return []
    return [strutils.to_name(s["country"]) for s in lst if s.get("country")]
示例#9
0
def list_conv(lst):
    if not lst:
        return []
    return [strutils.to_name(s) for s in lst]
示例#10
0
def director_list_conv(lst):
    if not lst:
        return []
    return [strutils.to_name(s["name"]) for s in lst]
示例#11
0
def default_conv(val):
    return strutils.to_name(val)