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

Fix some flake8 linting errors #20

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions aggregate6/aggregate6.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

try:
from builtins import str as text
except:
except ImportError:
# Python2.7 compatibility
from __builtin__ import unicode as text

Expand All @@ -41,21 +41,21 @@
import sys


def aggregate(l):
def aggregate(prefixes):
"""Aggregate a `list` of prefixes.

Keyword arguments:
l -- a python list of prefixes
prefixes -- a python list of prefixes

Example use:
>>> aggregate(["10.0.0.0/8", "10.0.0.0/24"])
['10.0.0.0/8']
"""
tree = radix.Radix()
for item in l:
for item in prefixes:
try:
tree.add(item)
except (ValueError) as err:
except ValueError:
raise Exception("ERROR: invalid IP prefix: {}".format(item))

return aggregate_tree(tree).prefixes()
Expand Down Expand Up @@ -155,7 +155,7 @@ def main():
else:
prefix_obj = ip_network(text(elem.strip()))
prefix = text(prefix_obj)
except (ValueError) as err:
except ValueError:
sys.stderr.write("ERROR: '%s' is not a valid IP network, \
ignoring.\n" % elem.strip())
continue
Expand Down