10 with urllib.request.urlopen('https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry') as f:
11 #with open('language-subtag-registry', 'r') as f:
12 for l in f.readlines():
13 if l.strip().decode('utf-8') == "%%":
15 if block['Type'] in ['language', 'variant', 'region', 'script', 'extlang']:
16 if not block['Type'] in lists:
17 lists[block['Type']] = []
18 lists[block['Type']].append((block['Subtag'], block['Description']))
19 elif block['Type'] == 'redundant' or block['Type'] == 'grandfathered':
20 # We'll ignore these (for now)
23 print("Unknown type `%s'" % block['Type'])
26 p = l.strip().decode('utf-8').split(':')
28 block[p[0]] = p[1][1:]
30 for k, v in lists.items():
31 with open(os.path.join('tags', k), 'w') as f:
38 with urllib.request.urlopen('https://registry.isdcf.com/languages') as f, open(os.path.join('tags', 'dcnc'), 'w') as g:
39 js = json.loads(f.read())
42 print(d['rfc5646Tag'], file=g)
43 print(d['dcncTag'], file=g)