void-packages/srcpkgs/python-docutils/patches/0017-Handle-ConfigParser-to...

94 lines
3.3 KiB
Diff

From bcc08592dd85f2e7805ab3528659a4396f109b30 Mon Sep 17 00:00:00 2001
From: Stephen Finucane <stephen@that.guru>
Date: Wed, 20 Nov 2019 00:05:43 +0700
Subject: [PATCH 17/26] Handle 'ConfigParser' to 'configparser' rename.
Based on a patch by Stephen Finucane.
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8364 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
---
docutils/frontend.py | 14 +++++++++-----
docutils/writers/odf_odt/__init__.py | 4 ++--
2 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/docutils/frontend.py b/docutils/frontend.py
index 627f603..815343d 100644
--- a/docutils/frontend.py
+++ b/docutils/frontend.py
@@ -33,10 +33,14 @@ import os
import os.path
import sys
import warnings
-import ConfigParser as CP
import codecs
import optparse
from optparse import SUPPRESS_HELP
+if sys.version_info >= (3,0):
+ from configparser import RawConfigParser
+else:
+ from ConfigParser import RawConfigParser
+
import docutils
import docutils.utils
import docutils.nodes
@@ -735,7 +739,7 @@ class OptionParser(optparse.OptionParser, docutils.SettingsSpec):
raise KeyError('No option with dest == %r.' % dest)
-class ConfigParser(CP.RawConfigParser):
+class ConfigParser(RawConfigParser):
old_settings = {
'pep_stylesheet': ('pep_html writer', 'stylesheet'),
@@ -757,7 +761,7 @@ Skipping "%s" configuration file.
"""
def __init__(self, *args, **kwargs):
- CP.RawConfigParser.__init__(self, *args, **kwargs)
+ RawConfigParser.__init__(self, *args, **kwargs)
self._files = []
"""List of paths of configuration files read."""
@@ -776,9 +780,9 @@ Skipping "%s" configuration file.
continue
try:
if sys.version_info < (3,2):
- CP.RawConfigParser.readfp(self, fp, filename)
+ RawConfigParser.readfp(self, fp, filename)
else:
- CP.RawConfigParser.read_file(self, fp, filename)
+ RawConfigParser.read_file(self, fp, filename)
except UnicodeDecodeError:
self._stderr.write(self.not_utf8_error % (filename, filename))
fp.close()
diff --git a/docutils/writers/odf_odt/__init__.py b/docutils/writers/odf_odt/__init__.py
index 75f846c..f36980f 100644
--- a/docutils/writers/odf_odt/__init__.py
+++ b/docutils/writers/odf_odt/__init__.py
@@ -30,10 +30,12 @@ from docutils import frontend, nodes, utils, writers, languages
from docutils.readers import standalone
from docutils.transforms import references
if type(sys.version_info)!=type((0,)) and sys.version_info.major >= 3:
+ from configparser import ConfigParser
from io import StringIO
from urllib.request import urlopen
from urllib.error import HTTPError
else:
+ from ConfigParser import ConfigParser
from StringIO import StringIO
from urllib2 import urlopen, HTTPError
@@ -938,8 +940,6 @@ class ODFTranslator(nodes.GenericNodeVisitor):
document.reporter)
self.format_map = {}
if self.settings.odf_config_file:
- from configparser import ConfigParser
-
parser = ConfigParser()
parser.read(self.settings.odf_config_file)
for rststyle, format in parser.items("Formats"):
--
2.24.0.375.geb5ae68d41