File tree 1 file changed +6
-6
lines changed
1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 30
30
31
31
try :
32
32
from builtins import str as text
33
- except :
33
+ except ImportError :
34
34
# Python2.7 compatibility
35
35
from __builtin__ import unicode as text
36
36
41
41
import sys
42
42
43
43
44
- def aggregate (l ):
44
+ def aggregate (prefixes ):
45
45
"""Aggregate a `list` of prefixes.
46
46
47
47
Keyword arguments:
48
- l -- a python list of prefixes
48
+ prefixes -- a python list of prefixes
49
49
50
50
Example use:
51
51
>>> aggregate(["10.0.0.0/8", "10.0.0.0/24"])
52
52
['10.0.0.0/8']
53
53
"""
54
54
tree = radix .Radix ()
55
- for item in l :
55
+ for item in prefixes :
56
56
try :
57
57
tree .add (item )
58
- except ( ValueError ) as err :
58
+ except ValueError :
59
59
raise Exception ("ERROR: invalid IP prefix: {}" .format (item ))
60
60
61
61
return aggregate_tree (tree ).prefixes ()
@@ -155,7 +155,7 @@ def main():
155
155
else :
156
156
prefix_obj = ip_network (text (elem .strip ()))
157
157
prefix = text (prefix_obj )
158
- except ( ValueError ) as err :
158
+ except ValueError :
159
159
sys .stderr .write ("ERROR: '%s' is not a valid IP network, \
160
160
ignoring.\n " % elem .strip ())
161
161
continue
You can’t perform that action at this time.
0 commit comments