katie/scripts/gentld.py
Ivailo Monev f40fc06760 use script instead of utility to generate URL TLDs table
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
2019-11-26 19:08:55 +00:00

23 lines
527 B
Python
Executable file

#!/usr/bin/python
# Data is from https://publicsuffix.org/list/public_suffix_list.dat
tldlist = []
with open('public_suffix_list.dat', 'rb') as f:
content = f.read()
content = content.decode('utf-8')
for line in content.splitlines():
if line.startswith('//') or not line:
continue
tldlist.append(line)
tldcount = len(tldlist)
print('''static const char* TLDTbl[%d] = {''' % tldcount)
for tld in tldlist:
print(' "%s\\0",' % tld)
print('''};
static const qint16 TLDTblSize = %d;''' % tldcount)