patch_pyxml.py

changeset 433
988006cb898f
parent 45
9a18f4dbb493
child 564
b3d966393ba9
diff -r 497e188ee86e -r 988006cb898f patch_pyxml.py
--- 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):
     """

eric ide

mercurial