#!/usr/bin/env python2

import sys
import re
import GeoIP

gi = GeoIP.open("/usr/share/GeoIP/GeoIPCity.dat", GeoIP.GEOIP_STANDARD)

if len(sys.argv) < 2:
	print("Please provide a hostname or IP address to look up")
	sys.exit(1)

arg = sys.argv[1]

if re.search(r"^[\d.:a-f]+$", arg):
	gir = gi.record_by_addr(arg)
else:
	gir = gi.record_by_name(arg)

print(gir)
