9 with urllib.request.urlopen('https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry') as f:
10 #with open('language-subtag-registry', 'r') as f:
11 for l in f.readlines():
12 if l.strip().decode('utf-8') == "%%":
14 if block['Type'] in ['language', 'variant', 'region', 'script', 'extlang']:
15 if not block['Type'] in lists:
16 lists[block['Type']] = []
17 lists[block['Type']].append((block['Subtag'], block['Description']))
18 elif block['Type'] == 'redundant' or block['Type'] == 'grandfathered':
19 # We'll ignore these (for now)
22 print("Unknown type `%s'" % block['Type'])
25 p = l.strip().decode('utf-8').split(':')
27 block[p[0]] = p[1][1:]
29 for k, v in lists.items():
30 with open(os.path.join('tags', k), 'w') as f: