Ignore:
Timestamp:
Mar 19, 2014, 11:31:01 PM (11 years ago)
Author:
dmik
Message:

python: Merge vendor 2.7.6 to trunk.

Location:
python/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • python/trunk

  • python/trunk/Tools/i18n/makelocalealias.py

    r2 r391  
    1010
    1111# Location of the alias file
    12 LOCALE_ALIAS = '/usr/lib/X11/locale/locale.alias'
     12LOCALE_ALIAS = '/usr/share/X11/locale/locale.alias'
    1313
    1414def parse(filename):
  • python/trunk/Tools/i18n/msgfmt.py

    r2 r391  
    2626"""
    2727
     28import os
    2829import sys
    29 import os
     30import ast
    3031import getopt
    3132import struct
     
    138139            continue
    139140        # Now we are in a msgid section, output previous section
    140         if l.startswith('msgid'):
     141        if l.startswith('msgid') and not l.startswith('msgid_plural'):
    141142            if section == STR:
    142143                add(msgid, msgstr, fuzzy)
     
    144145            l = l[5:]
    145146            msgid = msgstr = ''
     147            is_plural = False
     148        # This is a message with plural forms
     149        elif l.startswith('msgid_plural'):
     150            if section != ID:
     151                print >> sys.stderr, 'msgid_plural not preceded by msgid on %s:%d' %\
     152                    (infile, lno)
     153                sys.exit(1)
     154            l = l[12:]
     155            msgid += '\0' # separator of singular and plural
     156            is_plural = True
    146157        # Now we are in a msgstr section
    147158        elif l.startswith('msgstr'):
    148159            section = STR
    149             l = l[6:]
     160            if l.startswith('msgstr['):
     161                if not is_plural:
     162                    print >> sys.stderr, 'plural without msgid_plural on %s:%d' %\
     163                        (infile, lno)
     164                    sys.exit(1)
     165                l = l.split(']', 1)[1]
     166                if msgstr:
     167                    msgstr += '\0' # Separator of the various plural forms
     168            else:
     169                if is_plural:
     170                    print >> sys.stderr, 'indexed msgstr required for plural on  %s:%d' %\
     171                        (infile, lno)
     172                    sys.exit(1)
     173                l = l[6:]
    150174        # Skip empty lines
    151175        l = l.strip()
    152176        if not l:
    153177            continue
    154         # XXX: Does this always follow Python escape semantics?
    155         l = eval(l)
     178        l = ast.literal_eval(l)
    156179        if section == ID:
    157180            msgid += l
  • python/trunk/Tools/i18n/pygettext.py

    r2 r391  
    212212def make_escapes(pass_iso8859):
    213213    global escapes
     214    escapes = [chr(i) for i in range(256)]
    214215    if pass_iso8859:
    215216        # Allow iso-8859 characters to pass through so that e.g. 'msgid
     
    219220    else:
    220221        mod = 256
    221     for i in range(256):
    222         if 32 <= (i % mod) <= 126:
    223             escapes.append(chr(i))
    224         else:
    225             escapes.append("\\%03o" % i)
     222    for i in range(mod):
     223        if not(32 <= i <= 126):
     224            escapes[i] = "\\%03o" % i
    226225    escapes[ord('\\')] = '\\\\'
    227226    escapes[ord('\t')] = '\\t'
     
    600599
    601600    # calculate escapes
    602     make_escapes(options.escape)
     601    make_escapes(not options.escape)
    603602
    604603    # calculate all keywords
Note: See TracChangeset for help on using the changeset viewer.