Permalink
Browse files

reading states as codes

  • Loading branch information...
1 parent dbf33e4 commit d56cd3828aef31a219e7c16fa1c42c0fcc72d078 dvir volk committed Apr 6, 2011
Showing with 4 additions and 3 deletions.
  1. +1 −1 src/geodis.py
  2. +1 −0 src/iprange.py
  3. +2 −2 src/provider/zipcodes.py
View
@@ -78,7 +78,7 @@ def resolveIP(ip):
global redis_host, redis_port, redis_db
r = redis.Redis(host = redis_host, port = redis_port, db = redis_db)
- loc = IPRange.getCity(ip, r)
+ loc = IPRange.getZIP(ip, r)
print loc
View
@@ -102,6 +102,7 @@ def getZIP(ip, redisConn):
"""
range = IPRange.get(ip, redisConn)
+
if not range or not re.match('^[0-9]{5}$', range.zipcode):
return None
@@ -60,7 +60,7 @@ def runImport(self):
stateCode = row[2]
lat = float(row[3])
lon = float(row[4])
- state = code_to_state.get(stateCode, '').title()
+ state = stateCode#code_to_state.get(stateCode, '').title()
country = 'US'
loc = ZIPCode(name = name,
@@ -84,4 +84,4 @@ def runImport(self):
logging.info("Imported %d locations" % i)
- return i
+ return i

0 comments on commit d56cd38

Please sign in to comment.