comparison make-tld-conf.py @ 270:f92f24950bd3 stable-6-0-35

Use mozilla prefix list for tld checking, Enable surbl/uribl/dbl rhs lists
author Carl Byington <carl@five-ten-sg.com>
date Mon, 09 Sep 2013 15:15:53 -0700
parents
children 19ff60eaab74
comparison
equal deleted inserted replaced
269:6d2a11f0ae41 270:f92f24950bd3
1 #!/usr/bin/python
2
3 import os, sys
4
5 def cmd(c):
6 return os.popen(c).read().rstrip('\n')
7
8
9 c = 'curl http://mxr.mozilla.org/mozilla-central/source/netwerk/dns/effective_tld_names.dat?raw=1 2>/dev/null'
10 content = cmd(c)
11 f=open('tld.conf','w')
12 for x in content.split('\n'):
13 if (x == '') or (x[:2] == '//'): f.write('%s\n' % x)
14 else:
15 if x[:1] == '!':
16 x = x[1:]
17 prefix = '!'
18 else:
19 prefix = ''
20 yy = []
21 for xx in x.split('.'):
22 y = unicode(xx, 'utf8')
23 z = y.encode('punycode')
24 if z[-1:] == '-': yy.append(xx)
25 else: yy.append('xn--%s' % z)
26 y = '.'.join(yy)
27 if y == x:
28 f.write('%s%s\n' % (prefix, x))
29 else:
30 f.write('// %s%s\n' % (prefix, x))
31 f.write('%s%s\n' % (prefix, y))
32 f.close()