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():
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().split(':')
30 if key == 'Description' and key in block:
31 block[key] = '/'.join([block[key], value])
35 for k, v in lists.items():
36 with open(os.path.join('tags', k), 'w') as f:
42 with urllib.request.urlopen('https://registry.isdcf.com/languages') as f, open(os.path.join('tags', 'dcnc'), 'w') as g:
43 js = json.loads(f.read())
46 print(d['rfc5646Tag'], file=g)
47 print(d['dcncTag'], file=g)