summaryrefslogtreecommitdiff
path: root/Tools/i18n
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-10-02 10:38:12 +0300
committerSerhiy Storchaka <storchaka@gmail.com>2014-10-02 10:38:12 +0300
commit9403105c1d0758697c3c79a7421c0f6872fccae3 (patch)
treef91b552c6556b0d8920cd55e7bc7e41d026f97bc /Tools/i18n
parentcc7f36e1c2cb6865100f3cc6d400c1780f7f9ada (diff)
downloadcpython-9403105c1d0758697c3c79a7421c0f6872fccae3.tar.gz
Issue #20079: makelocalealias.py now supports installed SUPPORTED file,
not only source SUPPORTED file in glibc sources tree.
Diffstat (limited to 'Tools/i18n')
-rwxr-xr-xTools/i18n/makelocalealias.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/Tools/i18n/makelocalealias.py b/Tools/i18n/makelocalealias.py
index 25cb337b96..c7ecacec38 100755
--- a/Tools/i18n/makelocalealias.py
+++ b/Tools/i18n/makelocalealias.py
@@ -10,8 +10,10 @@ import locale
import sys
_locale = locale
-# Location of the alias file
+# Location of the X11 alias file.
LOCALE_ALIAS = '/usr/share/X11/locale/locale.alias'
+# Location of the glibc SUPPORTED locales file.
+SUPPORTED = '/usr/share/i18n/SUPPORTED'
def parse(filename):
@@ -59,10 +61,12 @@ def parse_glibc_supported(filename):
continue
if line[:1] == '#':
continue
- if '/' not in line:
- continue
+ line = line.replace('/', ' ').strip()
line = line.rstrip('\\').rstrip()
- alias, _, alias_encoding = line.partition('/')
+ words = line.split()
+ if len(words) != 2:
+ continue
+ alias, alias_encoding = words
# Lower-case locale
locale = alias.lower()
# Normalize encoding, if given
@@ -125,13 +129,13 @@ if __name__ == '__main__':
parser.add_argument('--locale-alias', default=LOCALE_ALIAS,
help='location of the X11 alias file '
'(default: %a)' % LOCALE_ALIAS)
- parser.add_argument('--glibc-supported',
- help='location of the glibc SUPPORTED locales file')
+ parser.add_argument('--glibc-supported', default=SUPPORTED,
+ help='location of the glibc SUPPORTED locales file '
+ '(default: %a)' % SUPPORTED)
args = parser.parse_args()
data = locale.locale_alias.copy()
- if args.glibc_supported:
- data.update(parse_glibc_supported(args.glibc_supported))
+ data.update(parse_glibc_supported(args.glibc_supported))
data.update(parse(args.locale_alias))
while True:
# Repeat optimization while the size is decreased.