Skip to content

Commit

Permalink
Fixes #67 by indexing per range, not per org name
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Maxwell committed Sep 15, 2014
1 parent d3f3ccf commit 17ae07f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions winnower.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ def load_gi_org(filename):
with open(filename, 'rb') as f:
org_reader = csv.DictReader(f, fieldnames=['start', 'end', 'org'])
for row in org_reader:
gi_org[row['org']] = IPRange(row['start'], row['end'])
gi_org[IPRange(row['start'], row['end'])] = row['org']
return gi_org


def org_by_addr(address, org_data):
as_num = None
as_name = None
for org in org_data:
if address in org_data[org]:
as_num, sep, as_name = org.partition(' ')
for iprange in org_data:
if address in iprange:
as_num, sep, as_name = org_data[iprange].partition(' ')
break
return as_num, as_name

Expand Down

0 comments on commit 17ae07f

Please sign in to comment.