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
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
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