diff options
author | Rob Austein <sra@hactrn.net> | 2010-03-26 18:09:41 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2010-03-26 18:09:41 +0000 |
commit | f4d240ec289e3652a175abd5b38ce5d2696475d4 (patch) | |
tree | 7b7c226cdecaec3b948423d5c257562bd8772d2b | |
parent | 9e5c1639d84fdce7d4826efa7c2486729508292b (diff) |
Perhaps a simpler approach
svn path=/myrpki.rototill/ripe-asns-to-csv.py; revision=3136
-rw-r--r-- | myrpki.rototill/ripe-asns-to-csv.py (renamed from myrpki.rototill/ripe-to-csv.py) | 30 | ||||
-rw-r--r-- | myrpki.rototill/ripe-prefixes-to-csv.awk | 28 |
2 files changed, 30 insertions, 28 deletions
diff --git a/myrpki.rototill/ripe-to-csv.py b/myrpki.rototill/ripe-asns-to-csv.py index f3935399..01c0f82a 100644 --- a/myrpki.rototill/ripe-to-csv.py +++ b/myrpki.rototill/ripe-asns-to-csv.py @@ -29,8 +29,6 @@ class Handle(dict): want_tags = () - want_status = ("ASSIGNED", "ASSIGNEDPA", "ASSIGNEDPI") - debug = False def set(self, tag, val): @@ -56,14 +54,6 @@ class Handle(dict): def finish(self, ctx): self.check() -class as_block(Handle): - # This one is less useful than I had hoped, no useful links to owners - want_tags = ("as-block", "mnt-by", "org", "mnt-lower") - -class as_set(Handle): - # This is probably useless - want_tags = ("as-set", "mnt-by", "members") - class aut_num(Handle): want_tags = ("aut-num", "mnt-by", "as-name") @@ -76,23 +66,9 @@ class aut_num(Handle): if self.check(): ctx.asns.writerow((self["mnt-by"], self["aut-num"])) -class inetnum(Handle): - want_tags = ("inetnum", "mnt-by", "netname", "status") - - def finish(self, ctx): - if self.check() and self["status"] in self.want_status: - ctx.prefixes.writerow((self["mnt-by"], self["inetnum"])) - -class inet6num(Handle): - want_tags = ("inet6num", "mnt-by", "netname", "status") - - def finish(self, ctx): - if self.check() and self["status"] in self.want_status: - ctx.prefixes.writerow((self["mnt-by"], self["inet6num"])) - class main(object): - types = dict((x.want_tags[0], x) for x in (as_block, as_set, aut_num, inetnum, inet6num)) + types = dict((x.want_tags[0], x) for x in (aut_num,)) @staticmethod def csvout(fn): @@ -112,12 +88,10 @@ class main(object): self.cur.finish(self) self.cur = None - #filenames = ("ripe.db.gz",) - filenames = ("ripe.db.aut-num.gz", "ripe.db.inet6num.gz", "ripe.db.inetnum.gz") + filenames = ("ripe.db.aut-num.gz",) def __init__(self): self.asns = self.csvout("asns.csv") - self.prefixes = self.csvout("prefixes.csv") for fn in self.filenames: f = gzip.open(fn) self.statement = "" diff --git a/myrpki.rototill/ripe-prefixes-to-csv.awk b/myrpki.rototill/ripe-prefixes-to-csv.awk new file mode 100644 index 00000000..a532afa5 --- /dev/null +++ b/myrpki.rototill/ripe-prefixes-to-csv.awk @@ -0,0 +1,28 @@ +#!/usr/bin/awk -f +# $Id$ + +# ftp -pa ftp://ftp.ripe.net/pub/stats/ripencc/membership/alloclist.txt + +function done() { + for (i = 1; i <= n_allocs; i++) + print handle "\t" alloc[i]; + n_allocs = 0; +} + +/^[a-z]/ { + done(); + handle = $0; + nr = NR; +} + +NR == nr + 1 { + name = $0; +} + +NR > nr + 2 && NF > 1 { + alloc[++n_allocs] = $2; +} + +END { + done(); +} |