Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #67 by indexing per range, not per org name #70

Merged
merged 2 commits into from
Sep 16, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions winnower.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ 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(' ')
as_num = as_num.replace("AS", "") # Making sure the variable only has the number
break
return as_num, as_name

Expand Down