Exemplo n.º 1
0
def geo_by_addr(ip):
    try:
        geo = _geo_by_addr(ip)
    except Exception:
        geo = None

    if not geo:
        return

    rv = {}
    for k in "country_code", "city", "region":
        d = geo.get(k)
        if isinstance(d, bytes):
            d = d.decode("ISO-8859-1")
        rv[k] = d

    return rv
Exemplo n.º 2
0
def geo_by_addr(ip):
    try:
        geo = _geo_by_addr(ip)
    except Exception:
        geo = None

    if not geo:
        return

    rv = {}
    for k in 'country_code', 'city', 'region':
        d = geo.get(k)
        if isinstance(d, six.binary_type):
            d = d.decode('ISO-8859-1')
        rv[k] = d

    return rv
Exemplo n.º 3
0
def geo_by_addr(ip):
    try:
        geo = _geo_by_addr(ip)
    except Exception:
        geo = None

    if not geo:
        return

    rv = {}
    for k in 'country_code', 'city', 'region':
        d = geo.get(k)
        if isinstance(d, six.binary_type):
            d = d.decode('ISO-8859-1')
        rv[k] = d

    return rv