mirror of
https://github.com/manuelkasper/AS-Stats.git
synced 2025-02-20 11:44:12 +08:00
generate-asinfo.py: Removing leading on the country
This commit is contained in:
parent
c233dd1ff0
commit
f29a39dd49
@ -4,30 +4,31 @@
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
for line in sys.stdin:
|
for line in sys.stdin:
|
||||||
try:
|
try:
|
||||||
asn,country,_,_,data = [_.strip() for _ in line.split('|')]
|
asn,country,_,_,data = [_.strip() for _ in line.split('|')]
|
||||||
except ValueError:
|
except ValueError:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data,country = data.rsplit(',',1)
|
data,country = data.rsplit(',',1)
|
||||||
except:
|
country = country.strip()
|
||||||
data = data
|
except:
|
||||||
|
data = data
|
||||||
|
|
||||||
if data == '-Private Use AS-':
|
if data == '-Private Use AS-':
|
||||||
data = 'Private Use AS'
|
data = 'Private Use AS'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
macro,name = data.split(' ',1)
|
macro,name = data.split(' ',1)
|
||||||
except:
|
except:
|
||||||
macro = data
|
macro = data
|
||||||
name = data
|
name = data
|
||||||
|
|
||||||
if not (macro.count('-') or macro.upper() == macro or name.startswith('- ')) or macro == 'UK':
|
if not (macro.count('-') or macro.upper() == macro or name.startswith('- ')) or macro == 'UK':
|
||||||
macro = 'UNSPECIFIED'
|
macro = 'UNSPECIFIED'
|
||||||
name = data
|
name = data
|
||||||
|
|
||||||
if name.startswith('- '):
|
if name.startswith('- '):
|
||||||
name = name[2:]
|
name = name[2:]
|
||||||
|
|
||||||
print("%s\t%s\t%s\t%s" % (asn,macro,name,country))
|
print("%s\t%s\t%s\t%s" % (asn,macro,name,country))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user