From 99582eb1446a54222f9f57fe48a7562a52a9fbf8 Mon Sep 17 00:00:00 2001
From: Patrick Steinhardt
Date: Thu, 23 May 2019 22:58:38 +0200
Subject: [PATCH] docs: call `replace` directory on string object
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 | 12 ++++++------
docs/zzipdoc/dbk2htm.py | 3 +--
2 files changed, 7 insertions(+), 8 deletions(-)
diff --git a/docs/make-doc.py b/docs/make-doc.py
index 36f594f..355fb7f 100644
--- a/docs/make-doc.py
+++ b/docs/make-doc.py
@@ -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 = { "" : "
", "
" : "",
"" : "
", "
" : "
" ,
"" : "", "" : "" }
- 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, "&", "&")
+ return text.replace("&", "&")
def cdata31(text):
- return string.replace(string.replace(text, "<","<"), ">",">")
+ text = text.replace("<","<")
+ return text.replace(">",">")
def cdata3(text):
return cdata31(cdata1(text))
def cdata43(text):
- return string.replace(text,"\"", """)
+ return text.replace("\"", """)
def cdata41(text):
return cdata43(cdata31(text))
def cdata4(text):
diff --git a/docs/zzipdoc/dbk2htm.py b/docs/zzipdoc/dbk2htm.py
index 42d95b1..b2d362f 100644
--- a/docs/zzipdoc/dbk2htm.py
+++ b/docs/zzipdoc/dbk2htm.py
@@ -1,5 +1,4 @@
from zzipdoc.match import Match
-import string
class dbk2htm_conversion:
mapping = { "" : "
", "
" : "",
@@ -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()
--
2.40.0