MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / parse

Function parse

tools/python-3.11.9-amd64/Tools/i18n/makelocalealias.py:18–54  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

16SUPPORTED = '/usr/share/i18n/SUPPORTED'
17
18def parse(filename):
19
20 with open(filename, encoding='latin1') as f:
21 lines = list(f)
22 # Remove mojibake in /usr/share/X11/locale/locale.alias.
23 # b'\xef\xbf\xbd' == '\ufffd'.encode('utf-8')
24 lines = [line for line in lines if '\xef\xbf\xbd' not in line]
25 data = {}
26 for line in lines:
27 line = line.strip()
28 if not line:
29 continue
30 if line[:1] == '#':
31 continue
32 locale, alias = line.split()
33 # Fix non-standard locale names, e.g. ks_IN@devanagari.UTF-8
34 if '@' in alias:
35 alias_lang, _, alias_mod = alias.partition('@')
36 if '.' in alias_mod:
37 alias_mod, _, alias_enc = alias_mod.partition('.')
38 alias = alias_lang + '.' + alias_enc + '@' + alias_mod
39 # Strip ':'
40 if locale[-1] == ':':
41 locale = locale[:-1]
42 # Lower-case locale
43 locale = locale.lower()
44 # Ignore one letter locale mappings (except for 'c')
45 if len(locale) == 1 and locale != 'c':
46 continue
47 # Normalize encoding, if given
48 if '.' in locale:
49 lang, encoding = locale.split('.')[:2]
50 encoding = encoding.replace('-', '')
51 encoding = encoding.replace('_', '')
52 locale = lang + '.' + encoding
53 data[locale] = alias
54 return data
55
56def parse_glibc_supported(filename):
57

Callers 1

makelocalealias.pyFile · 0.70

Calls 7

listFunction · 0.85
stripMethod · 0.80
partitionMethod · 0.80
openFunction · 0.50
splitMethod · 0.45
lowerMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected