Changeset 388 for python/vendor/current/Tools
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- Location:
- python/vendor/current/Tools
- Files:
-
- 11 added
- 2 deleted
- 53 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Tools/README
r2 r388 21 21 freeze Create a stand-alone executable from a Python program. 22 22 23 gdb Python code to be run inside gdb, to make it easier to 24 debug Python itself (by David Malcolm). 25 23 26 i18n Tools for internationalization. pygettext.py 24 27 parses Python source code and generates .pot files, … … 26 29 from a catalog in text format. 27 30 28 modulator Interactively generate boiler plate for an extension29 module. Works easiest if you have Tk.30 31 31 pynche A Tkinter-based color editor. 32 32 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. 33 scripts 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. 36 37 37 38 unicode Tools used to generate unicode database files for -
python/vendor/current/Tools/buildbot/build-amd64.bat
r2 r388 1 1 @rem Used by the buildbot "compile" step. 2 set HOST_PYTHON="%CD%\PCbuild\amd64\python_d.exe" 2 3 cmd /c Tools\buildbot\external-amd64.bat 3 4 call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 -
python/vendor/current/Tools/buildbot/buildmsi.bat
r2 r388 12 12 "%ProgramFiles%\HTML Help Workshop\hhc.exe" Doc\build\htmlhelp\python26a3.hhp 13 13 14 @rem bu old the MSI file14 @rem build the MSI file 15 15 cd PC 16 16 nmake /f icons.mak -
python/vendor/current/Tools/buildbot/clean-amd64.bat
r2 r388 1 1 @rem Used by the buildbot "clean" step. 2 2 call "%VS90COMNTOOLS%\..\..\VC\vcvarsall.bat" x86_amd64 3 cd PCbuild4 3 @echo Deleting .pyc/.pyo files ... 5 4 del /s Lib\*.pyc Lib\*.pyo 5 @echo Deleting test leftovers ... 6 rmdir /s /q build 7 cd PCbuild 6 8 vcbuild /clean pcbuild.sln "Release|x64" 7 9 vcbuild /clean pcbuild.sln "Debug|x64" 10 cd .. -
python/vendor/current/Tools/buildbot/clean.bat
r2 r388 3 3 @echo Deleting .pyc/.pyo files ... 4 4 del /s Lib\*.pyc Lib\*.pyo 5 @echo Deleting test leftovers ... 6 rmdir /s /q build 5 7 cd PCbuild 6 8 vcbuild /clean pcbuild.sln "Release|Win32" 7 9 vcbuild /clean pcbuild.sln "Debug|Win32" 10 cd .. -
python/vendor/current/Tools/buildbot/external-common.bat
r2 r388 5 5 @rem XXX: If you need to force the buildbots to start from a fresh environment, uncomment 6 6 @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.57 @rem if exist bzip2-1.0.6 rd /s/q bzip2-1.0.6 8 8 @rem if exist tcltk rd /s/q tcltk 9 9 @rem if exist tcltk64 rd /s/q tcltk64 … … 16 16 @rem if exist db-4.4.20 rd /s/q db-4.4.20 17 17 @rem if exist db-4.7.25.0 rd /s/q db-4.7.25.0 18 @rem if exist openssl-0.9.8 l rd /s/q openssl-0.9.8l19 @rem if exist sqlite-3. 5.9 rd /s/q sqlite-3.5.918 @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 20 20 21 21 @rem bzip 22 if not exist bzip2-1.0. 5(23 rd /s/q bzip2-1.0. 324 svn export http://svn.python.org/projects/external/bzip2-1.0. 522 if 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 25 25 ) 26 26 … … 30 30 31 31 @rem OpenSSL 32 if not exist openssl-0.9.8 l svn export http://svn.python.org/projects/external/openssl-0.9.8l32 if not exist openssl-0.9.8y svn export http://svn.python.org/projects/external/openssl-0.9.8y 33 33 34 34 @rem tcl/tk … … 40 40 41 41 @rem sqlite3 42 if not exist sqlite-3. 5.9(42 if not exist sqlite-3.6.21 ( 43 43 rd /s/q sqlite-source-3.3.4 44 svn export http://svn.python.org/projects/external/sqlite-3. 5.944 svn export http://svn.python.org/projects/external/sqlite-3.6.21 45 45 ) -
python/vendor/current/Tools/buildbot/test-amd64.bat
r2 r388 1 1 @rem Used by the buildbot "test" step. 2 2 cd PCbuild 3 call rt.bat - q -d -x64 -uall -rw3 call 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 1 1 @rem Used by the buildbot "test" step. 2 2 cd PCbuild 3 call rt.bat -d -q -uall -rw 3 call rt.bat -d -q -uall -rwW %1 %2 %3 %4 %5 %6 %7 %8 %9 -
python/vendor/current/Tools/compiler/astgen.py
r2 r388 106 106 def _gen_init(self, buf): 107 107 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 109 111 else: 110 112 print >> buf, " def __init__(self, lineno=None):" 111 113 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) 114 120 print >> buf, " self.lineno = lineno" 115 121 # Copy the lines in self.init, indented four spaces. The rstrip() -
python/vendor/current/Tools/faqwiz/faqw.py
r2 r388 1 #! /usr/local/bin/python1 #!/usr/bin/env python 2 2 3 3 """FAQ wizard bootstrap.""" -
python/vendor/current/Tools/freeze/checkextensions_win32.py
r2 r388 4 4 are needed (primarily to toggle the behavior of "public" symbols. 5 5 6 I don t consider it worth parsing the MSVC makefiles for compiler options. Even if6 I don't consider it worth parsing the MSVC makefiles for compiler options. Even if 7 7 we get it just right, a specific freeze application may have specific compiler 8 8 options anyway (eg, to enable or disable specific functionality) 9 9 10 So my basic stra gtegy is:10 So my basic strategy is: 11 11 12 12 * Have some Windows INI files which "describe" one or more extension modules. … … 15 15 * This description can include: 16 16 - The MSVC .dsp file for the extension. The .c source file names 17 are extrac ed from there.17 are extracted from there. 18 18 - Specific compiler/linker options 19 19 - Flag to indicate if Unicode compilation is expected. -
python/vendor/current/Tools/freeze/makeconfig.py
r2 r388 1 1 import re 2 2 import sys 3 3 4 4 # Write the config.c file 5 5 6 never = ['marshal', '__main__', '__builtin__', 'sys', 'exceptions' ]6 never = ['marshal', '__main__', '__builtin__', 'sys', 'exceptions', '_warnings'] 7 7 8 8 def makeconfig(infp, outfp, modules, with_ifdef=0): … … 39 39 40 40 def test(): 41 import sys42 41 if not sys.argv[3:]: 43 42 print 'usage: python makeconfig.py config.c.in outputfile', -
python/vendor/current/Tools/freeze/makefreeze.py
r2 r388 63 63 outfp.write('\n') 64 64 # The following modules have a NULL code pointer, indicating 65 # that the prozen program should not search for them on the host65 # that the frozen program should not search for them on the host 66 66 # system. Importing them will *always* raise an ImportError. 67 67 # The zero value size is never used. -
python/vendor/current/Tools/freeze/winmakemakefile.py
r2 r388 135 135 136 136 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)" 142 142 print "\t$(resources)" 143 print "<<" 143 144 print 144 145 print "clean:" -
python/vendor/current/Tools/i18n/makelocalealias.py
r2 r388 10 10 11 11 # Location of the alias file 12 LOCALE_ALIAS = '/usr/ lib/X11/locale/locale.alias'12 LOCALE_ALIAS = '/usr/share/X11/locale/locale.alias' 13 13 14 14 def parse(filename): -
python/vendor/current/Tools/i18n/msgfmt.py
r2 r388 26 26 """ 27 27 28 import os 28 29 import sys 29 import os30 import ast 30 31 import getopt 31 32 import struct … … 138 139 continue 139 140 # 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'): 141 142 if section == STR: 142 143 add(msgid, msgstr, fuzzy) … … 144 145 l = l[5:] 145 146 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 146 157 # Now we are in a msgstr section 147 158 elif l.startswith('msgstr'): 148 159 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:] 150 174 # Skip empty lines 151 175 l = l.strip() 152 176 if not l: 153 177 continue 154 # XXX: Does this always follow Python escape semantics? 155 l = eval(l) 178 l = ast.literal_eval(l) 156 179 if section == ID: 157 180 msgid += l -
python/vendor/current/Tools/i18n/pygettext.py
r2 r388 212 212 def make_escapes(pass_iso8859): 213 213 global escapes 214 escapes = [chr(i) for i in range(256)] 214 215 if pass_iso8859: 215 216 # Allow iso-8859 characters to pass through so that e.g. 'msgid … … 219 220 else: 220 221 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 226 225 escapes[ord('\\')] = '\\\\' 227 226 escapes[ord('\t')] = '\\t' … … 600 599 601 600 # calculate escapes 602 make_escapes( options.escape)601 make_escapes(not options.escape) 603 602 604 603 # calculate all keywords -
python/vendor/current/Tools/msi/msi.py
r2 r388 2 2 # (C) 2003 Martin v. Loewis 3 3 # See "FOO" in comments refers to MSDN sections with the title FOO. 4 import msilib, schema, sequence, os, glob, time, re, shutil 4 import msilib, schema, sequence, os, glob, time, re, shutil, zipfile 5 5 from msilib import Feature, CAB, Directory, Dialog, Binary, add_data 6 6 import uisample … … 8 8 from distutils.spawn import find_executable 9 9 from uuids import product_codes 10 import tempfile 10 11 11 12 # Settings can be overridden in config.py below … … 29 30 # msvcrt version 30 31 MSVCR = "90" 32 # Name of certificate in default store to sign MSI with 33 certname = None 34 # Make a zip file containing the PDB files for this build? 35 pdbzip = True 31 36 32 37 try: … … 112 117 "25":"{2e41b118-38bd-4c1b-a840-6977efd1b911}", 113 118 "26":"{34ebecac-f046-4e1c-b0e3-9bac3cdaacfa}", 119 "27":"{4fe21c76-1760-437b-a2f2-99909130a175}", 114 120 } [major+minor] 115 121 116 122 # Compute the name that Sphinx gives to the docfile 117 123 docfile = "" 118 if micro:119 docfile = str(micro)124 if int(micro): 125 docfile = micro 120 126 if 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) 122 131 docfile = 'python%s%s%s.chm' % (major, minor, docfile) 123 132 … … 168 177 have_mingw = build_mingw_lib(lib_file, def_file, dll_file, mingw_lib) 169 178 170 # Determine the target architechture 179 # Determine the target architecture 180 if os.system("nmake /nologo /c /f msisupport.mak") != 0: 181 raise RuntimeError("'nmake /f msisupport.mak' failed") 171 182 dll_path = os.path.join(srcdir, PCBUILD, dll_file) 172 183 msilib.set_arch_from_file(dll_path) … … 215 226 # sequence is the set of standard sequences 216 227 # (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, 218 230 schema, ProductName="Python "+full_current_version+productsuffix, 219 231 ProductCode=product_code, … … 238 250 ]) 239 251 db.Commit() 240 return db 252 return db, msiname 241 253 242 254 def remove_old_versions(db): … … 365 377 # the installed/uninstalled state according to both the 366 378 # Extensions and TclTk features. 367 if os.system("nmake /nologo /c /f msisupport.mak") != 0:368 raise "'nmake /f msisupport.mak' failed"369 379 add_data(db, "Binary", [("Script", msilib.Binary("msisupport.dll"))]) 370 380 # See "Custom Action Type 1" … … 399 409 ]) 400 410 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"' 402 412 lib2to3args = r'-c "import lib2to3.pygram, lib2to3.patcomp;lib2to3.patcomp.PatternCompiler()"' 403 413 # See "CustomAction Table" … … 486 496 exit_dialog = PyDialog(db, "ExitDialog", x, y, w, h, modal, title, 487 497 "Finish", "Finish", "Finish") 488 exit_dialog.title("Complet ingthe [ProductName] Installer")498 exit_dialog.title("Complete the [ProductName] Installer") 489 499 exit_dialog.back("< Back", "Finish", active = 0) 490 500 exit_dialog.cancel("Cancel", "Back", active = 0) … … 496 506 497 507 c = exit_dialog.text("warning", 135, 200, 220, 40, 0x30003, 498 "{\\VerdanaRed9}Warning: Python 2.5.xis 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") 501 511 502 512 exit_dialog.text("Description", 135, 235, 220, 20, 0x30003, … … 1002 1012 lib.add_file("cfgparser.1") 1003 1013 lib.add_file("sgml_input.html") 1004 lib.add_file("test.xml")1005 lib.add_file("test.xml.out")1006 1014 lib.add_file("testtar.tar") 1007 1015 lib.add_file("test_difflib_expect.html") … … 1012 1020 lib.glob("*.pem") 1013 1021 lib.glob("*.pck") 1014 lib.add_file("readme.txt", src="README")1015 1022 lib.add_file("zipdir.zip") 1023 if dir=='tests' and parent.physical=='distutils': 1024 lib.add_file("Setup.sample") 1016 1025 if dir=='decimaltestdata': 1017 1026 lib.glob("*.decTest") 1027 if dir=='xmltestdata': 1028 lib.glob("*.xml") 1029 lib.add_file("test.xml.out") 1018 1030 if dir=='output': 1019 1031 lib.glob("test_*") … … 1188 1200 tcl_verbs=[ 1189 1201 ("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"', 1191 1203 "REGISTRY.tcl"), 1192 1204 ("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"', 1194 1206 "REGISTRY.tcl"), 1195 1207 ] … … 1290 1302 db.Commit() 1291 1303 1292 db = build_database() 1304 def 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 1314 db,msiname = build_database() 1293 1315 try: 1294 1316 add_features(db) … … 1300 1322 finally: 1301 1323 del db 1324 1325 # Merge CRT into MSI file. This requires the database to be closed. 1326 mod_dir = os.path.join(os.environ["ProgramFiles"], "Common Files", "Merge Modules") 1327 if msilib.Win64: 1328 modules = ["Microsoft_VC90_CRT_x86_x64.msm", "policy_9_0_Microsoft_VC90_CRT_x86_x64.msm"] 1329 else: 1330 modules = ["Microsoft_VC90_CRT_x86.msm","policy_9_0_Microsoft_VC90_CRT_x86.msm"] 1331 1332 for i, n in enumerate(modules): 1333 modules[i] = os.path.join(mod_dir, n) 1334 1335 def 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 1390 merge(msiname, "SharedCRT", "TARGETDIR", modules) 1391 1392 # certname (from config.py) should be (a substring of) 1393 # the certificate subject, e.g. "Python Software Foundation" 1394 if 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 1400 if pdbzip: 1401 build_pdbzip() -
python/vendor/current/Tools/msi/msilib.py
r2 r388 306 306 # Fill the validation table 307 307 add_data(db, "_Validation", schema._Validation_records) 308 # Initialize the summary information, allowing at most 20 properties308 # Initialize the summary information, allowing at most 20 properties 309 309 si = db.GetSummaryInformation(20) 310 310 si.SetProperty(PID_TITLE, "Installation Database") … … 517 517 def add_file(self, file, src=None, version=None, language=None): 518 518 """Add a file to the current component of the directory, starting a new one 519 oneif there is no current component. By default, the file name in the source519 if there is no current component. By default, the file name in the source 520 520 and the file table will be identical. If the src file is specified, it is 521 521 interpreted relative to the current directory. Optionally, a version and a -
python/vendor/current/Tools/msi/msisupport.c
r2 r388 8 8 static UINT debug(MSIHANDLE hInstall, LPCSTR msg) 9 9 { 10 11 12 13 14 15 16 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; 17 17 } 18 18 … … 23 23 { 24 24 #define PSIZE 1024 25 26 27 28 29 25 WCHAR wpath[PSIZE]; 26 char path[PSIZE]; 27 UINT result; 28 DWORD size = PSIZE; 29 DWORD attributes; 30 30 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';37 31 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 } 46 46 } 47 47 … … 52 52 UINT __declspec(dllexport) __stdcall UpdateEditIDLE(MSIHANDLE hInstall) 53 53 { 54 55 54 INSTALLSTATE ext_old, ext_new, tcl_old, tcl_new, reg_new; 55 UINT result; 56 56 57 58 59 60 61 62 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; 63 63 64 65 66 67 68 69 70 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; 71 71 72 73 74 75 76 77 78 79 80 } else { 81 82 83 84 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; 85 85 } 86 86 87 BOOL APIENTRY DllMain(HANDLE hModule, 88 DWORD ul_reason_for_call, 87 BOOL APIENTRY DllMain(HANDLE hModule, 88 DWORD ul_reason_for_call, 89 89 LPVOID lpReserved) 90 90 { -
python/vendor/current/Tools/msi/uuids.py
r2 r388 8 8 # so people can refer to them. 9 9 product_codes = { 10 '2.4.101': '{0e9b4d8e-6cda-446e-a208-7b92f3ddffa0}', # 2.4a1, released as a snapshot11 '2.4.102': '{1b998745-4901-4edb-bc52-213689e1b922}', # 2.4a212 '2.4.103': '{33fc8bd2-1e8f-4add-a40a-ade2728d5942}', # 2.4a313 '2.4.111': '{51a7e2a8-2025-4ef0-86ff-e6aab742d1fa}', # 2.4b114 '2.4.112': '{4a5e7c1d-c659-4fe3-b8c9-7c65bd9c95a5}', # 2.4b215 '2.4.121': '{75508821-a8e9-40a8-95bd-dbe6033ddbea}', # 2.4c116 '2.4.122': '{83a9118b-4bdd-473b-afc3-bcb142feca9e}', # 2.4c217 '2.4.150': '{82d9302e-f209-4805-b548-52087047483a}', # 2.4.018 '2.4.1121':'{be027411-8e6b-4440-a29b-b07df0690230}', # 2.4.1c119 '2.4.1122':'{02818752-48bf-4074-a281-7a4114c4f1b1}', # 2.4.1c220 '2.4.1150':'{4d4f5346-7e4a-40b5-9387-fdb6181357fc}', # 2.4.121 '2.4.2121':'{5ef9d6b6-df78-45d2-ab09-14786a3c5a99}', # 2.4.2c122 '2.4.2150':'{b191e49c-ea23-43b2-b28a-14e0784069b8}', # 2.4.223 '2.4.3121':'{f669ed4d-1dce-41c4-9617-d985397187a1}', # 2.4.3c124 '2.4.3150':'{75e71add-042c-4f30-bfac-a9ec42351313}', # 2.4.325 '2.4.4121':'{cd2862db-22a4-4688-8772-85407ea21550}', # 2.4.4c126 '2.4.4150':'{60e2c8c9-6cf3-4b1a-9618-e304946c94e6}', # 2.4.427 10 '2.5.101': '{bc14ce3e-5e72-4a64-ac1f-bf59a571898c}', # 2.5a1 28 11 '2.5.102': '{5eed51c1-8e9d-4071-94c5-b40de5d49ba5}', # 2.5a2 … … 59 42 '2.6.5122':'{fa227b76-0671-4dc6-b826-c2ff2a70dfd5}', # 2.6.5c2 60 43 '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 61 66 } -
python/vendor/current/Tools/pybench/CommandLine.py
r2 r388 459 459 except AttributeError: 460 460 if value == '': 461 # count the number of occur ances461 # count the number of occurrences 462 462 if values.has_key(optionname): 463 463 values[optionname] = values[optionname] + 1 -
python/vendor/current/Tools/pybench/README
r2 r388 4 4 ________________________________________________________________________ 5 5 6 Extendable suite of oflow-level benchmarks for measuring6 Extendable suite of low-level benchmarks for measuring 7 7 the performance of the Python implementation 8 8 (interpreter, compiler or VM). -
python/vendor/current/Tools/pybench/Setup.py
r2 r388 1 #! python1 #!/usr/bin/env python 2 2 3 3 # Setup file for pybench -
python/vendor/current/Tools/pybench/pybench.py
r2 r388 231 231 self.calibration_runs = calibration_runs 232 232 if timer is not None: 233 timer = timer233 self.timer = timer 234 234 235 235 # Init variables … … 279 279 pass 280 280 t = timer() - t 281 prep_times.append(t )281 prep_times.append(t / CALIBRATION_LOOPS) 282 282 min_prep_time = min(prep_times) 283 283 if _debug: … … 690 690 if (benchmarks_compatible and 691 691 test.compatible(other)): 692 # Both benchmark and tests are compar ible692 # Both benchmark and tests are comparable 693 693 min_diff = ((min_time * self.warp) / 694 694 (other_min_time * other.warp) - 1.0) … … 704 704 avg_diff = '%+5.1f%%' % (avg_diff * PERCENT) 705 705 else: 706 # Benchmark or tests are not compar ible706 # Benchmark or tests are not comparable 707 707 min_diff, avg_diff = 'n/a', 'n/a' 708 708 tests_compatible = 0 -
python/vendor/current/Tools/pybench/systimes.py
r2 r388 6 6 This module implements various different strategies for measuring 7 7 performance timings. It tries to choose the best available method 8 based on the platform aand available tools.8 based on the platform and available tools. 9 9 10 10 On Windows, it is recommended to have the Mark Hammond win32 -
python/vendor/current/Tools/pynche/DetailsViewer.py
r2 r388 27 27 would have the value 7. 28 28 29 Prese ve Distance29 Preserve Distance 30 30 When the increment or decrement would send any of the tied variations 31 31 out of bounds, all tied variations are wrapped as one, so as to -
python/vendor/current/Tools/scripts/2to3
r2 r388 1 1 #!/usr/bin/env python 2 import sys 2 3 from lib2to3.main import main 3 import sys4 import os5 4 6 5 sys.exit(main("lib2to3.fixes")) -
python/vendor/current/Tools/scripts/README
r2 r388 5 5 See also the Demo/scripts directory! 6 6 7 analyze_dxp.py Analyzes the result of sys.getdxp() 7 8 byext.py Print lines/words/chars stats of files by extension 8 9 byteyears.py Print product of a file's size and age … … 19 20 dutree.py Format du(1) output as a tree sorted by size 20 21 eptags.py Create Emacs TAGS file for Python modules 21 finddiv.py A grep-like tool that looks for division operators. 22 find_recursionlimit.py Find the maximum recursion limit on this machine 23 finddiv.py A grep-like tool that looks for division operators 22 24 findlinksto.py Recursively find symbolic links to a given path prefix 23 25 findnocoding.py Find source files which need an encoding declaration … … 28 30 fixps.py Fix Python scripts' first line (if #!) 29 31 ftpmirror.py FTP mirror script 30 google.py Open a webbrowser with Google .31 gprof2html.py Transform gprof(1) output into useful HTML .32 google.py Open a webbrowser with Google 33 gprof2html.py Transform gprof(1) output into useful HTML 32 34 h2py.py Translate #define's into Python assignments 33 35 hotshotmain.py Main program to run script under control of hotshot … … 56 58 reindent.py Change .py files to use 4-space indents. 57 59 rgrep.py Reverse grep through a file (useful for big logfiles) 58 setup.py Install all scripts listed here. 60 serve.py Small wsgiref-based web server, used in make serve in Doc 61 setup.py Install all scripts listed here 59 62 suff.py Sort a list of files by suffix 60 svneol.py Sets svn:eol-style on all files in directory .63 svneol.py Sets svn:eol-style on all files in directory 61 64 texcheck.py Validate Python LaTeX formatting (Raymond Hettinger) 62 65 texi2html.py Convert GNU texinfo files into HTML -
python/vendor/current/Tools/scripts/byext.py
r2 r388 2 2 3 3 """Show file statistics by extension.""" 4 5 from __future__ import print_function 4 6 5 7 import os … … 24 26 self.addstats("<dir>", "dirs", 1) 25 27 try: 26 names = os.listdir(dir)27 except os.error ,err:28 names = sorted(os.listdir(dir)) 29 except os.error as err: 28 30 sys.stderr.write("Can't list %s: %s\n" % (dir, err)) 29 31 self.addstats("<dir>", "unlistable", 1) 30 32 return 31 names.sort()32 33 for name in names: 33 34 if name.startswith(".#"): … … 54 55 try: 55 56 f = open(filename, "rb") 56 except IOError ,err:57 except IOError as err: 57 58 sys.stderr.write("Can't open %s: %s\n" % (filename, err)) 58 59 self.addstats(ext, "unopenable", 1) … … 61 62 f.close() 62 63 self.addstats(ext, "bytes", len(data)) 63 if '\0' in data:64 if b'\0' in data: 64 65 self.addstats(ext, "binary", 1) 65 66 return … … 78 79 79 80 def report(self): 80 exts = self.stats.keys() 81 exts.sort() 81 exts = sorted(self.stats.keys()) 82 82 # Get the column keys 83 83 columns = {} 84 84 for ext in exts: 85 85 columns.update(self.stats[ext]) 86 cols = columns.keys() 87 cols.sort() 86 cols = sorted(columns.keys()) 88 87 colwidth = {} 89 88 colwidth["ext"] = max([len(ext) for ext in exts]) … … 110 109 def printheader(): 111 110 for col in cols: 112 print "%*s" % (colwidth[col], col),113 print 111 print("%*s" % (colwidth[col], col), end=" ") 112 print() 114 113 printheader() 115 114 for ext in exts: 116 115 for col in cols: 117 116 value = self.stats[ext].get(col, "") 118 print "%*s" % (colwidth[col], value),119 print 117 print("%*s" % (colwidth[col], value), end=" ") 118 print() 120 119 printheader() # Another header at the bottom 121 120 -
python/vendor/current/Tools/scripts/diff.py
r2 r388 1 #!/usr/bin/env python 1 2 """ Command line interface to difflib.py providing diffs in four formats: 2 3 -
python/vendor/current/Tools/scripts/findnocoding.py
r2 r388 33 33 34 34 35 decl_re = re.compile(r "coding[=:]\s*([-\w.]+)")35 decl_re = re.compile(r'^[ \t\f]*#.*coding[:=][ \t]*([-\w.]+)') 36 36 37 37 def get_declaration(line): 38 match = decl_re. search(line)38 match = decl_re.match(line) 39 39 if match: 40 40 return match.group(1) 41 return ''41 return b'' 42 42 43 43 def has_correct_encoding(text, codec): -
python/vendor/current/Tools/scripts/fixcid.py
r2 r388 189 189 err(filename + ': rename failed (' + str(msg) + ')\n') 190 190 return 1 191 # Return succes 191 # Return success 192 192 return 0 193 193 -
python/vendor/current/Tools/scripts/fixnotice.py
r2 r388 3 3 """(Ostensibly) fix copyright notices in files. 4 4 5 Actually, this s ript will simply replace a block of text in a file from one5 Actually, this script will simply replace a block of text in a file from one 6 6 string to another. It will only do this once though, i.e. not globally 7 7 throughout 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 python 2.31 #! /usr/bin/env python 2 2 3 3 """Transform gprof(1) output into useful HTML.""" -
python/vendor/current/Tools/scripts/h2py.py
r2 r388 59 59 except KeyError: 60 60 searchdirs=['/usr/include'] 61 try: 62 searchdirs.insert(0, os.path.join('/usr/include', 63 os.environ['MULTIARCH'])) 64 except KeyError: 65 pass 66 61 67 62 68 def main(): … … 96 102 body = p.sub(' ', body) 97 103 # replace char literals by ord(...) 98 body = p_char.sub( 'ord(\\0)', body)104 body = p_char.sub("ord('\\1')", body) 99 105 # Compute negative hexadecimal constants 100 106 start = 0 -
python/vendor/current/Tools/scripts/ifdef.py
r2 r388 10 10 # minus those code sections that are suppressed by the selected 11 11 # combination of defined/undefined symbols. The #if(n)def/#else/#else 12 # lines themsel fs (if the #if(n)def tests for one of the mentioned12 # lines themselves (if the #if(n)def tests for one of the mentioned 13 13 # names) are removed as well. 14 14 15 15 # Features: Arbitrary nesting of recognized and unrecognized 16 # preproces or statements works correctly. Unrecognized #if* commands16 # preprocessor statements works correctly. Unrecognized #if* commands 17 17 # are left in place, so it will never remove too much, only too 18 18 # little. It does accept whitespace around the '#' character. -
python/vendor/current/Tools/scripts/mailerdaemon.py
r2 r388 1 #!/usr/bin/env python 1 2 """mailerdaemon - classes to parse mailer-daemon messages""" 2 3 -
python/vendor/current/Tools/scripts/parseentities.py
r2 r388 1 #!/usr/ local/bin/python1 #!/usr/bin/env python 2 2 """ Utility for parsing HTML entity definitions available from: 3 3 -
python/vendor/current/Tools/scripts/patchcheck.py
r2 r388 1 #!/usr/bin/env python 2 import re 3 import sys 4 import shutil 1 5 import os.path 2 6 import subprocess 3 import sys 7 import sysconfig 4 8 5 9 import reindent 10 import untabify 11 12 13 SRCDIR = sysconfig.get_config_var('srcdir') 14 15 16 def 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 "") 6 19 7 20 … … 18 31 print info(result) 19 32 else: 20 if result: 21 print "yes" 22 else: 23 print "NO" 33 print "yes" if result else "NO" 24 34 return result 25 35 return call_fxn 26 36 return decorated_fxn 27 37 38 39 def 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 28 53 @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))) 30 55 def 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') 46 67 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 81 def 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) 48 93 def normalize_whitespace(file_paths): 49 94 """Make sure that the whitespace for .py files have been normalized.""" 50 95 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) 104 def 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 117 ws_re = re.compile(br'\s+(\r?\n)$') 118 119 @status("Fixing docs whitespace", info=report_modified_files) 120 def 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 53 137 54 138 @status("Docs modified", modal=True) 55 139 def 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 61 143 62 144 @status("Misc/ACKS updated", modal=True) 63 145 def credit_given(file_paths): 64 146 """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 66 149 67 150 @status("Misc/NEWS updated", modal=True) 68 151 def reported_news(file_paths): 69 152 """Check if Misc/NEWS has been changed.""" 70 return 'Misc/NEWS'in file_paths153 return os.path.join('Misc', 'NEWS') in file_paths 71 154 72 155 73 156 def main(): 74 157 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) 77 169 # Docs updated. 78 docs_modified( file_paths)170 docs_modified(doc_files) 79 171 # Misc/ACKS changed. 80 credit_given( file_paths)172 credit_given(misc_files) 81 173 # Misc/NEWS changed. 82 reported_news( file_paths)174 reported_news(misc_files) 83 175 84 176 # 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 87 181 88 182 -
python/vendor/current/Tools/scripts/pathfix.py
r2 r388 136 136 err('%s: rename failed (%r)\n' % (filename, msg)) 137 137 return 1 138 # Return succes 138 # Return success 139 139 return 0 140 140 -
python/vendor/current/Tools/scripts/pindent.py
r2 r388 77 77 # - optionally do much more thorough reformatting, a la C indent 78 78 79 from __future__ import print_function 80 79 81 # Defaults 80 82 STEPSIZE = 8 81 83 TABSIZE = 8 82 EXPANDTABS = 0 83 84 EXPANDTABS = False 85 86 import io 84 87 import re 85 88 import sys … … 90 93 next['try'] = 'except', 'finally' 91 94 next['except'] = 'except', 'else', 'finally', 'end' 92 next['else'] = next['finally'] = next['def'] = next['class'] = 'end' 95 next['else'] = next['finally'] = next['with'] = \ 96 next['def'] = next['class'] = 'end' 93 97 next['end'] = () 94 98 start = 'if', 'while', 'for', 'try', 'with', 'def', 'class' … … 106 110 self._write = fpo.write 107 111 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*))?' 110 114 r'[^\w]') 111 115 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]+)' 113 117 r'(\s+(?P<id>[a-zA-Z_]\w*))?' 114 118 r'[^\w]') … … 126 130 def readline(self): 127 131 line = self.fpi.readline() 128 if line: self.lineno = self.lineno +1132 if line: self.lineno += 1 129 133 # end if 130 134 return line … … 144 148 if not line2: break 145 149 # end if 146 line = line +line2150 line += line2 147 151 # end while 148 152 return line 149 153 # end def getline 150 154 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): 156 156 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) 162 163 # end def putline 163 164 164 165 def reformat(self): 165 166 stack = [] 166 while 1:167 while True: 167 168 line = self.getline() 168 169 if not line: break # EOF … … 174 175 if not stack: 175 176 self.error('unexpected end') 176 elif stack [-1][0] != kw2:177 elif stack.pop()[0] != kw2: 177 178 self.error('unmatched end') 178 179 # end if 179 del stack[-1:]180 180 self.putline(line, len(stack)) 181 181 continue … … 209 209 begin_counter = 0 210 210 end_counter = 0 211 while 1:211 while True: 212 212 line = self.getline() 213 213 if not line: break # EOF … … 215 215 m = self.endprog.match(line) 216 216 if m: 217 end_counter = end_counter +1217 end_counter += 1 218 218 continue 219 219 # end if … … 222 222 kw = m.group('kw') 223 223 if kw in start: 224 begin_counter = begin_counter +1225 # end if 226 # end if 227 self. putline(line)224 begin_counter += 1 225 # end if 226 # end if 227 self.write(line) 228 228 # end while 229 229 if begin_counter - end_counter < 0: … … 235 235 236 236 def complete(self): 237 self.indentsize = 1238 237 stack = [] 239 238 todo = [] 240 thisid = '' 241 current, firstkw, lastkw, topid = 0, '', '', '' 242 while 1: 239 currentws = thisid = firstkw = lastkw = topid = '' 240 while True: 243 241 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() 248 243 m = self.endprog.match(line) 249 244 if m: … … 270 265 # end if 271 266 # 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)) 273 270 while indent < current: 274 271 if firstkw: … … 279 276 s = '# end %s\n' % firstkw 280 277 # end if 281 self. putline(s, current)278 self.write(currentws + s) 282 279 firstkw = lastkw = '' 283 280 # 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)) 286 283 # end while 287 284 if indent == current and firstkw: … … 298 295 s = '# end %s\n' % firstkw 299 296 # end if 300 self. putline(s, current)297 self.write(currentws + s) 301 298 firstkw = lastkw = topid = '' 302 299 # end if 303 300 # end if 304 301 if indent > current: 305 stack.append((current , firstkw, lastkw, topid))302 stack.append((currentws, firstkw, lastkw, topid)) 306 303 if thiskw and thiskw not in start: 307 304 # error 308 305 thiskw = '' 309 306 # end if 310 current , firstkw, lastkw, topid = \311 indent, thiskw, thiskw, thisid307 currentws, firstkw, lastkw, topid = \ 308 indentws, thiskw, thiskw, thisid 312 309 # end if 313 310 if thiskw: … … 327 324 # end while 328 325 # end def complete 329 330 326 # end class PythonIndenter 331 327 … … 353 349 # end def reformat_filter 354 350 355 class StringReader:356 def __init__(self, buf):357 self.buf = buf358 self.pos = 0359 self.len = len(self.buf)360 # end def __init__361 def read(self, n = 0):362 if n <= 0:363 n = self.len - self.pos364 else:365 n = min(n, self.len - self.pos)366 # end if367 r = self.buf[self.pos : self.pos + n]368 self.pos = self.pos + n369 return r370 # end def read371 def readline(self):372 i = self.buf.find('\n', self.pos)373 return self.read(i + 1 - self.pos)374 # end def readline375 def readlines(self):376 lines = []377 line = self.readline()378 while line:379 lines.append(line)380 line = self.readline()381 # end while382 return lines383 # end def readlines384 # seek/tell etc. are left as an exercise for the reader385 # end class StringReader386 387 class StringWriter:388 def __init__(self):389 self.buf = ''390 # end def __init__391 def write(self, s):392 self.buf = self.buf + s393 # end def write394 def getvalue(self):395 return self.buf396 # end def getvalue397 # end class StringWriter398 399 351 def 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() 402 354 pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) 403 355 pi.complete() … … 406 358 407 359 def 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() 410 362 pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) 411 363 pi.delete() … … 414 366 415 367 def 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() 418 370 pi = PythonIndenter(input, output, stepsize, tabsize, expandtabs) 419 371 pi.reformat() … … 421 373 # end def reformat_string 422 374 375 def 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 423 392 def 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 425 396 result = complete_string(source, stepsize, tabsize, expandtabs) 426 397 if source == result: return 0 427 398 # 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 435 403 return 1 436 404 # end def complete_file 437 405 438 406 def 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 440 410 result = delete_string(source, stepsize, tabsize, expandtabs) 441 411 if source == result: return 0 442 412 # 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 450 417 return 1 451 418 # end def delete_file 452 419 453 420 def 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 455 424 result = reformat_string(source, stepsize, tabsize, expandtabs) 456 425 if source == result: return 0 457 426 # 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 465 431 return 1 466 432 # end def reformat_file … … 475 441 -s stepsize: indentation step (default %(STEPSIZE)d) 476 442 -t tabsize : the worth in spaces of a tab (default %(TABSIZE)d) 477 -e : expand TABs into spaces (defa ilt OFF)443 -e : expand TABs into spaces (default OFF) 478 444 [file] ... : files are changed in place, with backups in file~ 479 445 If no files are specified or a single - is given, … … 518 484 tabsize = int(a) 519 485 elif o == '-e': 520 expandtabs = 1486 expandtabs = True 521 487 # end if 522 488 # end for -
python/vendor/current/Tools/scripts/redemo.py
r2 r388 1 #!/usr/bin/env python 1 2 """Basic regular expression demostration facility (Perl style syntax).""" 2 3 -
python/vendor/current/Tools/scripts/reindent-rst.py
r2 r388 4 4 # Currently just remove trailing whitespace. 5 5 6 from __future__ import with_statement 7 import sys, re, shutil 6 import sys 8 7 9 ws_re = re.compile(r'\s+(\r?\n)$') 8 import patchcheck 10 9 11 10 def 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:]) 27 12 28 13 if __name__ == '__main__': -
python/vendor/current/Tools/scripts/reindent.py
r2 r388 36 36 The backup file is a copy of the one that is being reindented. The ".bak" 37 37 file is generated with shutil.copy(), but some corner cases regarding 38 user/group and permissions could leave the backup file more readable tha t38 user/group and permissions could leave the backup file more readable than 39 39 you'd prefer. You can always use the --nobackup option to prevent this. 40 40 """ … … 45 45 import os, shutil 46 46 import sys 47 import io 47 48 48 49 verbose = 0 … … 109 110 print "checking", file, "...", 110 111 try: 111 f = open(file)112 f = io.open(file) 112 113 except IOError, msg: 113 114 errprint("%s: I/O Error: %s" % (file, str(msg))) … … 116 117 r = Reindenter(f) 117 118 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 118 125 if r.run(): 119 126 if verbose: … … 127 134 if verbose: 128 135 print "backed up", file, "to", bak 129 f = open(file, "w")136 f = io.open(file, "w", newline=newline) 130 137 r.write(f) 131 138 f.close() … … 173 180 # indeed, they're our headache! 174 181 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 175 186 176 187 def run(self): -
python/vendor/current/Tools/scripts/untabify.py
r2 r388 24 24 process(filename, tabsize) 25 25 26 def process(filename, tabsize ):26 def process(filename, tabsize, verbose=True): 27 27 try: 28 28 f = open(filename) … … 44 44 except os.error: 45 45 pass 46 f = open(filename, "w")47 f.write(newtext)48 f.close()49 print filename46 with open(filename, "w") as f: 47 f.write(newtext) 48 if verbose: 49 print filename 50 50 51 51 if __name__ == '__main__': -
python/vendor/current/Tools/unicode/gencodec.py
r2 r388 41 41 '(#.+)?') 42 42 43 def parsecodes(codes, 44 len=len, filter=filter,range=range): 43 def parsecodes(codes, len=len, range=range): 45 44 46 45 """ Converts code combinations to either a single code integer … … 63 62 except ValueError: 64 63 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] 66 65 if len(l) == 1: 67 66 return l[0] … … 139 138 l = [] 140 139 append = l.append 141 if map.has_key("IDENTITY"):140 if "IDENTITY" in map: 142 141 append("%s = codecs.make_identity_dict(range(%d))" % 143 142 (varname, map["IDENTITY"])) … … 151 150 identity = 0 152 151 153 mappings = map.items() 154 mappings.sort() 152 mappings = sorted(map.items()) 155 153 i = 0 156 154 key_precision, value_precision = precisions … … 200 198 201 199 # Analyze map and create table dict 202 mappings = map.items() 203 mappings.sort() 200 mappings = sorted(map.items()) 204 201 table = {} 205 202 maxkey = 0 206 if map.has_key('IDENTITY'):203 if 'IDENTITY' in map: 207 204 for key in range(256): 208 205 table[key] = (key, '') … … 422 419 import sys 423 420 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 31 31 32 32 # The Unicode Database 33 UNIDATA_VERSION = "5. 1.0"33 UNIDATA_VERSION = "5.2.0" 34 34 UNICODE_DATA = "UnicodeData%s.txt" 35 35 COMPOSITION_EXCLUSIONS = "CompositionExclusions%s.txt" 36 36 EASTASIAN_WIDTH = "EastAsianWidth%s.txt" 37 UNIHAN = "Unihan%s.txt" 38 DERIVEDNORMALIZATION_PROPS = "DerivedNormalizationProps%s.txt" 39 LINE_BREAK = "LineBreak%s.txt" 37 40 38 41 old_versions = ["3.2.0"] … … 48 51 49 52 EASTASIANWIDTH_NAMES = [ "F", "H", "W", "Na", "A", "N" ] 53 54 MANDATORY_LINE_BREAKS = [ "BK", "CR", "LF", "NL" ] 50 55 51 56 # note: should match definitions in Objects/unicodectype.c … … 59 64 UPPER_MASK = 0x80 60 65 NODELTA_MASK = 0x100 66 NUMERIC_MASK = 0x200 61 67 62 68 def maketables(trace=0): … … 67 73 unicode = UnicodeData(UNICODE_DATA % version, 68 74 COMPOSITION_EXCLUSIONS % version, 69 EASTASIAN_WIDTH % version) 75 EASTASIAN_WIDTH % version, 76 UNIHAN % version, 77 DERIVEDNORMALIZATION_PROPS % version, 78 LINE_BREAK % version) 70 79 71 80 print len(filter(None, unicode.table)), "characters" … … 75 84 old_unicode = UnicodeData(UNICODE_DATA % ("-"+version), 76 85 COMPOSITION_EXCLUSIONS % ("-"+version), 77 EASTASIAN_WIDTH % ("-"+version)) 86 EASTASIAN_WIDTH % ("-"+version), 87 UNIHAN % ("-"+version)) 78 88 print len(filter(None, old_unicode.table)), "characters" 79 89 merge_old_version(version, unicode, old_unicode) … … 88 98 def makeunicodedata(unicode, trace): 89 99 90 dummy = (0, 0, 0, 0, 0 )100 dummy = (0, 0, 0, 0, 0, 0) 91 101 table = [dummy] 92 102 cache = {0: dummy} … … 108 118 mirrored = record[9] == "Y" 109 119 eastasianwidth = EASTASIANWIDTH_NAMES.index(record[15]) 120 normalizationquickcheck = record[17] 110 121 item = ( 111 category, combining, bidirectional, mirrored, eastasianwidth 122 category, combining, bidirectional, mirrored, eastasianwidth, 123 normalizationquickcheck 112 124 ) 113 125 # add entry to index and item tables … … 149 161 assert prefix < 256 150 162 # 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] 153 164 # Collect NFC pairs 154 165 if not prefix and len(decomp) == 3 and \ … … 223 234 "const _PyUnicode_DatabaseRecord _PyUnicode_Database_Records[] = {" 224 235 for item in table: 225 print >>fp, " {%d, %d, %d, %d, %d }," % item236 print >>fp, " {%d, %d, %d, %d, %d, %d}," % item 226 237 print >>fp, "};" 227 238 print >>fp … … 349 360 cache = {0: dummy} 350 361 index = [0] * len(unicode.chars) 362 numeric = {} 363 spaces = [] 364 linebreaks = [] 351 365 352 366 for char in unicode.chars: … … 356 370 category = record[2] 357 371 bidirectional = record[4] 372 properties = record[16] 358 373 flags = 0 359 374 delta = True … … 362 377 if category == "Ll": 363 378 flags |= LOWER_MASK 364 if category == "Zl"or bidirectional == "B":379 if 'Line_Break' in properties or bidirectional == "B": 365 380 flags |= LINEBREAK_MASK 381 linebreaks.append(char) 366 382 if category == "Zs" or bidirectional in ("WS", "B", "S"): 367 383 flags |= SPACE_MASK 384 spaces.append(char) 368 385 if category == "Lt": 369 386 flags |= TITLE_MASK … … 408 425 flags |= DIGIT_MASK 409 426 digit = int(record[7]) 427 if record[8]: 428 flags |= NUMERIC_MASK 429 numeric.setdefault(record[8], []).append(char) 410 430 item = ( 411 431 upper, lower, title, decimal, digit, flags … … 419 439 420 440 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" 421 444 422 445 print "--- Writing", FILE, "..." … … 439 462 Array("index1", index1).dump(fp, trace) 440 463 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 441 558 442 559 fp.close() … … 487 604 488 605 # 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) 495 610 496 611 # figure out how many phrasebook escapes we need … … 516 631 517 632 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) 519 634 wordlist.extend(wordtail) 520 635 … … 657 772 # print "NUMERIC",hex(i), `old.table[i][k]`, new.table[i][k] 658 773 # Since 0 encodes "no change", the old value is better not 0 659 assert value != "0" and value != "-1"660 774 if not value: 661 775 numeric_changes[i] = -1 662 776 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) 665 779 elif k == 9: 666 780 if value == 'Y': … … 680 794 # change to simple titlecase mapping; ignore 681 795 pass 796 elif k == 16: 797 # change to properties; not yet 798 pass 682 799 else: 683 800 class Difference(Exception):pass … … 695 812 # load a unicode-data file from disk 696 813 697 import sys698 699 814 class 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): 702 824 self.changed = [] 703 825 file = open(filename) … … 762 884 if table[i] is not None: 763 885 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 764 938 765 939 def uselatin1(self): … … 912 1086 """ 913 1087 914 import sys915 1088 if trace: 916 1089 def dump(t1, t2, shift, bytes): -
python/vendor/current/Tools/unicode/mkstringprep.py
r2 r388 2 2 3 3 if sys.maxunicode == 65535: 4 raise RuntimeError , "need UCS-4 Python"4 raise RuntimeError("need UCS-4 Python") 5 5 6 6 def gen_category(cats): … … 64 64 if m.group(1) == "Start": 65 65 if curname: 66 raise "Double Start",(curname, l)66 raise RuntimeError("Double Start", (curname, l)) 67 67 curname = m.group(2) 68 68 table = {} … … 71 71 else: 72 72 if not curname: 73 raise "End without start", l73 raise RuntimeError("End without start", l) 74 74 curname = None 75 75 continue … … 88 88 start, end = fields 89 89 except ValueError: 90 raise "Unpacking problem", l90 raise RuntimeError("Unpacking problem", l) 91 91 else: 92 92 start = end = fields[0] … … 147 147 del tables[0] 148 148 assert name == "B.1" 149 table = table.keys() 150 table.sort() 149 table = sorted(table.keys()) 151 150 print """ 152 151 b1_set = """ + compact_set(table) + """ … … 178 177 b3_exceptions[k] = u"".join(map(unichr,v)) 179 178 180 b3 = b3_exceptions.items() 181 b3.sort() 179 b3 = sorted(b3_exceptions.items()) 182 180 183 181 print """ … … 354 352 assert name == "C.6" 355 353 356 table = table.keys() 357 table.sort() 354 table = sorted(table.keys()) 358 355 359 356 print """ … … 368 365 assert name == "C.7" 369 366 370 table = table.keys() 371 table.sort() 367 table = sorted(table.keys()) 372 368 373 369 print """ … … 382 378 assert name == "C.8" 383 379 384 table = table.keys() 385 table.sort() 380 table = sorted(table.keys()) 386 381 387 382 print """ … … 396 391 assert name == "C.9" 397 392 398 table = table.keys() 399 table.sort() 393 table = sorted(table.keys()) 400 394 401 395 print """ -
python/vendor/current/Tools/webchecker/wcgui.py
r2 r388 64 64 import tktools 65 65 import webchecker 66 67 # Override some for a weaker platform68 if sys.platform == 'mac':69 webchecker.DEFROOT = "http://grail.cnri.reston.va.us/"70 webchecker.MAXPAGE = 5000071 webchecker.verbose = 472 66 73 67 def main(): -
python/vendor/current/Tools/webchecker/webchecker.py
r2 r388 104 104 105 105 106 __version__ = "$Revision : 50851$"106 __version__ = "$Revision$" 107 107 108 108 -
python/vendor/current/Tools/webchecker/websucker.py
r2 r388 3 3 """A variant on webchecker that creates a mirror copy of a remote site.""" 4 4 5 __version__ = "$Revision : 28654$"5 __version__ = "$Revision$" 6 6 7 7 import os … … 98 98 if os.sep != "/": 99 99 path = os.sep.join(path.split("/")) 100 if os.name == "mac":101 path = os.sep + path102 100 path = os.path.join(host, path) 103 101 return path -
python/vendor/current/Tools/world/world
r2 r388 80 80 Print this message. 81 81 """ 82 __version__ = '$Revision : 27624$'82 __version__ = '$Revision$' 83 83 84 84
Note:
See TracChangeset
for help on using the changeset viewer.