]> granicus.if.org Git - zziplib/commitdiff
docs: call `replace` directory on string object
authorPatrick Steinhardt <ps@pks.im>
Thu, 23 May 2019 20:58:38 +0000 (22:58 +0200)
committerPatrick Steinhardt <ps@pks.im>
Thu, 1 Aug 2019 08:14:04 +0000 (10:14 +0200)
In Python 3, the function string.replace has been removed in favor of
using replace on the string class directly. As Python 2.7 already
supports this variant, convert all instances of the old way to call
replace on the object.

docs/make-doc.py
docs/zzipdoc/dbk2htm.py

index 36f594f6a100f5c4f03523b3f018104d5e840b74..355fb7fbaaed892213a41bc70350df700c6f989d 100644 (file)
@@ -5,7 +5,6 @@ from __future__ import print_function
 
 import sys
 import re
-import string
 import commands
 import warnings
 
@@ -61,19 +60,20 @@ def section2html(text):
     mapping = { "<screen>" : "<pre>", "</screen>" : "</pre>",
                 "<para>" : "<p>", "</para>" : "</p>" ,
                 "<function>" : "<link>", "</function>" : "</link>" }
-    for str in mapping:
-        text = string.replace(text, str, mapping[str])
+    for m in mapping:
+        text = text.replace(m, mapping[m])
     return text
 def html(text):
     return section2html(paramdef2html(text))
 def cdata1(text):
-    return string.replace(text, "&",  "&amp;")
+    return text.replace("&",  "&amp;")
 def cdata31(text):
-    return string.replace(string.replace(text, "<","&lt;"), ">","&gt;")
+    text = text.replace("<","&lt;")
+    return text.replace(">","&gt;")
 def cdata3(text):
     return cdata31(cdata1(text))
 def cdata43(text):
-    return string.replace(text,"\"", "&quot;")
+    return text.replace("\"", "&quot;")
 def cdata41(text):
     return cdata43(cdata31(text))
 def cdata4(text):
index 42d95b17d7063e1527b3b1c6a85ef20ec533d9f7..b2d362fbc2449b3d5a278167f23de3084157c465 100644 (file)
@@ -1,5 +1,4 @@
 from zzipdoc.match import Match
-import string
 
 class dbk2htm_conversion:
     mapping = { "<screen>" : "<pre>", "</screen>" : "</pre>",
@@ -9,7 +8,7 @@ class dbk2htm_conversion:
         pass
     def section2html(self, text):
         for str in self.mapping:
-            text = string.replace(text, str, self.mapping[str])
+            text = text.replace(str, self.mapping[str])
         return text
     def paramdef2html(self, text):
         s = Match()