Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

Location:
python/vendor/current/Tools
Files:
11 added
2 deleted
53 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Tools/README

    r2 r388  
    2121freeze          Create a stand-alone executable from a Python program.
    2222
     23gdb             Python code to be run inside gdb, to make it easier to
     24                debug Python itself (by David Malcolm).
     25
    2326i18n            Tools for internationalization. pygettext.py
    2427                parses Python source code and generates .pot files,
     
    2629                from a catalog in text format.
    2730
    28 modulator       Interactively generate boiler plate for an extension
    29                 module.  Works easiest if you have Tk.
    30 
    3131pynche          A Tkinter-based color editor.
    3232
    33 scripts         A number of useful single-file programs, e.g. tabnanny.py
    34                 (by Tim Peters), which checks for inconsistent mixing
    35                 of tabs and spaces.
     33scripts         A number of useful single-file programs, e.g. tabnanny.py
     34                by Tim Peters, which checks for inconsistent mixing of
     35                tabs and spaces, and 2to3, which converts Python 2 code
     36                to Python 3 code.
    3637
    3738unicode         Tools used to generate unicode database files for
  • python/vendor/current/Tools/buildbot/build-amd64.bat

    r2 r388  
    11@rem Used by the buildbot "compile" step.
     2set HOST_PYTHON="%CD%\PCbuild\amd64\python_d.exe"
    23cmd /c Tools\buildbot\external-amd64.bat
    34call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
  • python/vendor/current/Tools/buildbot/buildmsi.bat

    r2 r388  
    1212"%ProgramFiles%\HTML Help Workshop\hhc.exe" Doc\build\htmlhelp\python26a3.hhp
    1313
    14 @rem buold the MSI file
     14@rem build the MSI file
    1515cd PC
    1616nmake /f icons.mak
  • python/vendor/current/Tools/buildbot/clean-amd64.bat

    r2 r388  
    11@rem Used by the buildbot "clean" step.
    22call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64
    3 cd PCbuild
    43@echo Deleting .pyc/.pyo files ...
    54del /s Lib\*.pyc Lib\*.pyo
     5@echo Deleting test leftovers ...
     6rmdir /s /q build
     7cd PCbuild
    68vcbuild /clean pcbuild.sln "Release|x64"
    79vcbuild /clean pcbuild.sln "Debug|x64"
     10cd ..
  • python/vendor/current/Tools/buildbot/clean.bat

    r2 r388  
    33@echo Deleting .pyc/.pyo files ...
    44del /s Lib\*.pyc Lib\*.pyo
     5@echo Deleting test leftovers ...
     6rmdir /s /q build
    57cd PCbuild
    68vcbuild /clean pcbuild.sln "Release|Win32"
    79vcbuild /clean pcbuild.sln "Debug|Win32"
     10cd ..
  • python/vendor/current/Tools/buildbot/external-common.bat

    r2 r388  
    55@rem XXX: If you need to force the buildbots to start from a fresh environment, uncomment
    66@rem the following, check it in, then check it out, comment it out, then check it back in.
    7 @rem if exist bzip2-1.0.5 rd /s/q bzip2-1.0.5
     7@rem if exist bzip2-1.0.6 rd /s/q bzip2-1.0.6
    88@rem if exist tcltk rd /s/q tcltk
    99@rem if exist tcltk64 rd /s/q tcltk64
     
    1616@rem if exist db-4.4.20 rd /s/q db-4.4.20
    1717@rem if exist db-4.7.25.0 rd /s/q db-4.7.25.0
    18 @rem if exist openssl-0.9.8l rd /s/q openssl-0.9.8l
    19 @rem if exist sqlite-3.5.9 rd /s/q sqlite-3.5.9   
     18@rem if exist openssl-0.9.8y rd /s/q openssl-0.9.8y
     19@rem if exist sqlite-3.6.21 rd /s/q sqlite-3.6.21   
    2020
    2121@rem bzip
    22 if not exist bzip2-1.0.5 (
    23    rd /s/q bzip2-1.0.3
    24   svn export http://svn.python.org/projects/external/bzip2-1.0.5
     22if not exist bzip2-1.0.6 (
     23   rd /s/q bzip2-1.0.5
     24  svn export http://svn.python.org/projects/external/bzip2-1.0.6
    2525)
    2626
     
    3030
    3131@rem OpenSSL
    32 if not exist openssl-0.9.8l svn export http://svn.python.org/projects/external/openssl-0.9.8l
     32if not exist openssl-0.9.8y svn export http://svn.python.org/projects/external/openssl-0.9.8y
    3333
    3434@rem tcl/tk
     
    4040
    4141@rem sqlite3
    42 if not exist sqlite-3.5.9 (
     42if not exist sqlite-3.6.21 (
    4343  rd /s/q sqlite-source-3.3.4
    44   svn export http://svn.python.org/projects/external/sqlite-3.5.9
     44  svn export http://svn.python.org/projects/external/sqlite-3.6.21
    4545)
  • python/vendor/current/Tools/buildbot/test-amd64.bat

    r2 r388  
    11@rem Used by the buildbot "test" step.
    22cd PCbuild
    3 call rt.bat -q -d -x64 -uall -rw
     3call rt.bat -d -q -x64 -uall -rwW %1 %2 %3 %4 %5 %6 %7 %8 %9
  • python/vendor/current/Tools/buildbot/test.bat

    r2 r388  
    11@rem Used by the buildbot "test" step.
    22cd PCbuild
    3 call rt.bat -d -q -uall -rw
     3call rt.bat -d -q -uall -rwW %1 %2 %3 %4 %5 %6 %7 %8 %9
  • python/vendor/current/Tools/compiler/astgen.py

    r2 r388  
    106106    def _gen_init(self, buf):
    107107        if self.args:
    108             print >> buf, "    def __init__(self, %s, lineno=None):" % self.args
     108            argtuple = '(' in self.args
     109            args = self.args if not argtuple else ''.join(self.argnames)
     110            print >> buf, "    def __init__(self, %s, lineno=None):" % args
    109111        else:
    110112            print >> buf, "    def __init__(self, lineno=None):"
    111113        if self.argnames:
    112             for name in self.argnames:
    113                 print >> buf, "        self.%s = %s" % (name, name)
     114            if argtuple:
     115                for idx, name in enumerate(self.argnames):
     116                    print >> buf, "        self.%s = %s[%s]" % (name, args, idx)
     117            else:
     118                for name in self.argnames:
     119                    print >> buf, "        self.%s = %s" % (name, name)
    114120        print >> buf, "        self.lineno = lineno"
    115121        # Copy the lines in self.init, indented four spaces.  The rstrip()
  • python/vendor/current/Tools/faqwiz/faqw.py

    r2 r388  
    1 #! /usr/local/bin/python
     1#!/usr/bin/env python
    22
    33"""FAQ wizard bootstrap."""
  • python/vendor/current/Tools/freeze/checkextensions_win32.py

    r2 r388  
    44are needed (primarily to toggle the behavior of "public" symbols.
    55
    6 I dont consider it worth parsing the MSVC makefiles for compiler options.  Even if
     6I don't consider it worth parsing the MSVC makefiles for compiler options.  Even if
    77we get it just right, a specific freeze application may have specific compiler
    88options anyway (eg, to enable or disable specific functionality)
    99
    10 So my basic stragtegy is:
     10So my basic strategy is:
    1111
    1212* Have some Windows INI files which "describe" one or more extension modules.
     
    1515* This description can include:
    1616  - The MSVC .dsp file for the extension.  The .c source file names
    17     are extraced from there.
     17    are extracted from there.
    1818  - Specific compiler/linker options
    1919  - Flag to indicate if Unicode compilation is expected.
  • python/vendor/current/Tools/freeze/makeconfig.py

    r2 r388  
    11import re
    2 
     2import sys
    33
    44# Write the config.c file
    55
    6 never = ['marshal', '__main__', '__builtin__', 'sys', 'exceptions']
     6never = ['marshal', '__main__', '__builtin__', 'sys', 'exceptions', '_warnings']
    77
    88def makeconfig(infp, outfp, modules, with_ifdef=0):
     
    3939
    4040def test():
    41     import sys
    4241    if not sys.argv[3:]:
    4342        print 'usage: python makeconfig.py config.c.in outputfile',
  • python/vendor/current/Tools/freeze/makefreeze.py

    r2 r388  
    6363    outfp.write('\n')
    6464    # The following modules have a NULL code pointer, indicating
    65     # that the prozen program should not search for them on the host
     65    # that the frozen program should not search for them on the host
    6666    # system. Importing them will *always* raise an ImportError.
    6767    # The zero value size is never used.
  • python/vendor/current/Tools/freeze/winmakemakefile.py

    r2 r388  
    135135
    136136    print "$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext)
    137     print "\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags),
    138     print "\t$(OBJS) \\"
    139     print "\t$(LIBS) \\"
    140     print "\t$(ADDN_LINK_FILES) \\"
    141     print "\t$(pythonlib) $(lcustom) $(l_debug)\\"
     137    print "\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags), "@<<"
     138    print "\t$(OBJS)"
     139    print "\t$(LIBS)"
     140    print "\t$(ADDN_LINK_FILES)"
     141    print "\t$(pythonlib) $(lcustom) $(l_debug)"
    142142    print "\t$(resources)"
     143    print "<<"
    143144    print
    144145    print "clean:"
  • python/vendor/current/Tools/i18n/makelocalealias.py

    r2 r388  
    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/vendor/current/Tools/i18n/msgfmt.py

    r2 r388  
    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/vendor/current/Tools/i18n/pygettext.py

    r2 r388  
    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
  • python/vendor/current/Tools/msi/msi.py

    r2 r388  
    22# (C) 2003 Martin v. Loewis
    33# See "FOO" in comments refers to MSDN sections with the title FOO.
    4 import msilib, schema, sequence, os, glob, time, re, shutil
     4import msilib, schema, sequence, os, glob, time, re, shutil, zipfile
    55from msilib import Feature, CAB, Directory, Dialog, Binary, add_data
    66import uisample
     
    88from distutils.spawn import find_executable
    99from uuids import product_codes
     10import tempfile
    1011
    1112# Settings can be overridden in config.py below
     
    2930# msvcrt version
    3031MSVCR = "90"
     32# Name of certificate in default store to sign MSI with
     33certname = None
     34# Make a zip file containing the PDB files for this build?
     35pdbzip = True
    3136
    3237try:
     
    112117    "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}",
    113118    "26":"{34ebecac-f046-4e1c-b0e3-9bac3cdaacfa}",
     119    "27":"{4fe21c76-1760-437b-a2f2-99909130a175}",
    114120    } [major+minor]
    115121
    116122# Compute the name that Sphinx gives to the docfile
    117123docfile = ""
    118 if micro:
    119     docfile = str(micro)
     124if int(micro):
     125    docfile = micro
    120126if level < 0xf:
    121     docfile += '%x%s' % (level, serial)
     127    if level == 0xC:
     128        docfile += "rc%s" % (serial,)
     129    else:
     130        docfile += '%x%s' % (level, serial)
    122131docfile = 'python%s%s%s.chm' % (major, minor, docfile)
    123132
     
    168177have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib)
    169178
    170 # Determine the target architechture
     179# Determine the target architecture
     180if os.system("nmake /nologo /c /f msisupport.mak") != 0:
     181    raise RuntimeError("'nmake /f msisupport.mak' failed")
    171182dll_path = os.path.join(srcdir, PCBUILD, dll_file)
    172183msilib.set_arch_from_file(dll_path)
     
    215226    # sequence is the set of standard sequences
    216227    # (ui/execute, admin/advt/install)
    217     db = msilib.init_database("python-%s%s.msi" % (full_current_version, msilib.arch_ext),
     228    msiname = "python-%s%s.msi" % (full_current_version, msilib.arch_ext)
     229    db = msilib.init_database(msiname,
    218230                  schema, ProductName="Python "+full_current_version+productsuffix,
    219231                  ProductCode=product_code,
     
    238250                             ])
    239251    db.Commit()
    240     return db
     252    return db, msiname
    241253
    242254def remove_old_versions(db):
     
    365377    # the installed/uninstalled state according to both the
    366378    # Extensions and TclTk features.
    367     if os.system("nmake /nologo /c /f msisupport.mak") != 0:
    368         raise "'nmake /f msisupport.mak' failed"
    369379    add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))])
    370380    # See "Custom Action Type 1"
     
    399409             ])
    400410
    401     compileargs = r'-Wi "[TARGETDIR]Lib\compileall.py" -f -x bad_coding|badsyntax|site-packages|py3_ "[TARGETDIR]Lib"'
     411    compileargs = r'-Wi "[TARGETDIR]Lib\compileall.py" -f -x "bad_coding|badsyntax|site-packages|py3_" "[TARGETDIR]Lib"'
    402412    lib2to3args = r'-c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"'
    403413    # See "CustomAction Table"
     
    486496    exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title,
    487497                         "Finish", "Finish", "Finish")
    488     exit_dialog.title("Completing the [ProductName] Installer")
     498    exit_dialog.title("Complete the [ProductName] Installer")
    489499    exit_dialog.back("< Back", "Finish", active = 0)
    490500    exit_dialog.cancel("Cancel", "Back", active = 0)
     
    496506
    497507    c = exit_dialog.text("warning", 135, 200, 220, 40, 0x30003,
    498             "{\\VerdanaRed9}Warning: Python 2.5.x is the last "
    499             "Python release for Windows 9x.")
    500     c.condition("Hide", "NOT Version9X")
     508            "{\\VerdanaRed9}Warning: Python 3.3.0 is the last "
     509            "Python release for Windows 2000.")
     510    c.condition("Hide", "VersionNT > 500")
    501511
    502512    exit_dialog.text("Description", 135, 235, 220, 20, 0x30003,
     
    10021012            lib.add_file("cfgparser.1")
    10031013            lib.add_file("sgml_input.html")
    1004             lib.add_file("test.xml")
    1005             lib.add_file("test.xml.out")
    10061014            lib.add_file("testtar.tar")
    10071015            lib.add_file("test_difflib_expect.html")
     
    10121020            lib.glob("*.pem")
    10131021            lib.glob("*.pck")
    1014             lib.add_file("readme.txt", src="README")
    10151022            lib.add_file("zipdir.zip")
     1023        if dir=='tests' and parent.physical=='distutils':
     1024            lib.add_file("Setup.sample")
    10161025        if dir=='decimaltestdata':
    10171026            lib.glob("*.decTest")
     1027        if dir=='xmltestdata':
     1028            lib.glob("*.xml")
     1029            lib.add_file("test.xml.out")
    10181030        if dir=='output':
    10191031            lib.glob("test_*")
     
    11881200        tcl_verbs=[
    11891201             ("py.IDLE", -1, pat % (testprefix, "", ewi), "",
    1190               r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
     1202              r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -e "%1"',
    11911203              "REGISTRY.tcl"),
    11921204             ("pyw.IDLE", -1, pat % (testprefix, "NoCon", ewi), "",
    1193               r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -n -e "%1"',
     1205              r'"[TARGETDIR]pythonw.exe" "[TARGETDIR]Lib\idlelib\idle.pyw" -e "%1"',
    11941206              "REGISTRY.tcl"),
    11951207        ]
     
    12901302    db.Commit()
    12911303
    1292 db = build_database()
     1304def build_pdbzip():
     1305    pdbexclude = ['kill_python.pdb', 'make_buildinfo.pdb',
     1306                  'make_versioninfo.pdb']
     1307    path = "python-%s%s-pdb.zip" % (full_current_version, msilib.arch_ext)
     1308    pdbzip = zipfile.ZipFile(path, 'w')
     1309    for f in glob.glob1(os.path.join(srcdir, PCBUILD), "*.pdb"):
     1310        if f not in pdbexclude and not f.endswith('_d.pdb'):
     1311            pdbzip.write(os.path.join(srcdir, PCBUILD, f), f)
     1312    pdbzip.close()
     1313
     1314db,msiname = build_database()
    12931315try:
    12941316    add_features(db)
     
    13001322finally:
    13011323    del db
     1324
     1325# Merge CRT into MSI file. This requires the database to be closed.
     1326mod_dir = os.path.join(os.environ["ProgramFiles"], "Common Files", "Merge Modules")
     1327if msilib.Win64:
     1328    modules = ["Microsoft_VC90_CRT_x86_x64.msm", "policy_9_0_Microsoft_VC90_CRT_x86_x64.msm"]
     1329else:
     1330    modules = ["Microsoft_VC90_CRT_x86.msm","policy_9_0_Microsoft_VC90_CRT_x86.msm"]
     1331
     1332for i, n in enumerate(modules):
     1333    modules[i] = os.path.join(mod_dir, n)
     1334
     1335def merge(msi, feature, rootdir, modules):
     1336    cab_and_filecount = []
     1337    # Step 1: Merge databases, extract cabfiles
     1338    m = msilib.MakeMerge2()
     1339    m.OpenLog("merge.log")
     1340    m.OpenDatabase(msi)
     1341    for module in modules:
     1342        print module
     1343        m.OpenModule(module,0)
     1344        m.Merge(feature, rootdir)
     1345        print "Errors:"
     1346        for e in m.Errors:
     1347            print e.Type, e.ModuleTable, e.DatabaseTable
     1348            print "   Modkeys:",
     1349            for s in e.ModuleKeys: print s,
     1350            print
     1351            print "   DBKeys:",
     1352            for s in e.DatabaseKeys: print s,
     1353            print
     1354        cabname = tempfile.mktemp(suffix=".cab")
     1355        m.ExtractCAB(cabname)
     1356        cab_and_filecount.append((cabname, len(m.ModuleFiles)))
     1357        m.CloseModule()
     1358    m.CloseDatabase(True)
     1359    m.CloseLog()
     1360
     1361    # Step 2: Add CAB files
     1362    i = msilib.MakeInstaller()
     1363    db = i.OpenDatabase(msi, constants.msiOpenDatabaseModeTransact)
     1364
     1365    v = db.OpenView("SELECT LastSequence FROM Media")
     1366    v.Execute(None)
     1367    maxmedia = -1
     1368    while 1:
     1369        r = v.Fetch()
     1370        if not r: break
     1371        seq = r.IntegerData(1)
     1372        if seq > maxmedia:
     1373            maxmedia = seq
     1374    print "Start of Media", maxmedia
     1375
     1376    for cabname, count in cab_and_filecount:
     1377        stream = "merged%d" % maxmedia
     1378        msilib.add_data(db, "Media",
     1379                [(maxmedia+1, maxmedia+count, None, "#"+stream, None, None)])
     1380        msilib.add_stream(db, stream,  cabname)
     1381        os.unlink(cabname)
     1382        maxmedia += count
     1383    # The merge module sets ALLUSERS to 1 in the property table.
     1384    # This is undesired; delete that
     1385    v = db.OpenView("DELETE FROM Property WHERE Property='ALLUSERS'")
     1386    v.Execute(None)
     1387    v.Close()
     1388    db.Commit()
     1389
     1390merge(msiname, "SharedCRT", "TARGETDIR", modules)
     1391
     1392# certname (from config.py) should be (a substring of)
     1393# the certificate subject, e.g. "Python Software Foundation"
     1394if certname:
     1395    os.system('signtool sign /n "%s" '
     1396      '/t http://timestamp.verisign.com/scripts/timestamp.dll '
     1397      '/d "Python %s" '
     1398      '%s' % (certname, full_current_version, msiname))
     1399
     1400if pdbzip:
     1401    build_pdbzip()
  • python/vendor/current/Tools/msi/msilib.py

    r2 r388  
    306306    # Fill the validation table
    307307    add_data(db, "_Validation", schema._Validation_records)
    308     # Initialize the summary information, allowing atmost 20 properties
     308    # Initialize the summary information, allowing at most 20 properties
    309309    si = db.GetSummaryInformation(20)
    310310    si.SetProperty(PID_TITLE, "Installation Database")
     
    517517    def add_file(self, file, src=None, version=None, language=None):
    518518        """Add a file to the current component of the directory, starting a new one
    519         one if there is no current component. By default, the file name in the source
     519        if there is no current component. By default, the file name in the source
    520520        and the file table will be identical. If the src file is specified, it is
    521521        interpreted relative to the current directory. Optionally, a version and a
  • python/vendor/current/Tools/msi/msisupport.c

    r2 r388  
    88static UINT debug(MSIHANDLE hInstall, LPCSTR msg)
    99{
    10         MSIHANDLE hRec = MsiCreateRecord(1);
    11         if (!hRec || MsiRecordSetStringA(hRec, 1, msg) != ERROR_SUCCESS) {
    12                 return ERROR_INSTALL_FAILURE;
    13         }
    14         MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hRec);
    15         MsiCloseHandle(hRec);
    16         return ERROR_SUCCESS;
     10    MSIHANDLE hRec = MsiCreateRecord(1);
     11    if (!hRec || MsiRecordSetStringA(hRec, 1, msg) != ERROR_SUCCESS) {
     12        return ERROR_INSTALL_FAILURE;
     13    }
     14    MsiProcessMessage(hInstall, INSTALLMESSAGE_INFO, hRec);
     15    MsiCloseHandle(hRec);
     16    return ERROR_SUCCESS;
    1717}
    1818
     
    2323{
    2424#define PSIZE 1024
    25         WCHAR wpath[PSIZE];
    26         char path[PSIZE];
    27         UINT result;
    28         DWORD size = PSIZE;
    29         DWORD attributes;
     25    WCHAR wpath[PSIZE];
     26    char path[PSIZE];
     27    UINT result;
     28    DWORD size = PSIZE;
     29    DWORD attributes;
    3030
    31        
    32         result = MsiGetPropertyW(hInstall, L"TARGETDIR", wpath, &size);
    33         if (result != ERROR_SUCCESS)
    34                 return result;
    35         wpath[size] = L'\0';
    36         path[size] = L'\0';
    3731
    38         attributes = GetFileAttributesW(wpath);
    39         if (attributes == INVALID_FILE_ATTRIBUTES ||
    40                 !(attributes & FILE_ATTRIBUTE_DIRECTORY))
    41         {
    42                 return MsiSetPropertyA(hInstall, "TargetExists", "0");
    43         } else {
    44                 return MsiSetPropertyA(hInstall, "TargetExists", "1");
    45         }
     32    result = MsiGetPropertyW(hInstall, L"TARGETDIR", wpath, &size);
     33    if (result != ERROR_SUCCESS)
     34        return result;
     35    wpath[size] = L'\0';
     36    path[size] = L'\0';
     37
     38    attributes = GetFileAttributesW(wpath);
     39    if (attributes == INVALID_FILE_ATTRIBUTES ||
     40        !(attributes & FILE_ATTRIBUTE_DIRECTORY))
     41    {
     42        return MsiSetPropertyA(hInstall, "TargetExists", "0");
     43    } else {
     44        return MsiSetPropertyA(hInstall, "TargetExists", "1");
     45    }
    4646}
    4747
     
    5252UINT __declspec(dllexport) __stdcall UpdateEditIDLE(MSIHANDLE hInstall)
    5353{
    54         INSTALLSTATE ext_old, ext_new, tcl_old, tcl_new, reg_new;
    55         UINT result;
     54    INSTALLSTATE ext_old, ext_new, tcl_old, tcl_new, reg_new;
     55    UINT result;
    5656
    57         result = MsiGetFeatureStateA(hInstall, "Extensions", &ext_old, &ext_new);
    58         if (result != ERROR_SUCCESS)
    59                 return result;
    60         result = MsiGetFeatureStateA(hInstall, "TclTk", &tcl_old, &tcl_new);
    61         if (result != ERROR_SUCCESS)
    62                 return result;
     57    result = MsiGetFeatureStateA(hInstall, "Extensions", &ext_old, &ext_new);
     58    if (result != ERROR_SUCCESS)
     59        return result;
     60    result = MsiGetFeatureStateA(hInstall, "TclTk", &tcl_old, &tcl_new);
     61    if (result != ERROR_SUCCESS)
     62        return result;
    6363
    64         /* If the current state is Absent, and the user did not select
    65            the feature in the UI, Installer apparently sets the "selected"
    66            state to unknown. Update it to the current value, then. */
    67         if (ext_new == INSTALLSTATE_UNKNOWN)
    68                 ext_new = ext_old;
    69         if (tcl_new == INSTALLSTATE_UNKNOWN)
    70                 tcl_new = tcl_old;
     64    /* If the current state is Absent, and the user did not select
     65       the feature in the UI, Installer apparently sets the "selected"
     66       state to unknown. Update it to the current value, then. */
     67    if (ext_new == INSTALLSTATE_UNKNOWN)
     68        ext_new = ext_old;
     69    if (tcl_new == INSTALLSTATE_UNKNOWN)
     70        tcl_new = tcl_old;
    7171
    72         // XXX consider current state of REGISTRY.tcl?
    73         if (((tcl_new == INSTALLSTATE_LOCAL) ||
    74                 (tcl_new == INSTALLSTATE_SOURCE) ||
    75                 (tcl_new == INSTALLSTATE_DEFAULT)) &&
    76                 ((ext_new == INSTALLSTATE_LOCAL) ||
    77                 (ext_new == INSTALLSTATE_SOURCE) ||
    78                 (ext_new == INSTALLSTATE_DEFAULT))) {
    79                 reg_new = INSTALLSTATE_SOURCE;
    80         } else {
    81                 reg_new = INSTALLSTATE_ABSENT;
    82         }
    83         result = MsiSetComponentStateA(hInstall, "REGISTRY.tcl", reg_new);
    84         return result;
     72    // XXX consider current state of REGISTRY.tcl?
     73    if (((tcl_new == INSTALLSTATE_LOCAL) ||
     74            (tcl_new == INSTALLSTATE_SOURCE) ||
     75            (tcl_new == INSTALLSTATE_DEFAULT)) &&
     76        ((ext_new == INSTALLSTATE_LOCAL) ||
     77        (ext_new == INSTALLSTATE_SOURCE) ||
     78        (ext_new == INSTALLSTATE_DEFAULT))) {
     79        reg_new = INSTALLSTATE_SOURCE;
     80    } else {
     81        reg_new = INSTALLSTATE_ABSENT;
     82    }
     83    result = MsiSetComponentStateA(hInstall, "REGISTRY.tcl", reg_new);
     84    return result;
    8585}
    8686
    87 BOOL APIENTRY DllMain(HANDLE hModule, 
    88                       DWORD  ul_reason_for_call, 
     87BOOL APIENTRY DllMain(HANDLE hModule,
     88                      DWORD  ul_reason_for_call,
    8989                      LPVOID lpReserved)
    9090{
  • python/vendor/current/Tools/msi/uuids.py

    r2 r388  
    88# so people can refer to them.
    99product_codes = {
    10     '2.4.101': '{0e9b4d8e-6cda-446e-a208-7b92f3ddffa0}', # 2.4a1, released as a snapshot
    11     '2.4.102': '{1b998745-4901-4edb-bc52-213689e1b922}', # 2.4a2
    12     '2.4.103': '{33fc8bd2-1e8f-4add-a40a-ade2728d5942}', # 2.4a3
    13     '2.4.111': '{51a7e2a8-2025-4ef0-86ff-e6aab742d1fa}', # 2.4b1
    14     '2.4.112': '{4a5e7c1d-c659-4fe3-b8c9-7c65bd9c95a5}', # 2.4b2
    15     '2.4.121': '{75508821-a8e9-40a8-95bd-dbe6033ddbea}', # 2.4c1
    16     '2.4.122': '{83a9118b-4bdd-473b-afc3-bcb142feca9e}', # 2.4c2
    17     '2.4.150': '{82d9302e-f209-4805-b548-52087047483a}', # 2.4.0
    18     '2.4.1121':'{be027411-8e6b-4440-a29b-b07df0690230}', # 2.4.1c1
    19     '2.4.1122':'{02818752-48bf-4074-a281-7a4114c4f1b1}', # 2.4.1c2
    20     '2.4.1150':'{4d4f5346-7e4a-40b5-9387-fdb6181357fc}', # 2.4.1
    21     '2.4.2121':'{5ef9d6b6-df78-45d2-ab09-14786a3c5a99}', # 2.4.2c1
    22     '2.4.2150':'{b191e49c-ea23-43b2-b28a-14e0784069b8}', # 2.4.2
    23     '2.4.3121':'{f669ed4d-1dce-41c4-9617-d985397187a1}', # 2.4.3c1
    24     '2.4.3150':'{75e71add-042c-4f30-bfac-a9ec42351313}', # 2.4.3
    25     '2.4.4121':'{cd2862db-22a4-4688-8772-85407ea21550}', # 2.4.4c1
    26     '2.4.4150':'{60e2c8c9-6cf3-4b1a-9618-e304946c94e6}', # 2.4.4
    2710    '2.5.101': '{bc14ce3e-5e72-4a64-ac1f-bf59a571898c}', # 2.5a1
    2811    '2.5.102': '{5eed51c1-8e9d-4071-94c5-b40de5d49ba5}', # 2.5a2
     
    5942    '2.6.5122':'{fa227b76-0671-4dc6-b826-c2ff2a70dfd5}', # 2.6.5c2
    6043    '2.6.5150':'{4723f199-fa64-4233-8e6e-9fccc95a18ee}', # 2.6.5
     44    '2.7.101': '{eca1bbef-432c-49ae-a667-c213cc7bbf22}', # 2.7a1
     45    '2.7.102': '{21ce16ed-73c4-460d-9b11-522f417b2090}', # 2.7a2
     46    '2.7.103': '{6e7dbd55-ba4a-48ac-a688-6c75db4d7500}', # 2.7a3
     47    '2.7.104': '{ee774ba3-74a5-48d9-b425-b35a287260c8}', # 2.7a4
     48    '2.7.111': '{9cfd9ec7-a9c7-4980-a1c6-054fc6493eb3}', # 2.7b1
     49    '2.7.112': '{9a72faf6-c304-4165-8595-9291ff30cac6}', # 2.7b2
     50    '2.7.121': '{f530c94a-dd53-4de9-948e-b632b9cb48d2}', # 2.7c1
     51    '2.7.122': '{f80905d2-dd8d-4b8e-8a40-c23c93dca07d}', # 2.7c2
     52    '2.7.150': '{20c31435-2a0a-4580-be8b-ac06fc243ca4}', # 2.7.0
     53    '2.7.1121':'{60a4036a-374c-4fd2-84b9-bfae7db03931}', # 2.7.1rc1
     54    '2.7.1122':'{5965e7d1-5584-4de9-b13a-694e0b2ee3a6}', # 2.7.1rc2
     55    '2.7.1150':'{32939827-d8e5-470a-b126-870db3c69fdf}', # 2.7.1
     56    '2.7.2121':'{B2E1F06E-F719-4786-972A-488A336EB2A0}', # 2.7.2rc1
     57    '2.7.2150':'{2E295B5B-1AD4-4d36-97C2-A316084722CF}', # 2.7.2
     58    '2.7.3121':'{1ACB88BF-1425-4f11-B664-6C89A3D7699C}', # 2.7.3rc1
     59    '2.7.3122':'{B12311BE-6364-4b2a-A49A-551EEE10F3E4}', # 2.7.3rc2
     60    '2.7.3150':'{C0C31BCC-56FB-42a7-8766-D29E1BD74C7C}', # 2.7.3
     61    '2.7.4121':'{47F45F45-72D7-4e54-AF41-26767EDE95CF}', # 2.7.4rc1
     62    '2.7.4150':'{84ADC96C-B7E0-4938-9D6E-2B640D5DA224}', # 2.7.4
     63    '2.7.5150':'{DBDD570E-0952-475f-9453-AB88F3DD5659}', # 2.7.5
     64    '2.7.6121':'{D1EBC07F-A7B1-4163-83DB-AE813CEF392F}', # 2.7.6rc1
     65    '2.7.6150':'{C3CC4DF5-39A5-4027-B136-2B3E1F5AB6E2}', # 2.7.6
    6166}
  • python/vendor/current/Tools/pybench/CommandLine.py

    r2 r388  
    459459            except AttributeError:
    460460                if value == '':
    461                     # count the number of occurances
     461                    # count the number of occurrences
    462462                    if values.has_key(optionname):
    463463                        values[optionname] = values[optionname] + 1
  • python/vendor/current/Tools/pybench/README

    r2 r388  
    44________________________________________________________________________
    55
    6      Extendable suite of of low-level benchmarks for measuring
     6     Extendable suite of low-level benchmarks for measuring
    77          the performance of the Python implementation
    88                 (interpreter, compiler or VM).
  • python/vendor/current/Tools/pybench/Setup.py

    r2 r388  
    1 #!python
     1#!/usr/bin/env python
    22
    33# Setup file for pybench
  • python/vendor/current/Tools/pybench/pybench.py

    r2 r388  
    231231            self.calibration_runs = calibration_runs
    232232        if timer is not None:
    233             timer = timer
     233            self.timer = timer
    234234
    235235        # Init variables
     
    279279                pass
    280280            t = timer() - t
    281             prep_times.append(t)
     281            prep_times.append(t / CALIBRATION_LOOPS)
    282282        min_prep_time = min(prep_times)
    283283        if _debug:
     
    690690                if (benchmarks_compatible and
    691691                    test.compatible(other)):
    692                     # Both benchmark and tests are comparible
     692                    # Both benchmark and tests are comparable
    693693                    min_diff = ((min_time * self.warp) /
    694694                                (other_min_time * other.warp) - 1.0)
     
    704704                        avg_diff = '%+5.1f%%' % (avg_diff * PERCENT)
    705705                else:
    706                     # Benchmark or tests are not comparible
     706                    # Benchmark or tests are not comparable
    707707                    min_diff, avg_diff = 'n/a', 'n/a'
    708708                    tests_compatible = 0
  • python/vendor/current/Tools/pybench/systimes.py

    r2 r388  
    66    This module implements various different strategies for measuring
    77    performance timings. It tries to choose the best available method
    8     based on the platforma and available tools.
     8    based on the platform and available tools.
    99
    1010    On Windows, it is recommended to have the Mark Hammond win32
  • python/vendor/current/Tools/pynche/DetailsViewer.py

    r2 r388  
    2727        would have the value 7.
    2828
    29     Preseve Distance
     29    Preserve Distance
    3030        When the increment or decrement would send any of the tied variations
    3131        out of bounds, all tied variations are wrapped as one, so as to
  • python/vendor/current/Tools/scripts/2to3

    r2 r388  
    11#!/usr/bin/env python
     2import sys
    23from lib2to3.main import main
    3 import sys
    4 import os
    54
    65sys.exit(main("lib2to3.fixes"))
  • python/vendor/current/Tools/scripts/README

    r2 r388  
    55See also the Demo/scripts directory!
    66
     7analyze_dxp.py          Analyzes the result of sys.getdxp()
    78byext.py                Print lines/words/chars stats of files by extension
    89byteyears.py            Print product of a file's size and age
     
    1920dutree.py               Format du(1) output as a tree sorted by size
    2021eptags.py               Create Emacs TAGS file for Python modules
    21 finddiv.py              A grep-like tool that looks for division operators.
     22find_recursionlimit.py  Find the maximum recursion limit on this machine
     23finddiv.py              A grep-like tool that looks for division operators
    2224findlinksto.py          Recursively find symbolic links to a given path prefix
    2325findnocoding.py         Find source files which need an encoding declaration
     
    2830fixps.py                Fix Python scripts' first line (if #!)
    2931ftpmirror.py            FTP mirror script
    30 google.py               Open a webbrowser with Google.
    31 gprof2html.py           Transform gprof(1) output into useful HTML.
     32google.py               Open a webbrowser with Google
     33gprof2html.py           Transform gprof(1) output into useful HTML
    3234h2py.py                 Translate #define's into Python assignments
    3335hotshotmain.py          Main program to run script under control of hotshot
     
    5658reindent.py             Change .py files to use 4-space indents.
    5759rgrep.py                Reverse grep through a file (useful for big logfiles)
    58 setup.py                Install all scripts listed here.
     60serve.py                Small wsgiref-based web server, used in make serve in Doc
     61setup.py                Install all scripts listed here
    5962suff.py                 Sort a list of files by suffix
    60 svneol.py               Sets svn:eol-style on all files in directory.
     63svneol.py               Sets svn:eol-style on all files in directory
    6164texcheck.py             Validate Python LaTeX formatting (Raymond Hettinger)
    6265texi2html.py            Convert GNU texinfo files into HTML
  • python/vendor/current/Tools/scripts/byext.py

    r2 r388  
    22
    33"""Show file statistics by extension."""
     4
     5from __future__ import print_function
    46
    57import os
     
    2426        self.addstats("<dir>", "dirs", 1)
    2527        try:
    26             names = os.listdir(dir)
    27         except os.error, err:
     28            names = sorted(os.listdir(dir))
     29        except os.error as err:
    2830            sys.stderr.write("Can't list %s: %s\n" % (dir, err))
    2931            self.addstats("<dir>", "unlistable", 1)
    3032            return
    31         names.sort()
    3233        for name in names:
    3334            if name.startswith(".#"):
     
    5455        try:
    5556            f = open(filename, "rb")
    56         except IOError, err:
     57        except IOError as err:
    5758            sys.stderr.write("Can't open %s: %s\n" % (filename, err))
    5859            self.addstats(ext, "unopenable", 1)
     
    6162        f.close()
    6263        self.addstats(ext, "bytes", len(data))
    63         if '\0' in data:
     64        if b'\0' in data:
    6465            self.addstats(ext, "binary", 1)
    6566            return
     
    7879
    7980    def report(self):
    80         exts = self.stats.keys()
    81         exts.sort()
     81        exts = sorted(self.stats.keys())
    8282        # Get the column keys
    8383        columns = {}
    8484        for ext in exts:
    8585            columns.update(self.stats[ext])
    86         cols = columns.keys()
    87         cols.sort()
     86        cols = sorted(columns.keys())
    8887        colwidth = {}
    8988        colwidth["ext"] = max([len(ext) for ext in exts])
     
    110109        def printheader():
    111110            for col in cols:
    112                 print "%*s" % (colwidth[col], col),
    113             print
     111                print("%*s" % (colwidth[col], col), end=" ")
     112            print()
    114113        printheader()
    115114        for ext in exts:
    116115            for col in cols:
    117116                value = self.stats[ext].get(col, "")
    118                 print "%*s" % (colwidth[col], value),
    119             print
     117                print("%*s" % (colwidth[col], value), end=" ")
     118            print()
    120119        printheader() # Another header at the bottom
    121120
  • python/vendor/current/Tools/scripts/diff.py

    r2 r388  
     1#!/usr/bin/env python
    12""" Command line interface to difflib.py providing diffs in four formats:
    23
  • python/vendor/current/Tools/scripts/findnocoding.py

    r2 r388  
    3333
    3434
    35 decl_re = re.compile(r"coding[=:]\s*([-\w.]+)")
     35decl_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)')
    3636
    3737def get_declaration(line):
    38     match = decl_re.search(line)
     38    match = decl_re.match(line)
    3939    if match:
    4040        return match.group(1)
    41     return ''
     41    return b''
    4242
    4343def has_correct_encoding(text, codec):
  • python/vendor/current/Tools/scripts/fixcid.py

    r2 r388  
    189189        err(filename + ': rename failed (' + str(msg) + ')\n')
    190190        return 1
    191     # Return succes
     191    # Return success
    192192    return 0
    193193
  • python/vendor/current/Tools/scripts/fixnotice.py

    r2 r388  
    33"""(Ostensibly) fix copyright notices in files.
    44
    5 Actually, this sript will simply replace a block of text in a file from one
     5Actually, this script will simply replace a block of text in a file from one
    66string to another.  It will only do this once though, i.e. not globally
    77throughout the file.  It writes a backup file and then does an os.rename()
  • python/vendor/current/Tools/scripts/gprof2html.py

    r2 r388  
    1 #! /usr/bin/env python2.3
     1#! /usr/bin/env python
    22
    33"""Transform gprof(1) output into useful HTML."""
  • python/vendor/current/Tools/scripts/h2py.py

    r2 r388  
    5959        except KeyError:
    6060            searchdirs=['/usr/include']
     61            try:
     62                searchdirs.insert(0, os.path.join('/usr/include',
     63                                                  os.environ['MULTIARCH']))
     64            except KeyError:
     65                pass
     66
    6167
    6268def main():
     
    96102        body = p.sub(' ', body)
    97103    # replace char literals by ord(...)
    98     body = p_char.sub('ord(\\0)', body)
     104    body = p_char.sub("ord('\\1')", body)
    99105    # Compute negative hexadecimal constants
    100106    start = 0
  • python/vendor/current/Tools/scripts/ifdef.py

    r2 r388  
    1010# minus those code sections that are suppressed by the selected
    1111# combination of defined/undefined symbols.  The #if(n)def/#else/#else
    12 # lines themselfs (if the #if(n)def tests for one of the mentioned
     12# lines themselves (if the #if(n)def tests for one of the mentioned
    1313# names) are removed as well.
    1414
    1515# Features: Arbitrary nesting of recognized and unrecognized
    16 # preprocesor statements works correctly.  Unrecognized #if* commands
     16# preprocessor statements works correctly.  Unrecognized #if* commands
    1717# are left in place, so it will never remove too much, only too
    1818# little.  It does accept whitespace around the '#' character.
  • python/vendor/current/Tools/scripts/mailerdaemon.py

    r2 r388  
     1#!/usr/bin/env python
    12"""mailerdaemon - classes to parse mailer-daemon messages"""
    23
  • python/vendor/current/Tools/scripts/parseentities.py

    r2 r388  
    1 #!/usr/local/bin/python
     1#!/usr/bin/env python
    22""" Utility for parsing HTML entity definitions available from:
    33
  • python/vendor/current/Tools/scripts/patchcheck.py

    r2 r388  
     1#!/usr/bin/env python
     2import re
     3import sys
     4import shutil
    15import os.path
    26import subprocess
    3 import sys
     7import sysconfig
    48
    59import reindent
     10import untabify
     11
     12
     13SRCDIR = sysconfig.get_config_var('srcdir')
     14
     15
     16def n_files_str(count):
     17    """Return 'N file(s)' with the proper plurality on 'file'."""
     18    return "{} file{}".format(count, "s" if count != 1 else "")
    619
    720
     
    1831                print info(result)
    1932            else:
    20                 if result:
    21                     print "yes"
    22                 else:
    23                     print "NO"
     33                print "yes" if result else "NO"
    2434            return result
    2535        return call_fxn
    2636    return decorated_fxn
    2737
     38
     39def mq_patches_applied():
     40    """Check if there are any applied MQ patches."""
     41    cmd = 'hg qapplied'
     42    st = subprocess.Popen(cmd.split(),
     43                          stdout=subprocess.PIPE,
     44                          stderr=subprocess.PIPE)
     45    try:
     46        bstdout, _ = st.communicate()
     47        return st.returncode == 0 and bstdout
     48    finally:
     49        st.stdout.close()
     50        st.stderr.close()
     51
     52
    2853@status("Getting the list of files that have been added/changed",
    29             info=lambda x: "%s files" % len(x))
     54        info=lambda x: n_files_str(len(x)))
    3055def changed_files():
    31     """Run ``svn status`` and return a set of files that have been
    32     changed/added."""
    33     cmd = 'svn status --quiet --non-interactive --ignore-externals'
    34     svn_st = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
    35     svn_st.wait()
    36     output = [line.strip() for line in svn_st.stdout.readlines()]
    37     files = set()
    38     for line in output:
    39         if not line[0] in ('A', 'M'):
    40             continue
    41         line_parts = line.split()
    42         path = line_parts[-1]
    43         if os.path.isfile(path):
    44             files.add(path)
    45     return files
     56    """Get the list of changed or added files from the VCS."""
     57    if os.path.isdir(os.path.join(SRCDIR, '.hg')):
     58        vcs = 'hg'
     59        cmd = 'hg status --added --modified --no-status'
     60        if mq_patches_applied():
     61            cmd += ' --rev qparent'
     62    elif os.path.isdir('.svn'):
     63        vcs = 'svn'
     64        cmd = 'svn status --quiet --non-interactive --ignore-externals'
     65    else:
     66        sys.exit('need a checkout to get modified files')
    4667
    47 @status("Fixing whitespace", info=lambda x: "%s files" % x)
     68    st = subprocess.Popen(cmd.split(), stdout=subprocess.PIPE)
     69    try:
     70        st.wait()
     71        if vcs == 'hg':
     72            return [x.decode().rstrip() for x in st.stdout]
     73        else:
     74            output = (x.decode().rstrip().rsplit(None, 1)[-1]
     75                      for x in st.stdout if x[0] in 'AM')
     76        return set(path for path in output if os.path.isfile(path))
     77    finally:
     78        st.stdout.close()
     79
     80
     81def report_modified_files(file_paths):
     82    count = len(file_paths)
     83    if count == 0:
     84        return n_files_str(count)
     85    else:
     86        lines = ["{}:".format(n_files_str(count))]
     87        for path in file_paths:
     88            lines.append("  {}".format(path))
     89        return "\n".join(lines)
     90
     91
     92@status("Fixing whitespace", info=report_modified_files)
    4893def normalize_whitespace(file_paths):
    4994    """Make sure that the whitespace for .py files have been normalized."""
    5095    reindent.makebackup = False  # No need to create backups.
    51     result = map(reindent.check, (x for x in file_paths if x.endswith('.py')))
    52     return sum(result)
     96    fixed = []
     97    for path in (x for x in file_paths if x.endswith('.py')):
     98        if reindent.check(os.path.join(SRCDIR, path)):
     99            fixed.append(path)
     100    return fixed
     101
     102
     103@status("Fixing C file whitespace", info=report_modified_files)
     104def normalize_c_whitespace(file_paths):
     105    """Report if any C files """
     106    fixed = []
     107    for path in file_paths:
     108        abspath = os.path.join(SRCDIR, path)
     109        with open(abspath, 'r') as f:
     110            if '\t' not in f.read():
     111                continue
     112        untabify.process(abspath, 8, verbose=False)
     113        fixed.append(path)
     114    return fixed
     115
     116
     117ws_re = re.compile(br'\s+(\r?\n)$')
     118
     119@status("Fixing docs whitespace", info=report_modified_files)
     120def normalize_docs_whitespace(file_paths):
     121    fixed = []
     122    for path in file_paths:
     123        abspath = os.path.join(SRCDIR, path)
     124        try:
     125            with open(abspath, 'rb') as f:
     126                lines = f.readlines()
     127            new_lines = [ws_re.sub(br'\1', line) for line in lines]
     128            if new_lines != lines:
     129                shutil.copyfile(abspath, abspath + '.bak')
     130                with open(abspath, 'wb') as f:
     131                    f.writelines(new_lines)
     132                fixed.append(path)
     133        except Exception as err:
     134            print 'Cannot fix %s: %s' % (path, err)
     135    return fixed
     136
    53137
    54138@status("Docs modified", modal=True)
    55139def docs_modified(file_paths):
    56     """Report if any files in the Docs directory."""
    57     for path in file_paths:
    58         if path.startswith("Doc"):
    59             return True
    60     return False
     140    """Report if any file in the Doc directory has been changed."""
     141    return bool(file_paths)
     142
    61143
    62144@status("Misc/ACKS updated", modal=True)
    63145def credit_given(file_paths):
    64146    """Check if Misc/ACKS has been changed."""
    65     return 'Misc/ACKS' in file_paths
     147    return os.path.join('Misc', 'ACKS') in file_paths
     148
    66149
    67150@status("Misc/NEWS updated", modal=True)
    68151def reported_news(file_paths):
    69152    """Check if Misc/NEWS has been changed."""
    70     return 'Misc/NEWS' in file_paths
     153    return os.path.join('Misc', 'NEWS') in file_paths
    71154
    72155
    73156def main():
    74157    file_paths = changed_files()
    75     # PEP 7/8 verification.
    76     normalize_whitespace(file_paths)
     158    python_files = [fn for fn in file_paths if fn.endswith('.py')]
     159    c_files = [fn for fn in file_paths if fn.endswith(('.c', '.h'))]
     160    doc_files = [fn for fn in file_paths if fn.startswith('Doc')]
     161    misc_files = {os.path.join('Misc', 'ACKS'), os.path.join('Misc', 'NEWS')}\
     162            & set(file_paths)
     163    # PEP 8 whitespace rules enforcement.
     164    normalize_whitespace(python_files)
     165    # C rules enforcement.
     166    normalize_c_whitespace(c_files)
     167    # Doc whitespace enforcement.
     168    normalize_docs_whitespace(doc_files)
    77169    # Docs updated.
    78     docs_modified(file_paths)
     170    docs_modified(doc_files)
    79171    # Misc/ACKS changed.
    80     credit_given(file_paths)
     172    credit_given(misc_files)
    81173    # Misc/NEWS changed.
    82     reported_news(file_paths)
     174    reported_news(misc_files)
    83175
    84176    # Test suite run and passed.
    85     print
    86     print "Did you run the test suite?"
     177    if python_files or c_files:
     178        end = " and check for refleaks?" if c_files else "?"
     179        print
     180        print "Did you run the test suite" + end
    87181
    88182
  • python/vendor/current/Tools/scripts/pathfix.py

    r2 r388  
    136136        err('%s: rename failed (%r)\n' % (filename, msg))
    137137        return 1
    138     # Return succes
     138    # Return success
    139139    return 0
    140140
  • python/vendor/current/Tools/scripts/pindent.py

    r2 r388  
    7777# - optionally do much more thorough reformatting, a la C indent
    7878
     79from __future__ import print_function
     80
    7981# Defaults
    8082STEPSIZE = 8
    8183TABSIZE = 8
    82 EXPANDTABS = 0
    83 
     84EXPANDTABS = False
     85
     86import io
    8487import re
    8588import sys
     
    9093next['try'] = 'except', 'finally'
    9194next['except'] = 'except', 'else', 'finally', 'end'
    92 next['else'] = next['finally'] = next['def'] = next['class'] = 'end'
     95next['else'] = next['finally'] = next['with'] = \
     96    next['def'] = next['class'] = 'end'
    9397next['end'] = ()
    9498start = 'if', 'while', 'for', 'try', 'with', 'def', 'class'
     
    106110        self._write = fpo.write
    107111        self.kwprog = re.compile(
    108                 r'^\s*(?P<kw>[a-z]+)'
    109                 r'(\s+(?P<id>[a-zA-Z_]\w*))?'
     112                r'^(?:\s|\\\n)*(?P<kw>[a-z]+)'
     113                r'((?:\s|\\\n)+(?P<id>[a-zA-Z_]\w*))?'
    110114                r'[^\w]')
    111115        self.endprog = re.compile(
    112                 r'^\s*#?\s*end\s+(?P<kw>[a-z]+)'
     116                r'^(?:\s|\\\n)*#?\s*end\s+(?P<kw>[a-z]+)'
    113117                r'(\s+(?P<id>[a-zA-Z_]\w*))?'
    114118                r'[^\w]')
     
    126130    def readline(self):
    127131        line = self.fpi.readline()
    128         if line: self.lineno = self.lineno + 1
     132        if line: self.lineno += 1
    129133        # end if
    130134        return line
     
    144148            if not line2: break
    145149            # end if
    146             line = line + line2
     150            line += line2
    147151        # end while
    148152        return line
    149153    # end def getline
    150154
    151     def putline(self, line, indent = None):
    152         if indent is None:
    153             self.write(line)
    154             return
    155         # end if
     155    def putline(self, line, indent):
    156156        tabs, spaces = divmod(indent*self.indentsize, self.tabsize)
    157         i = 0
    158         m = self.wsprog.match(line)
    159         if m: i = m.end()
    160         # end if
    161         self.write('\t'*tabs + ' '*spaces + line[i:])
     157        i = self.wsprog.match(line).end()
     158        line = line[i:]
     159        if line[:1] not in ('\n', '\r', ''):
     160            line = '\t'*tabs + ' '*spaces + line
     161        # end if
     162        self.write(line)
    162163    # end def putline
    163164
    164165    def reformat(self):
    165166        stack = []
    166         while 1:
     167        while True:
    167168            line = self.getline()
    168169            if not line: break      # EOF
     
    174175                if not stack:
    175176                    self.error('unexpected end')
    176                 elif stack[-1][0] != kw2:
     177                elif stack.pop()[0] != kw2:
    177178                    self.error('unmatched end')
    178179                # end if
    179                 del stack[-1:]
    180180                self.putline(line, len(stack))
    181181                continue
     
    209209        begin_counter = 0
    210210        end_counter = 0
    211         while 1:
     211        while True:
    212212            line = self.getline()
    213213            if not line: break      # EOF
     
    215215            m = self.endprog.match(line)
    216216            if m:
    217                 end_counter = end_counter + 1
     217                end_counter += 1
    218218                continue
    219219            # end if
     
    222222                kw = m.group('kw')
    223223                if kw in start:
    224                     begin_counter = begin_counter + 1
    225                 # end if
    226             # end if
    227             self.putline(line)
     224                    begin_counter += 1
     225                # end if
     226            # end if
     227            self.write(line)
    228228        # end while
    229229        if begin_counter - end_counter < 0:
     
    235235
    236236    def complete(self):
    237         self.indentsize = 1
    238237        stack = []
    239238        todo = []
    240         thisid = ''
    241         current, firstkw, lastkw, topid = 0, '', '', ''
    242         while 1:
     239        currentws = thisid = firstkw = lastkw = topid = ''
     240        while True:
    243241            line = self.getline()
    244             i = 0
    245             m = self.wsprog.match(line)
    246             if m: i = m.end()
    247             # end if
     242            i = self.wsprog.match(line).end()
    248243            m = self.endprog.match(line)
    249244            if m:
     
    270265                # end if
    271266            # end if
    272             indent = len(line[:i].expandtabs(self.tabsize))
     267            indentws = line[:i]
     268            indent = len(indentws.expandtabs(self.tabsize))
     269            current = len(currentws.expandtabs(self.tabsize))
    273270            while indent < current:
    274271                if firstkw:
     
    279276                        s = '# end %s\n' % firstkw
    280277                    # end if
    281                     self.putline(s, current)
     278                    self.write(currentws + s)
    282279                    firstkw = lastkw = ''
    283280                # end if
    284                 current, firstkw, lastkw, topid = stack[-1]
    285                 del stack[-1]
     281                currentws, firstkw, lastkw, topid = stack.pop()
     282                current = len(currentws.expandtabs(self.tabsize))
    286283            # end while
    287284            if indent == current and firstkw:
     
    298295                        s = '# end %s\n' % firstkw
    299296                    # end if
    300                     self.putline(s, current)
     297                    self.write(currentws + s)
    301298                    firstkw = lastkw = topid = ''
    302299                # end if
    303300            # end if
    304301            if indent > current:
    305                 stack.append((current, firstkw, lastkw, topid))
     302                stack.append((currentws, firstkw, lastkw, topid))
    306303                if thiskw and thiskw not in start:
    307304                    # error
    308305                    thiskw = ''
    309306                # end if
    310                 current, firstkw, lastkw, topid = \
    311                          indent, thiskw, thiskw, thisid
     307                currentws, firstkw, lastkw, topid = \
     308                          indentws, thiskw, thiskw, thisid
    312309            # end if
    313310            if thiskw:
     
    327324        # end while
    328325    # end def complete
    329 
    330326# end class PythonIndenter
    331327
     
    353349# end def reformat_filter
    354350
    355 class StringReader:
    356     def __init__(self, buf):
    357         self.buf = buf
    358         self.pos = 0
    359         self.len = len(self.buf)
    360     # end def __init__
    361     def read(self, n = 0):
    362         if n <= 0:
    363             n = self.len - self.pos
    364         else:
    365             n = min(n, self.len - self.pos)
    366         # end if
    367         r = self.buf[self.pos : self.pos + n]
    368         self.pos = self.pos + n
    369         return r
    370     # end def read
    371     def readline(self):
    372         i = self.buf.find('\n', self.pos)
    373         return self.read(i + 1 - self.pos)
    374     # end def readline
    375     def readlines(self):
    376         lines = []
    377         line = self.readline()
    378         while line:
    379             lines.append(line)
    380             line = self.readline()
    381         # end while
    382         return lines
    383     # end def readlines
    384     # seek/tell etc. are left as an exercise for the reader
    385 # end class StringReader
    386 
    387 class StringWriter:
    388     def __init__(self):
    389         self.buf = ''
    390     # end def __init__
    391     def write(self, s):
    392         self.buf = self.buf + s
    393     # end def write
    394     def getvalue(self):
    395         return self.buf
    396     # end def getvalue
    397 # end class StringWriter
    398 
    399351def complete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS):
    400     input = StringReader(source)
    401     output = StringWriter()
     352    input = io.BytesIO(source)
     353    output = io.BytesIO()
    402354    pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs)
    403355    pi.complete()
     
    406358
    407359def delete_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS):
    408     input = StringReader(source)
    409     output = StringWriter()
     360    input = io.BytesIO(source)
     361    output = io.BytesIO()
    410362    pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs)
    411363    pi.delete()
     
    414366
    415367def reformat_string(source, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS):
    416     input = StringReader(source)
    417     output = StringWriter()
     368    input = io.BytesIO(source)
     369    output = io.BytesIO()
    418370    pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs)
    419371    pi.reformat()
     
    421373# end def reformat_string
    422374
     375def make_backup(filename):
     376    import os, os.path
     377    backup = filename + '~'
     378    if os.path.lexists(backup):
     379        try:
     380            os.remove(backup)
     381        except os.error:
     382            print("Can't remove backup %r" % (backup,), file=sys.stderr)
     383        # end try
     384    # end if
     385    try:
     386        os.rename(filename, backup)
     387    except os.error:
     388        print("Can't rename %r to %r" % (filename, backup), file=sys.stderr)
     389    # end try
     390# end def make_backup
     391
    423392def complete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS):
    424     source = open(filename, 'r').read()
     393    with open(filename, 'r') as f:
     394        source = f.read()
     395    # end with
    425396    result = complete_string(source, stepsize, tabsize, expandtabs)
    426397    if source == result: return 0
    427398    # end if
    428     import os
    429     try: os.rename(filename, filename + '~')
    430     except os.error: pass
    431     # end try
    432     f = open(filename, 'w')
    433     f.write(result)
    434     f.close()
     399    make_backup(filename)
     400    with open(filename, 'w') as f:
     401        f.write(result)
     402    # end with
    435403    return 1
    436404# end def complete_file
    437405
    438406def delete_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS):
    439     source = open(filename, 'r').read()
     407    with open(filename, 'r') as f:
     408        source = f.read()
     409    # end with
    440410    result = delete_string(source, stepsize, tabsize, expandtabs)
    441411    if source == result: return 0
    442412    # end if
    443     import os
    444     try: os.rename(filename, filename + '~')
    445     except os.error: pass
    446     # end try
    447     f = open(filename, 'w')
    448     f.write(result)
    449     f.close()
     413    make_backup(filename)
     414    with open(filename, 'w') as f:
     415        f.write(result)
     416    # end with
    450417    return 1
    451418# end def delete_file
    452419
    453420def reformat_file(filename, stepsize = STEPSIZE, tabsize = TABSIZE, expandtabs = EXPANDTABS):
    454     source = open(filename, 'r').read()
     421    with open(filename, 'r') as f:
     422        source = f.read()
     423    # end with
    455424    result = reformat_string(source, stepsize, tabsize, expandtabs)
    456425    if source == result: return 0
    457426    # end if
    458     import os
    459     try: os.rename(filename, filename + '~')
    460     except os.error: pass
    461     # end try
    462     f = open(filename, 'w')
    463     f.write(result)
    464     f.close()
     427    make_backup(filename)
     428    with open(filename, 'w') as f:
     429        f.write(result)
     430    # end with
    465431    return 1
    466432# end def reformat_file
     
    475441-s stepsize: indentation step (default %(STEPSIZE)d)
    476442-t tabsize : the worth in spaces of a tab (default %(TABSIZE)d)
    477 -e         : expand TABs into spaces (defailt OFF)
     443-e         : expand TABs into spaces (default OFF)
    478444[file] ... : files are changed in place, with backups in file~
    479445If no files are specified or a single - is given,
     
    518484            tabsize = int(a)
    519485        elif o == '-e':
    520             expandtabs = 1
     486            expandtabs = True
    521487        # end if
    522488    # end for
  • python/vendor/current/Tools/scripts/redemo.py

    r2 r388  
     1#!/usr/bin/env python
    12"""Basic regular expression demostration facility (Perl style syntax)."""
    23
  • python/vendor/current/Tools/scripts/reindent-rst.py

    r2 r388  
    44# Currently just remove trailing whitespace.
    55
    6 from __future__ import with_statement
    7 import sys, re, shutil
     6import sys
    87
    9 ws_re = re.compile(r'\s+(\r?\n)$')
     8import patchcheck
    109
    1110def main(argv=sys.argv):
    12     rv = 0
    13     for filename in argv[1:]:
    14         try:
    15             with open(filename, 'rb') as f:
    16                 lines = f.readlines()
    17             new_lines = [ws_re.sub(r'\1', line) for line in lines]
    18             if new_lines != lines:
    19                 print 'Fixing %s...' % filename
    20             shutil.copyfile(filename, filename + '.bak')
    21             with open(filename, 'wb') as f:
    22                 f.writelines(new_lines)
    23         except Exception, err:
    24             print 'Cannot fix %s: %s' % (filename, err)
    25             rv = 1
    26     return rv
     11    patchcheck.normalize_docs_whitespace(argv[1:])
    2712
    2813if __name__ == '__main__':
  • python/vendor/current/Tools/scripts/reindent.py

    r2 r388  
    3636The backup file is a copy of the one that is being reindented. The ".bak"
    3737file is generated with shutil.copy(), but some corner cases regarding
    38 user/group and permissions could leave the backup file more readable that
     38user/group and permissions could leave the backup file more readable than
    3939you'd prefer. You can always use the --nobackup option to prevent this.
    4040"""
     
    4545import os, shutil
    4646import sys
     47import io
    4748
    4849verbose    = 0
     
    109110        print "checking", file, "...",
    110111    try:
    111         f = open(file)
     112        f = io.open(file)
    112113    except IOError, msg:
    113114        errprint("%s: I/O Error: %s" % (file, str(msg)))
     
    116117    r = Reindenter(f)
    117118    f.close()
     119
     120    newline = r.newlines
     121    if isinstance(newline, tuple):
     122        errprint("%s: mixed newlines detected; cannot process file" % file)
     123        return
     124
    118125    if r.run():
    119126        if verbose:
     
    127134                if verbose:
    128135                    print "backed up", file, "to", bak
    129             f = open(file, "w")
     136            f = io.open(file, "w", newline=newline)
    130137            r.write(f)
    131138            f.close()
     
    173180        # indeed, they're our headache!
    174181        self.stats = []
     182
     183        # Save the newlines found in the file so they can be used to
     184        #  create output without mutating the newlines.
     185        self.newlines = f.newlines
    175186
    176187    def run(self):
  • python/vendor/current/Tools/scripts/untabify.py

    r2 r388  
    2424        process(filename, tabsize)
    2525
    26 def process(filename, tabsize):
     26def process(filename, tabsize, verbose=True):
    2727    try:
    2828        f = open(filename)
     
    4444    except os.error:
    4545        pass
    46     f = open(filename, "w")
    47     f.write(newtext)
    48     f.close()
    49     print filename
     46    with open(filename, "w") as f:
     47        f.write(newtext)
     48    if verbose:
     49        print filename
    5050
    5151if __name__ == '__main__':
  • python/vendor/current/Tools/unicode/gencodec.py

    r2 r388  
    4141                   '(#.+)?')
    4242
    43 def parsecodes(codes,
    44                len=len, filter=filter,range=range):
     43def parsecodes(codes, len=len, range=range):
    4544
    4645    """ Converts code combinations to either a single code integer
     
    6362        except ValueError:
    6463            l[i] = None
    65     l = filter(lambda x: x is not None, l)
     64    l = [x for x in l if x is not None]
    6665    if len(l) == 1:
    6766        return l[0]
     
    139138    l = []
    140139    append = l.append
    141     if map.has_key("IDENTITY"):
     140    if "IDENTITY" in map:
    142141        append("%s = codecs.make_identity_dict(range(%d))" %
    143142               (varname, map["IDENTITY"]))
     
    151150        identity = 0
    152151
    153     mappings = map.items()
    154     mappings.sort()
     152    mappings = sorted(map.items())
    155153    i = 0
    156154    key_precision, value_precision = precisions
     
    200198
    201199    # Analyze map and create table dict
    202     mappings = map.items()
    203     mappings.sort()
     200    mappings = sorted(map.items())
    204201    table = {}
    205202    maxkey = 0
    206     if map.has_key('IDENTITY'):
     203    if 'IDENTITY' in map:
    207204        for key in range(256):
    208205            table[key] = (key, '')
     
    422419    import sys
    423420    if 1:
    424         apply(convertdir,tuple(sys.argv[1:]))
    425     else:
    426         apply(rewritepythondir,tuple(sys.argv[1:]))
     421        convertdir(*sys.argv[1:])
     422    else:
     423        rewritepythondir(*sys.argv[1:])
  • python/vendor/current/Tools/unicode/makeunicodedata.py

    r2 r388  
    3131
    3232# The Unicode Database
    33 UNIDATA_VERSION = "5.1.0"
     33UNIDATA_VERSION = "5.2.0"
    3434UNICODE_DATA = "UnicodeData%s.txt"
    3535COMPOSITION_EXCLUSIONS = "CompositionExclusions%s.txt"
    3636EASTASIAN_WIDTH = "EastAsianWidth%s.txt"
     37UNIHAN = "Unihan%s.txt"
     38DERIVEDNORMALIZATION_PROPS = "DerivedNormalizationProps%s.txt"
     39LINE_BREAK = "LineBreak%s.txt"
    3740
    3841old_versions = ["3.2.0"]
     
    4851
    4952EASTASIANWIDTH_NAMES = [ "F", "H", "W", "Na", "A", "N" ]
     53
     54MANDATORY_LINE_BREAKS = [ "BK", "CR", "LF", "NL" ]
    5055
    5156# note: should match definitions in Objects/unicodectype.c
     
    5964UPPER_MASK = 0x80
    6065NODELTA_MASK = 0x100
     66NUMERIC_MASK = 0x200
    6167
    6268def maketables(trace=0):
     
    6773    unicode = UnicodeData(UNICODE_DATA % version,
    6874                          COMPOSITION_EXCLUSIONS % version,
    69                           EASTASIAN_WIDTH % version)
     75                          EASTASIAN_WIDTH % version,
     76                          UNIHAN % version,
     77                          DERIVEDNORMALIZATION_PROPS % version,
     78                          LINE_BREAK % version)
    7079
    7180    print len(filter(None, unicode.table)), "characters"
     
    7584        old_unicode = UnicodeData(UNICODE_DATA % ("-"+version),
    7685                                  COMPOSITION_EXCLUSIONS % ("-"+version),
    77                                   EASTASIAN_WIDTH % ("-"+version))
     86                                  EASTASIAN_WIDTH % ("-"+version),
     87                                  UNIHAN % ("-"+version))
    7888        print len(filter(None, old_unicode.table)), "characters"
    7989        merge_old_version(version, unicode, old_unicode)
     
    8898def makeunicodedata(unicode, trace):
    8999
    90     dummy = (0, 0, 0, 0, 0)
     100    dummy = (0, 0, 0, 0, 0, 0)
    91101    table = [dummy]
    92102    cache = {0: dummy}
     
    108118            mirrored = record[9] == "Y"
    109119            eastasianwidth = EASTASIANWIDTH_NAMES.index(record[15])
     120            normalizationquickcheck = record[17]
    110121            item = (
    111                 category, combining, bidirectional, mirrored, eastasianwidth
     122                category, combining, bidirectional, mirrored, eastasianwidth,
     123                normalizationquickcheck
    112124                )
    113125            # add entry to index and item tables
     
    149161                assert prefix < 256
    150162                # content
    151                 decomp = [prefix + (len(decomp)<<8)] +\
    152                          map(lambda s: int(s, 16), decomp)
     163                decomp = [prefix + (len(decomp)<<8)] + [int(s, 16) for s in decomp]
    153164                # Collect NFC pairs
    154165                if not prefix and len(decomp) == 3 and \
     
    223234          "const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {"
    224235    for item in table:
    225         print >>fp, "    {%d, %d, %d, %d, %d}," % item
     236        print >>fp, "    {%d, %d, %d, %d, %d, %d}," % item
    226237    print >>fp, "};"
    227238    print >>fp
     
    349360    cache = {0: dummy}
    350361    index = [0] * len(unicode.chars)
     362    numeric = {}
     363    spaces = []
     364    linebreaks = []
    351365
    352366    for char in unicode.chars:
     
    356370            category = record[2]
    357371            bidirectional = record[4]
     372            properties = record[16]
    358373            flags = 0
    359374            delta = True
     
    362377            if category == "Ll":
    363378                flags |= LOWER_MASK
    364             if category == "Zl" or bidirectional == "B":
     379            if 'Line_Break' in properties or bidirectional == "B":
    365380                flags |= LINEBREAK_MASK
     381                linebreaks.append(char)
    366382            if category == "Zs" or bidirectional in ("WS", "B", "S"):
    367383                flags |= SPACE_MASK
     384                spaces.append(char)
    368385            if category == "Lt":
    369386                flags |= TITLE_MASK
     
    408425                flags |= DIGIT_MASK
    409426                digit = int(record[7])
     427            if record[8]:
     428                flags |= NUMERIC_MASK
     429                numeric.setdefault(record[8], []).append(char)
    410430            item = (
    411431                upper, lower, title, decimal, digit, flags
     
    419439
    420440    print len(table), "unique character type entries"
     441    print sum(map(len, numeric.values())), "numeric code points"
     442    print len(spaces), "whitespace code points"
     443    print len(linebreaks), "linebreak code points"
    421444
    422445    print "--- Writing", FILE, "..."
     
    439462    Array("index1", index1).dump(fp, trace)
    440463    Array("index2", index2).dump(fp, trace)
     464
     465    # Generate code for _PyUnicode_ToNumeric()
     466    numeric_items = sorted(numeric.items())
     467    print >>fp, '/* Returns the numeric value as double for Unicode characters'
     468    print >>fp, ' * having this property, -1.0 otherwise.'
     469    print >>fp, ' */'
     470    print >>fp, 'double _PyUnicode_ToNumeric(Py_UNICODE ch)'
     471    print >>fp, '{'
     472    print >>fp, '    switch (ch) {'
     473    for value, codepoints in numeric_items:
     474        # Turn text into float literals
     475        parts = value.split('/')
     476        parts = [repr(float(part)) for part in parts]
     477        value = '/'.join(parts)
     478
     479        haswide = False
     480        hasnonewide = False
     481        codepoints.sort()
     482        for codepoint in codepoints:
     483            if codepoint < 0x10000:
     484                hasnonewide = True
     485            if codepoint >= 0x10000 and not haswide:
     486                print >>fp, '#ifdef Py_UNICODE_WIDE'
     487                haswide = True
     488            print >>fp, '    case 0x%04X:' % (codepoint,)
     489        if haswide and hasnonewide:
     490            print >>fp, '#endif'
     491        print >>fp, '        return (double) %s;' % (value,)
     492        if haswide and not hasnonewide:
     493            print >>fp, '#endif'
     494    print >>fp,'    }'
     495    print >>fp,'    return -1.0;'
     496    print >>fp,'}'
     497    print >>fp
     498
     499    # Generate code for _PyUnicode_IsWhitespace()
     500    print >>fp, "/* Returns 1 for Unicode characters having the bidirectional"
     501    print >>fp, " * type 'WS', 'B' or 'S' or the category 'Zs', 0 otherwise."
     502    print >>fp, " */"
     503    print >>fp, 'int _PyUnicode_IsWhitespace(register const Py_UNICODE ch)'
     504    print >>fp, '{'
     505    print >>fp, '#ifdef WANT_WCTYPE_FUNCTIONS'
     506    print >>fp, '    return iswspace(ch);'
     507    print >>fp, '#else'
     508    print >>fp, '    switch (ch) {'
     509
     510    haswide = False
     511    hasnonewide = False
     512    for codepoint in sorted(spaces):
     513        if codepoint < 0x10000:
     514            hasnonewide = True
     515        if codepoint >= 0x10000 and not haswide:
     516            print >>fp, '#ifdef Py_UNICODE_WIDE'
     517            haswide = True
     518        print >>fp, '    case 0x%04X:' % (codepoint,)
     519    if haswide and hasnonewide:
     520        print >>fp, '#endif'
     521    print >>fp, '        return 1;'
     522    if haswide and not hasnonewide:
     523        print >>fp, '#endif'
     524
     525    print >>fp,'    }'
     526    print >>fp,'    return 0;'
     527    print >>fp, '#endif'
     528    print >>fp,'}'
     529    print >>fp
     530
     531    # Generate code for _PyUnicode_IsLinebreak()
     532    print >>fp, "/* Returns 1 for Unicode characters having the line break"
     533    print >>fp, " * property 'BK', 'CR', 'LF' or 'NL' or having bidirectional"
     534    print >>fp, " * type 'B', 0 otherwise."
     535    print >>fp, " */"
     536    print >>fp, 'int _PyUnicode_IsLinebreak(register const Py_UNICODE ch)'
     537    print >>fp, '{'
     538    print >>fp, '    switch (ch) {'
     539    haswide = False
     540    hasnonewide = False
     541    for codepoint in sorted(linebreaks):
     542        if codepoint < 0x10000:
     543            hasnonewide = True
     544        if codepoint >= 0x10000 and not haswide:
     545            print >>fp, '#ifdef Py_UNICODE_WIDE'
     546            haswide = True
     547        print >>fp, '    case 0x%04X:' % (codepoint,)
     548    if haswide and hasnonewide:
     549        print >>fp, '#endif'
     550    print >>fp, '        return 1;'
     551    if haswide and not hasnonewide:
     552        print >>fp, '#endif'
     553
     554    print >>fp,'    }'
     555    print >>fp,'    return 0;'
     556    print >>fp,'}'
     557    print >>fp
    441558
    442559    fp.close()
     
    487604
    488605    # sort on falling frequency, then by name
    489     def cmpwords((aword, alist),(bword, blist)):
    490         r = -cmp(len(alist),len(blist))
    491         if r:
    492             return r
    493         return cmp(aword, bword)
    494     wordlist.sort(cmpwords)
     606    def word_key(a):
     607        aword, alist = a
     608        return -len(alist), aword
     609    wordlist.sort(key=word_key)
    495610
    496611    # figure out how many phrasebook escapes we need
     
    516631
    517632    wordlist, wordtail = wordlist[:short], wordlist[short:]
    518     wordtail.sort(lambda a, b: len(b[0])-len(a[0]))
     633    wordtail.sort(key=lambda a: a[0], reverse=True)
    519634    wordlist.extend(wordtail)
    520635
     
    657772                        # print "NUMERIC",hex(i), `old.table[i][k]`, new.table[i][k]
    658773                        # Since 0 encodes "no change", the old value is better not 0
    659                         assert value != "0" and value != "-1"
    660774                        if not value:
    661775                            numeric_changes[i] = -1
    662776                        else:
    663                             assert re.match("^[0-9]+$", value)
    664                             numeric_changes[i] = int(value)
     777                            numeric_changes[i] = float(value)
     778                            assert numeric_changes[i] not in (0, -1)
    665779                    elif k == 9:
    666780                        if value == 'Y':
     
    680794                        # change to simple titlecase mapping; ignore
    681795                        pass
     796                    elif k == 16:
     797                        # change to properties; not yet
     798                        pass
    682799                    else:
    683800                        class Difference(Exception):pass
     
    695812# load a unicode-data file from disk
    696813
    697 import sys
    698 
    699814class UnicodeData:
    700 
    701     def __init__(self, filename, exclusions, eastasianwidth, expand=1):
     815    # Record structure:
     816    # [ID, name, category, combining, bidi, decomp,  (6)
     817    #  decimal, digit, numeric, bidi-mirrored, Unicode-1-name, (11)
     818    #  ISO-comment, uppercase, lowercase, titlecase, ea-width, (16)
     819    #  properties] (17)
     820
     821    def __init__(self, filename, exclusions, eastasianwidth, unihan,
     822                 derivednormalizationprops=None, linebreakprops=None,
     823                 expand=1):
    702824        self.changed = []
    703825        file = open(filename)
     
    762884            if table[i] is not None:
    763885                table[i].append(widths[i])
     886
     887        for i in range(0, 0x110000):
     888            if table[i] is not None:
     889                table[i].append(set())
     890        if linebreakprops:
     891            for s in open(linebreakprops):
     892                s = s.partition('#')[0]
     893                s = [i.strip() for i in s.split(';')]
     894                if len(s) < 2 or s[1] not in MANDATORY_LINE_BREAKS:
     895                    continue
     896                if '..' not in s[0]:
     897                    first = last = int(s[0], 16)
     898                else:
     899                    first, last = [int(c, 16) for c in s[0].split('..')]
     900                for char in range(first, last+1):
     901                    table[char][-1].add('Line_Break')
     902
     903        if derivednormalizationprops:
     904            quickchecks = [0] * 0x110000 # default is Yes
     905            qc_order = 'NFD_QC NFKD_QC NFC_QC NFKC_QC'.split()
     906            for s in open(derivednormalizationprops):
     907                if '#' in s:
     908                    s = s[:s.index('#')]
     909                s = [i.strip() for i in s.split(';')]
     910                if len(s) < 2 or s[1] not in qc_order:
     911                    continue
     912                quickcheck = 'MN'.index(s[2]) + 1 # Maybe or No
     913                quickcheck_shift = qc_order.index(s[1])*2
     914                quickcheck <<= quickcheck_shift
     915                if '..' not in s[0]:
     916                    first = last = int(s[0], 16)
     917                else:
     918                    first, last = [int(c, 16) for c in s[0].split('..')]
     919                for char in range(first, last+1):
     920                    assert not (quickchecks[char]>>quickcheck_shift)&3
     921                    quickchecks[char] |= quickcheck
     922            for i in range(0, 0x110000):
     923                if table[i] is not None:
     924                    table[i].append(quickchecks[i])
     925
     926        for line in open(unihan):
     927            if not line.startswith('U+'):
     928                continue
     929            code, tag, value = line.split(None, 3)[:3]
     930            if tag not in ('kAccountingNumeric', 'kPrimaryNumeric',
     931                           'kOtherNumeric'):
     932                continue
     933            value = value.strip().replace(',', '')
     934            i = int(code[2:], 16)
     935            # Patch the numeric field
     936            if table[i] is not None:
     937                table[i][8] = value
    764938
    765939    def uselatin1(self):
     
    9121086    """
    9131087
    914     import sys
    9151088    if trace:
    9161089        def dump(t1, t2, shift, bytes):
  • python/vendor/current/Tools/unicode/mkstringprep.py

    r2 r388  
    22
    33if sys.maxunicode == 65535:
    4     raise RuntimeError, "need UCS-4 Python"
     4    raise RuntimeError("need UCS-4 Python")
    55
    66def gen_category(cats):
     
    6464        if m.group(1) == "Start":
    6565            if curname:
    66                 raise "Double Start",(curname, l)
     66                raise RuntimeError("Double Start", (curname, l))
    6767            curname = m.group(2)
    6868            table = {}
     
    7171        else:
    7272            if not curname:
    73                 raise "End without start", l
     73                raise RuntimeError("End without start", l)
    7474            curname = None
    7575            continue
     
    8888                start, end = fields
    8989            except ValueError:
    90                 raise "Unpacking problem", l
     90                raise RuntimeError("Unpacking problem", l)
    9191        else:
    9292            start = end = fields[0]
     
    147147del tables[0]
    148148assert name == "B.1"
    149 table = table.keys()
    150 table.sort()
     149table = sorted(table.keys())
    151150print """
    152151b1_set = """ + compact_set(table) + """
     
    178177        b3_exceptions[k] = u"".join(map(unichr,v))
    179178
    180 b3 = b3_exceptions.items()
    181 b3.sort()
     179b3 = sorted(b3_exceptions.items())
    182180
    183181print """
     
    354352assert name == "C.6"
    355353
    356 table = table.keys()
    357 table.sort()
     354table = sorted(table.keys())
    358355
    359356print """
     
    368365assert name == "C.7"
    369366
    370 table = table.keys()
    371 table.sort()
     367table = sorted(table.keys())
    372368
    373369print """
     
    382378assert name == "C.8"
    383379
    384 table = table.keys()
    385 table.sort()
     380table = sorted(table.keys())
    386381
    387382print """
     
    396391assert name == "C.9"
    397392
    398 table = table.keys()
    399 table.sort()
     393table = sorted(table.keys())
    400394
    401395print """
  • python/vendor/current/Tools/webchecker/wcgui.py

    r2 r388  
    6464import tktools
    6565import webchecker
    66 
    67 # Override some for a weaker platform
    68 if sys.platform == 'mac':
    69     webchecker.DEFROOT = "http://grail.cnri.reston.va.us/"
    70     webchecker.MAXPAGE = 50000
    71     webchecker.verbose = 4
    7266
    7367def main():
  • python/vendor/current/Tools/webchecker/webchecker.py

    r2 r388  
    104104
    105105
    106 __version__ = "$Revision: 50851 $"
     106__version__ = "$Revision$"
    107107
    108108
  • python/vendor/current/Tools/webchecker/websucker.py

    r2 r388  
    33"""A variant on webchecker that creates a mirror copy of a remote site."""
    44
    5 __version__ = "$Revision: 28654 $"
     5__version__ = "$Revision$"
    66
    77import os
     
    9898        if os.sep != "/":
    9999            path = os.sep.join(path.split("/"))
    100             if os.name == "mac":
    101                 path = os.sep + path
    102100        path = os.path.join(host, path)
    103101        return path
  • python/vendor/current/Tools/world/world

    r2 r388  
    8080        Print this message.
    8181"""
    82 __version__ = '$Revision: 27624 $'
     82__version__ = '$Revision$'
    8383
    8484
Note: See TracChangeset for help on using the changeset viewer.