diff options
author | Rob Austein <sra@hactrn.net> | 2010-10-11 23:47:42 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2010-10-11 23:47:42 +0000 |
commit | 7c2a3ba493d9b966ce685e864389e09783521a2e (patch) | |
tree | d53c12f871016556071aa88b3f5dc33161615f84 /scripts/csvgrep.py | |
parent | 5d130e883692592fe146fe254164948789d08b05 (diff) |
We've already built a resource_set by the time we find a match, might
as well use it to prettify our output.
svn path=/scripts/csvgrep.py; revision=3479
Diffstat (limited to 'scripts/csvgrep.py')
-rw-r--r-- | scripts/csvgrep.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/scripts/csvgrep.py b/scripts/csvgrep.py index 823785bd..7c419021 100644 --- a/scripts/csvgrep.py +++ b/scripts/csvgrep.py @@ -45,16 +45,22 @@ for datum in sys.argv[1:]: #print "Looking for: ASNs %s IPv4 %s IPv6 %s" % (asn, ipv4, ipv6) -def matches(resource_set, datum): - return resource_set.intersection(resource_set.__class__(datum)) +def matches(set1, datum): + set2 = set1.__class__(datum) + if set1.intersection(set2): + return set2 + else: + return False if asn: for h, a in rpki.myrpki.csv_reader("asns.csv", columns = 2): - if matches(asn, a): - print h, a + m = matches(asn, a) + if m: + print h, m if ipv4 or ipv6: for h, a in rpki.myrpki.csv_reader("prefixes.csv", columns = 2): t = ipv6 if ":" in a else ipv4 - if t and matches(t, a): - print h, a + m = t and matches(t, a) + if m: + print h, m |