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