Fri, 30 Jul 2010 12:55:36 +0200
Did some more string format conversions.
eric5-api.py | file | annotate | diff | comparison | revisions | |
eric5-doc.py | file | annotate | diff | comparison | revisions | |
eric5.py | file | annotate | diff | comparison | revisions | |
install-i18n.py | file | annotate | diff | comparison | revisions | |
install.py | file | annotate | diff | comparison | revisions | |
patch_modpython.py | file | annotate | diff | comparison | revisions | |
patch_pyxml.py | file | annotate | diff | comparison | revisions |
--- a/eric5-api.py Thu Jul 29 20:00:59 2010 +0200 +++ b/eric5-api.py Fri Jul 30 12:55:36 2010 +0200 @@ -72,7 +72,7 @@ print(" Specify a directory basename to be excluded.") print(" This option may be repeated multiple times.") for lang in sorted(DocumentationTools.supportedExtensionsDictForApis.keys()): - print(" * %s" % lang) + print(" * {0}".format(lang)) print(" The default is 'Python'.") print(" This option may be repeated multiple times.") sys.exit(1) @@ -81,14 +81,14 @@ """ Function to show the version information. """ - print("""eric5-api %s + print("""eric5-api {0} Eric5 API generator. Copyright (c) 2004 - 2010 Detlev Offenbach <detlev@die-offenbachs.de> This is free software; see the LICENSE.GPL3 for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE.""" % Version) +PARTICULAR PURPOSE.""".format(Version)) sys.exit(1) def main(): @@ -133,7 +133,7 @@ version() elif k in ["-t", "--extension"]: if not v.startswith("."): - v = ".%s" % v + v = ".{0}".format(v) extensions.append(v) elif k in ["-b", "--base"]: basePackage = v @@ -143,7 +143,7 @@ if v not in progLanguages: if v not in \ list(DocumentationTools.supportedExtensionsDictForApis.keys()): - sys.stderr.write("Wrong language given: %s. Aborting\n" % v) + sys.stderr.write("Wrong language given: {0}. Aborting\n".format(v)) sys.exit(1) else: progLanguages.append(v) @@ -179,7 +179,7 @@ outputFile = outputFileName else: root, ext = os.path.splitext(outputFileName) - outputFile = "%s-%s%s" % (root, progLanguage.lower(), ext) + outputFile = "{0}-{1}{2}".format(root, progLanguage.lower(), ext) for arg in args: if os.path.isdir(arg): @@ -194,7 +194,7 @@ else: basename = arg if basename: - basename = "%s%s" % (basename, os.sep) + basename = "{0}{1}".format(basename, os.sep) if recursive and not os.path.islink(arg): names = [arg] + Utilities.getDirs(arg, excludeDirs) @@ -241,16 +241,16 @@ apiGenerator = APIGenerator(module) api = apiGenerator.genAPI(True, basePackage, includePrivate) except IOError as v: - sys.stderr.write("%s error: %s\n" % (file, v[1])) + sys.stderr.write("{0} error: {1}\n".format(file, v[1])) continue except ImportError as v: - sys.stderr.write("%s error: %s\n" % (file, v)) + sys.stderr.write("{0} error: {1}\n".format(file, v)) continue for apiEntry in api: if not apiEntry in apis: apis.append(apiEntry) - sys.stdout.write("-- %s -- %s ok\n" % (progLanguage, file)) + sys.stdout.write("-- {0} -- {1} ok\n".format(progLanguage, file)) outdir = os.path.dirname(outputFile) if outdir and not os.path.exists(outdir): @@ -260,7 +260,7 @@ out.write("\n".join(sorted(apis)) + "\n") out.close() except IOError as v: - sys.stderr.write("%s error: %s\n" % (outputFile, v[1])) + sys.stderr.write("{0} error: {1}\n".format(outputFile, v[1])) sys.exit(3) sys.stdout.write('\nDone.\n')
--- a/eric5-doc.py Thu Jul 29 20:00:59 2010 +0200 +++ b/eric5-doc.py Fri Jul 30 12:55:36 2010 +0200 @@ -118,14 +118,14 @@ """ Function to show the version information. """ - print("""eric5-doc %s + print("""eric5-doc {0} Eric5 API documentation generator. Copyright (c) 2003-2010 Detlev Offenbach <detlev@die-offenbachs.de> This is free software; see the LICENSE.GPL3 for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE.""" % Version) +PARTICULAR PURPOSE.""".format(Version)) sys.exit(1) def main(): @@ -194,7 +194,7 @@ stylesheetFile = v elif k in ["-t", "--extension"]: if not v.startswith("."): - v = ".%s" % v + v = ".{0}".format(v) supportedExtensions.append(v) elif k == "--eol": if v.lower() == "cr": @@ -257,7 +257,8 @@ try: os.makedirs(outputDir) except EnvironmentError: - sys.stderr.write("Could not create output directory %s." % outputDir) + sys.stderr.write( + "Could not create output directory {0}.".format(outputDir)) sys.exit(2) else: outputDir = os.getcwd() @@ -269,7 +270,8 @@ stylesheet = sf.read() sf.close() except IOError: - sys.stderr.write("The CSS stylesheet '%s' does not exist\n" % stylesheetFile) + sys.stderr.write( + "The CSS stylesheet '{0}' does not exist\n".format(stylesheetFile)) sys.stderr.write("Disabling CSS usage.\n") stylesheet = None else: @@ -283,8 +285,9 @@ try: os.makedirs(qtHelpOutputDir) except EnvironmentError: - sys.stderr.write("Could not create QtHelp output directory %s." % \ - qtHelpOutputDir) + sys.stderr.write( + "Could not create QtHelp output directory {0}.".format( + qtHelpOutputDir)) sys.exit(2) else: qtHelpOutputDir = os.getcwd() @@ -307,7 +310,7 @@ else: basename = arg if basename: - basename = "%s%s" % (basename, os.sep) + basename = "{0}{1}".format(basename, os.sep) if recursive and not os.path.islink(arg): names = [arg] + Utilities.getDirs(arg, excludeDirs) @@ -350,10 +353,10 @@ moduleDocument = ModuleDocument(module, colors, stylesheet) doc = moduleDocument.genDocument() except IOError as v: - sys.stderr.write("%s error: %s\n" % (file, v[1])) + sys.stderr.write("{0} error: {1}\n".format(file, v[1])) continue except ImportError as v: - sys.stderr.write("%s error: %s\n" % (file, v)) + sys.stderr.write("{0} error: {1}\n".format(file, v)) continue input = input + 1 @@ -378,9 +381,9 @@ out.write(doc) out.close() except IOError as v: - sys.stderr.write("%s error: %s\n" % (file, v[1])) + sys.stderr.write("{0} error: {1}\n".format(file, v[1])) else: - sys.stdout.write("%s ok\n" % f) + sys.stdout.write("{0} ok\n".format(f)) output = output + 1 sys.stdout.flush()
--- a/eric5.py Thu Jul 29 20:00:59 2010 +0200 +++ b/eric5.py Fri Jul 30 12:55:36 2010 +0200 @@ -84,7 +84,7 @@ client.processArgs(sys.argv[1:]) sys.exit(0) elif res < 0: - print("eric5: %s" % client.errstr()) + print("eric5: {0}".format(client.errstr())) sys.exit(res) def excepthook(excType, excValue, tracebackobj): @@ -99,24 +99,24 @@ logFile = os.path.join(Utilities.getConfigDir(), "eric5_error.log") notice = \ """An unhandled exception occurred. Please report the problem\n"""\ - """using the error reporting dialog or via email to <%s>.\n"""\ - """A log has been written to "%s".\n\nError information:\n""" % \ - (BugAddress, logFile) + """using the error reporting dialog or via email to <{0}>.\n"""\ + """A log has been written to "{1}".\n\nError information:\n""".format( + BugAddress, logFile) timeString = time.strftime("%Y-%m-%d, %H:%M:%S") - versionInfo = "\n%s\n%s" % (separator, Utilities.generateVersionInfo()) + versionInfo = "\n{0}\n{1}".format(separator, Utilities.generateVersionInfo()) pluginVersionInfo = Utilities.generatePluginsVersionInfo() if pluginVersionInfo: - versionInfo += "%s\n%s" % (separator, pluginVersionInfo) + versionInfo += "{0}\n{1}".format(separator, pluginVersionInfo) distroInfo = Utilities.generateDistroInfo() if distroInfo: - versionInfo += "%s\n%s" % (separator, distroInfo) + versionInfo += "{0}\n{1}".format(separator, distroInfo) tbinfofile = io.StringIO() traceback.print_tb(tracebackobj, None, tbinfofile) tbinfofile.seek(0) tbinfo = tbinfofile.read() - errmsg = '%s: \n%s' % (str(excType), str(excValue)) + errmsg = '{0}: \n{1}'.format(str(excType), str(excValue)) sections = [separator, timeString, separator, errmsg, separator, tbinfo] msg = '\n'.join(sections) try: @@ -240,7 +240,7 @@ # start the event loop res = app.exec_() - logging.debug("Shutting down, result %d" % res) + logging.debug("Shutting down, result {0:d}".format(res)) logging.shutdown() sys.exit(res) except Exception as err:
--- a/install-i18n.py Thu Jul 29 20:00:59 2010 +0200 +++ b/install-i18n.py Fri Jul 30 12:55:36 2010 +0200 @@ -57,10 +57,10 @@ print() print("Usage:") - print(" %s [-hp]" % (progName)) + print(" {0} [-hp]".format(progName)) print("where:") print(" -h display this help message") - print(" -p install into the private area (%s)" % (configDir)) + print(" -p install into the private area ({0})".format(configDir)) sys.exit(rcode) @@ -79,9 +79,11 @@ for fn in glob.glob(os.path.join('eric', 'i18n', '*.qm')): shutil.copy2(fn, targetDir) except IOError as msg: - sys.stderr.write('IOError: %s\nTry install-i18n as root.\n' % msg) + sys.stderr.write( + 'IOError: {0}\nTry install-i18n as root.\n'.format(msg)) except OSError as msg: - sys.stderr.write('OSError: %s\nTry install-i18n with admin rights.\n' % msg) + sys.stderr.write( + 'OSError: {0}\nTry install-i18n with admin rights.\n'.format(msg)) def main(argv): """
--- a/install.py Thu Jul 29 20:00:59 2010 +0200 +++ b/install.py Fri Jul 30 12:55:36 2010 +0200 @@ -50,22 +50,23 @@ print() print("Usage:") - print(" %s [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]" % (progName)) + print(" {0} [-chxz] [-a dir] [-b dir] [-d dir] [-f file] [-i dir]"\ + .format(progName)) print("where:") print(" -h display this help message") print(" -a dir where the API files will be installed") if apisDir: - print(" (default: %s)" % (apisDir)) + print(" (default: {0})".format(apisDir)) else: print(" (no default value)") print(" -b dir where the binaries will be installed") - print(" (default: %s)" % (platBinDir)) + print(" (default: {0})".format(platBinDir)) print(" -d dir where eric5 python files will be installed") - print(" (default: %s)" % (modDir)) + print(" (default: {0})".format(modDir)) print(" -f file configuration file naming the various installation paths") if not sys.platform.startswith("win"): print(" -i dir temporary install prefix") - print(" (default: %s)" % (distDir)) + print(" (default: {0})".format(distDir)) print(" -x don't perform dependency checks (use on your own risk)") print(" -c don't cleanup old installation first") print(" -z don't compile the installed python files") @@ -149,8 +150,8 @@ if sys.platform.startswith("win"): wname = wfile + ".bat" wrapper = \ -'''@"%s\\pythonw" "%s\\%s.py" %%1 %%2 %%3 %%4 %%5 %%6 %%7 %%8 %%9 -''' % (platBinDir, pydir, wfile) +'''@"{0}\\pythonw" "{1}\\{2}.py" %1 %2 %3 %4 %5 %6 %7 %8 %9 +'''.format(platBinDir, pydir, wfile) # Mac OS X elif sys.platform == "darwin": @@ -158,8 +159,8 @@ wrapper = \ '''#!/bin/sh -exec "%s/bin/pythonw3" "%s/%s.py" "$@" -''' % (sys.exec_prefix, pydir, wfile) +exec "{0}/bin/pythonw3" "{1}/{2}.py" "$@" +'''.format(sys.exec_prefix, pydir, wfile) # *nix systems else: @@ -167,8 +168,8 @@ wrapper = \ '''#!/bin/sh -exec "%s" "%s/%s.py" "$@" -''' % (sys.executable, pydir, wfile) +exec "{0}" "{1}/{2}.py" "$@" +'''.format(sys.executable, pydir, wfile) copyToFile(wname, wrapper) os.chmod(wname, 0o755) @@ -346,59 +347,65 @@ # copy the various parts of eric5 copyTree('eric', cfg['ericDir'], ['*.py', '*.pyc', '*.pyo', '*.pyw'], - ['eric%sExamples' % os.sep]) + ['eric{0}Examples'.format(os.sep)]) copyTree('eric', cfg['ericDir'], ['*.rb'], - ['eric%sExamples' % os.sep]) - copyTree('eric%sPlugins' % os.sep, '%s%sPlugins' % (cfg['ericDir'], os.sep), + ['eric{0}Examples'.format(os.sep)]) + copyTree('eric{0}Plugins'.format(os.sep), + '{0}{1}Plugins'.format(cfg['ericDir'], os.sep), ['*.png', '*.style']) - copyTree('eric%sDocumentation' % os.sep, cfg['ericDocDir'], ['*.html', '*.qch']) - copyTree('eric%sDTDs' % os.sep, cfg['ericDTDDir'], ['*.dtd']) - copyTree('eric%sCSSs' % os.sep, cfg['ericCSSDir'], ['*.css']) - copyTree('eric%sStyles' % os.sep, cfg['ericStylesDir'], ['*.qss']) - copyTree('eric%si18n' % os.sep, cfg['ericTranslationsDir'], ['*.qm']) - copyTree('eric%sicons' % os.sep, cfg['ericIconDir'], ['*.png', 'LICENSE*.*']) - copyTree('eric%spixmaps' % os.sep, cfg['ericPixDir'], ['*.png', '*.xpm', '*.ico']) - copyTree('eric%sDesignerTemplates' % os.sep, cfg['ericTemplatesDir'], ['*.tmpl']) - copyTree('eric%sCodeTemplates' % os.sep, cfg['ericCodeTemplatesDir'], ['*.tmpl']) - copyTree('eric%sExamples' % os.sep, cfg['ericExamplesDir'], - ['*.py', '*.pyc', '*.pyo']) + copyTree('eric{0}Documentation'.format(os.sep), cfg['ericDocDir'], + ['*.html', '*.qch']) + copyTree('eric{0}DTDs'.format(os.sep), cfg['ericDTDDir'], ['*.dtd']) + copyTree('eric{0}CSSs'.format(os.sep), cfg['ericCSSDir'], ['*.css']) + copyTree('eric{0}Styles'.format(os.sep), cfg['ericStylesDir'], ['*.qss']) + copyTree('eric{0}i18n'.format(os.sep), cfg['ericTranslationsDir'], ['*.qm']) + copyTree('eric{0}icons'.format(os.sep), cfg['ericIconDir'], + ['*.png', 'LICENSE*.*']) + copyTree('eric{0}pixmaps'.format(os.sep), cfg['ericPixDir'], + ['*.png', '*.xpm', '*.ico']) + copyTree('eric{0}DesignerTemplates'.format(os.sep), cfg['ericTemplatesDir'], + ['*.tmpl']) + copyTree('eric{0}CodeTemplates'.format(os.sep), cfg['ericCodeTemplatesDir'], + ['*.tmpl']) + copyTree('eric{0}Examples'.format(os.sep), cfg['ericExamplesDir'], + ['*.py', '*.pyc', '*.pyo']) # copy the wrappers for wname in wnames: shutil.copy(wname, cfg['bindir']) # copy the license file - shutil.copy('eric%sLICENSE.GPL3' % os.sep, cfg['ericDir']) + shutil.copy('eric{0}LICENSE.GPL3'.format(os.sep), cfg['ericDir']) # create the global plugins directory createGlobalPluginsDir() except IOError as msg: - sys.stderr.write('IOError: %s\nTry install as root.\n' % msg) + sys.stderr.write('IOError: {0}\nTry install as root.\n'.format(msg)) exit(7) except OSError as msg: - sys.stderr.write('OSError: %s\nTry install with admin rights.\n' % msg) + sys.stderr.write('OSError: {0}\nTry install with admin rights.\n'.format(msg)) exit(7) # copy some text files to the doc area for name in ["LICENSE.GPL3", "THANKS", "changelog"]: try: - shutil.copy('eric%s%s' % (os.sep, name), cfg['ericDocDir']) + shutil.copy('eric{0}{1}'.format(os.sep, name), cfg['ericDocDir']) except EnvironmentError: - print("Could not install 'eric%s%s'." % (os.sep, name)) + print("Could not install 'eric{0}{1}'.".format(os.sep, name)) for name in glob.glob(os.path.join('eric', 'README*.*')): try: shutil.copy(name, cfg['ericDocDir']) except EnvironmentError: - print("Could not install 'eric%s%s'." % (os.sep, name)) + print("Could not install 'eric{0}{1}'.".format(os.sep, name)) # copy some more stuff for name in ['default.e4k']: try: - shutil.copy('eric%s%s' % (os.sep, name), cfg['ericOthersDir']) + shutil.copy('eric{0}{1}'.format(os.sep, name), cfg['ericOthersDir']) except EnvironmentError: - print("Could not install 'eric%s%s'." % (os.sep, name)) + print("Could not install 'eric{0}{1}'.".format(os.sep, name)) # install the API file for progLanguage in progLanguages: @@ -409,14 +416,14 @@ try: shutil.copy(apiName, apidir) except EnvironmentError: - print("Could not install '%s'." % apiName) + print("Could not install '{0}'.".format(apiName)) if progLanguage == "Python": # copy Python3 API files to the same destination for apiName in glob.glob(os.path.join("eric", "APIs", "Python3", "*.api")): try: shutil.copy(apiName, apidir) except EnvironmentError: - print("Could not install '%s'." % apiName) + print("Could not install '{0}'.".format(apiName)) # create menu entry for Linux systems if sys.platform.startswith("linux"): @@ -484,22 +491,22 @@ # _pkg_config = { - 'ericDir' : r'%s', - 'ericPixDir' : r'%s', - 'ericIconDir' : r'%s', - 'ericDTDDir' : r'%s', - 'ericCSSDir' : r'%s', - 'ericStylesDir' : r'%s', - 'ericDocDir' : r'%s', - 'ericExamplesDir' : r'%s', - 'ericTranslationsDir' : r'%s', - 'ericTemplatesDir' : r'%s', - 'ericCodeTemplatesDir' : r'%s', - 'ericOthersDir' : r'%s', - 'bindir' : r'%s', - 'mdir' : r'%s', - 'apidir' : r'%s', - 'apis' : %s, + 'ericDir' : r'{0}', + 'ericPixDir' : r'{1}', + 'ericIconDir' : r'{2}', + 'ericDTDDir' : r'{3}', + 'ericCSSDir' : r'{4}', + 'ericStylesDir' : r'{5}', + 'ericDocDir' : r'{6}', + 'ericExamplesDir' : r'{7}', + 'ericTranslationsDir' : r'{8}', + 'ericTemplatesDir' : r'{9}', + 'ericCodeTemplatesDir' : r'{10}', + 'ericOthersDir' : r'{11}', + 'bindir' : r'{12}', + 'mdir' : r'{13}', + 'apidir' : r'{14}', + 'apis' : {15}, } def getConfig(name): @@ -513,15 +520,15 @@ except KeyError: pass - raise AttributeError('"%%s" is not a valid configuration value' %% name) -""" % (cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'], - cfg['ericDTDDir'], cfg['ericCSSDir'], - cfg['ericStylesDir'], cfg['ericDocDir'], - cfg['ericExamplesDir'], cfg['ericTranslationsDir'], - cfg['ericTemplatesDir'], - cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'], - cfg['bindir'], cfg['mdir'], - cfg['apidir'], apis) + raise AttributeError('"{{0}}" is not a valid configuration value'.format(name)) +""".format(cfg['ericDir'], cfg['ericPixDir'], cfg['ericIconDir'], + cfg['ericDTDDir'], cfg['ericCSSDir'], + cfg['ericStylesDir'], cfg['ericDocDir'], + cfg['ericExamplesDir'], cfg['ericTranslationsDir'], + cfg['ericTemplatesDir'], + cfg['ericCodeTemplatesDir'], cfg['ericOthersDir'], + cfg['bindir'], cfg['mdir'], + cfg['apidir'], apis) copyToFile(fn, config) def doDependancyChecks(): @@ -537,13 +544,13 @@ if sys.version_info > (3, 9, 9): print('Sorry, eric5 requires Python 3 for running.') exit(5) - print("Python Version: %d.%d.%d" % sys.version_info[:3]) + print("Python Version: {0:d}.{1:d}.{2:d}".format(*sys.version_info[:3])) try: from PyQt4.QtCore import qVersion except ImportError as msg: print('Sorry, please install PyQt4.') - print('Error: %s' % msg) + print('Error: {0}'.format(msg)) exit(1) print("Found PyQt") @@ -552,7 +559,7 @@ except ImportError as msg: print("Sorry, please install QScintilla2 and") print("it's PyQt4 wrapper.") - print('Error: %s' % msg) + print('Error: {0}'.format(msg)) exit(1) print("Found QScintilla2") @@ -562,7 +569,7 @@ if qtMajor < 4 or (qtMajor == 4 and qtMinor < 5): print('Sorry, you must have Qt version 4.5.0 or higher.') exit(2) - print("Qt Version: %s" % qVersion()) + print("Qt Version: {0}".format(qVersion())) #check version of PyQt from PyQt4.QtCore import PYQT_VERSION_STR @@ -680,7 +687,7 @@ @param py_file suggested name for the compile source file (string) @return tuple of directory name (string) and source file name (string) """ - return py_dir, "Ui_%s" % py_file + return py_dir, "Ui_{0}".format(py_file) compileUiDir("eric", True, pyName) @@ -731,8 +738,8 @@ try: exec(compile(open(arg).read(), arg, 'exec'), globals()) if len(cfg) != configLength: - print("The configuration dictionary in '%s' is incorrect. Aborting"\ - % arg) + print("The configuration dictionary in '{0}' is incorrect. Aborting"\ + .format(arg)) exit(6) except: cfg = {} @@ -757,7 +764,7 @@ else: cleanUp() except IOError as msg: - sys.stderr.write('IOError: %s\nTry install as root.\n' % msg) + sys.stderr.write('IOError: {0}\nTry install as root.\n'.format(msg)) # Create a config file and delete the default one createConfig() @@ -795,8 +802,8 @@ from eric5.patch_pyxml import isPatched, patchPyXML if not isPatched(): print("NOTE:") - print(" Found PyXML %d.%d.%d, which needs a patch to work correctly" % \ - (v[0], v[1], v[2])) + print(" Found PyXML {0:d}.{1:d}.{2:d}, which needs a patch " + "to work correctly".format(v[0], v[1], v[2])) print(" with foreign characters. Please see 'README-PyXML.txt' for") print(" details.") res = input(" Shall pyXML be patched now (y/n)? ")
--- a/patch_modpython.py Thu Jul 29 20:00:59 2010 +0200 +++ b/patch_modpython.py Fri Jul 30 12:55:36 2010 +0200 @@ -27,11 +27,11 @@ global progName, modDir print("Usage:") - print(" %s [-h] [-d dir]" % (progName)) + print(" {0} [-h] [-d dir]".format(progName)) print("where:") print(" -h display this help message") - print(" -d dir where Mod_python files are installed [default %s]" % \ - (modDir)) + print(" -d dir where Mod_python files are installed [default {0}]".format( + modDir)) print() print("This script patches the file apache.py of the Mod_python distribution") print("so that it will work with the eric5 debugger instead of pdb.") @@ -78,7 +78,7 @@ filename = os.path.join(modDir, "apache.py") f = open(filename, "r", encoding = "utf-8") except EnvironmentError: - print("The file %s does not exist. Aborting." % filename) + print("The file {0} does not exist. Aborting.".format(filename)) sys.exit(1) lines = f.readlines() @@ -118,12 +118,12 @@ try: py_compile.compile(sn) except py_compile.PyCompileError as e: - print("Error compiling %s. Aborting" % sn) + print("Error compiling {0}. Aborting".format(sn)) print(e) os.remove(sn) sys.exit(1) except SyntaxError as e: - print("Error compiling %s. Aborting" % sn) + print("Error compiling {0}. Aborting".format(sn)) print(e) os.remove(sn) sys.exit(1) @@ -132,15 +132,16 @@ os.path.join(modDir, "apache.py.orig")) shutil.copy(sn, modDir) os.remove(sn) - if os.path.exists("%sc" % sn): - shutil.copy("%sc" % sn, modDir) - os.remove("%sc" % sn) - if os.path.exists("%so" % sn): - shutil.copy("%so" % sn, modDir) - os.remove("%so" % sn) + if os.path.exists("{0}c".format(sn)): + shutil.copy("{0}c".format(sn), modDir) + os.remove("{0}c".format(sn)) + if os.path.exists("{0}o".format(sn)): + shutil.copy("{0}o".format(sn), modDir) + os.remove("{0}o".format(sn)) print("Mod_python patched successfully.") - print("Unpatched file copied to %s." % os.path.join(modDir, "apache.py.orig")) + print("Unpatched file copied to {0}.".format( + os.path.join(modDir, "apache.py.orig"))) if __name__ == "__main__":
--- a/patch_pyxml.py Thu Jul 29 20:00:59 2010 +0200 +++ b/patch_pyxml.py Fri Jul 30 12:55:36 2010 +0200 @@ -27,11 +27,11 @@ global progName, pyxmlModDir print("Usage:") - print(" %s [-h] [-d dir]" % (progName)) + print(" {0} [-h] [-d dir]".format(progName)) print("where:") print(" -h display this help message") - print(" -d dir where pyXML is installed [default %s]" % \ - (pyxmlModDir)) + print(" -d dir where pyXML is installed [default {0}]".format( + pyxmlModDir)) print() print("This script patches the file _xmlplus/parsers/xmlproc/xmlutils.py") print("of the pyXML distribution to fix a bug causing it to fail") @@ -101,7 +101,7 @@ os.path.join(pyxmlModDir, "parsers", "xmlproc", "xmlutils.py") f = open(filename, "r", encoding = "utf-8") except EnvironmentError: - print("The file %s does not exist. Aborting." % filename) + print("The file {0} does not exist. Aborting.".format(filename)) sys.exit(1) lines = f.readlines() @@ -136,28 +136,28 @@ try: py_compile.compile(sn) except py_compile.PyCompileError as e: - print("Error compiling %s. Aborting" % sn) + print("Error compiling {0}. Aborting".format(sn)) print(e) os.remove(sn) sys.exit(1) except SyntaxError as e: - print("Error compiling %s. Aborting" % sn) + print("Error compiling {0}. Aborting".format(sn)) print(e) os.remove(sn) sys.exit(1) - shutil.copy(filename, "%s.orig" % filename) + shutil.copy(filename, "{0}.orig".format(filename)) shutil.copy(sn, filename) os.remove(sn) - if os.path.exists("%sc" % sn): - shutil.copy("%sc" % sn, "%sc" % filename) - os.remove("%sc" % sn) - if os.path.exists("%so" % sn): - shutil.copy("%so" % sn, "%so" % filename) - os.remove("%so" % sn) + if os.path.exists("{0}c".format(sn)): + shutil.copy("{0}c".format(sn), "{0}c".format(filename)) + os.remove("{0}c".format(sn)) + if os.path.exists("{0}o".format(sn)): + shutil.copy("{0}o".format(sn), "{0}o".format(filename)) + os.remove("{0}o".format(sn)) print("xmlutils.py patched successfully.") - print("Unpatched file copied to %s.orig." % filename) + print("Unpatched file copied to {0}.orig.".format(filename)) def main(argv): """