|
From: <gr...@us...> - 2019-08-19 19:41:39
|
Revision: 8315
http://sourceforge.net/p/docutils/code/8315
Author: grubert
Date: 2019-08-19 19:41:38 +0000 (Mon, 19 Aug 2019)
Log Message:
-----------
Add regression test for odt contents
Fix: xml.etree.ElementTree Element.getchildren deprecated warning
Modified Paths:
--------------
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/test/test_writers/test_odt.py
Added Paths:
-----------
trunk/docutils/test/functional/expected/odt_contents.odt
trunk/docutils/test/functional/input/odt_contents.txt
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-19 19:31:52 UTC (rev 8314)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-19 19:41:38 UTC (rev 8315)
@@ -2763,8 +2763,7 @@
if WhichElementTree != "lxml":
s1 = s1.encode("utf-8")
el1 = etree.fromstring(s1)
- children = el1.getchildren()
- for child in children:
+ for child in el1:
self.current_element.append(child)
def depart_literal_block(self, node):
@@ -3460,7 +3459,7 @@
def update_toc_collect(self, el, level, collection):
collection.append((level, el))
level += 1
- for child_el in el.getchildren():
+ for child_el in el:
if child_el.tag != 'text:index-body':
self.update_toc_collect(child_el, level, collection)
Added: trunk/docutils/test/functional/expected/odt_contents.odt
===================================================================
(Binary files differ)
Index: trunk/docutils/test/functional/expected/odt_contents.odt
===================================================================
--- trunk/docutils/test/functional/expected/odt_contents.odt 2019-08-19 19:31:52 UTC (rev 8314)
+++ trunk/docutils/test/functional/expected/odt_contents.odt 2019-08-19 19:41:38 UTC (rev 8315)
Property changes on: trunk/docutils/test/functional/expected/odt_contents.odt
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/docutils/test/functional/input/odt_contents.txt
===================================================================
--- trunk/docutils/test/functional/input/odt_contents.txt (rev 0)
+++ trunk/docutils/test/functional/input/odt_contents.txt 2019-08-19 19:41:38 UTC (rev 8315)
@@ -0,0 +1,15 @@
+=================
+Table of contents
+=================
+
+.. contents::
+
+In short
+========
+
+Regression to test table of contents construction
+
+End
+===
+
+this
Property changes on: trunk/docutils/test/functional/input/odt_contents.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/docutils/test/test_writers/test_odt.py
===================================================================
--- trunk/docutils/test/test_writers/test_odt.py 2019-08-19 19:31:52 UTC (rev 8314)
+++ trunk/docutils/test/test_writers/test_odt.py 2019-08-19 19:41:38 UTC (rev 8315)
@@ -199,6 +199,9 @@
def test_odt_literal_block(self):
self.process_test('odt_literal_block.txt', 'odt_literal_block.odt')
+ def test_odt_contents(self):
+ self.process_test('odt_contents.txt', 'odt_contents.odt')
+
#
# Template for new tests.
# Also add functional/input/odt_xxxx.txt and
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2019-08-19 20:05:58
|
Revision: 8316
http://sourceforge.net/p/docutils/code/8316
Author: grubert
Date: 2019-08-19 20:05:56 +0000 (Mon, 19 Aug 2019)
Log Message:
-----------
Add odt classifier test
Fix: xml.etree.ElementTree Element.getchildren deprecated warning
Modified Paths:
--------------
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/test/test_writers/test_odt.py
Added Paths:
-----------
trunk/docutils/test/functional/expected/odt_classifier.odt
trunk/docutils/test/functional/input/odt_classifier.txt
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-19 19:41:38 UTC (rev 8315)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-19 20:05:56 UTC (rev 8316)
@@ -1938,9 +1938,8 @@
self.bumped_list_level_stack.pop()
def visit_classifier(self, node):
- els = self.current_element.getchildren()
- if len(els) > 0:
- el = els[-1]
+ if len(self.current_element) > 0:
+ el = self.current_element[-1]
el1 = SubElement(
el, 'text:span',
attrib={'text:style-name': self.rststyle('emphasis')})
Added: trunk/docutils/test/functional/expected/odt_classifier.odt
===================================================================
(Binary files differ)
Index: trunk/docutils/test/functional/expected/odt_classifier.odt
===================================================================
--- trunk/docutils/test/functional/expected/odt_classifier.odt 2019-08-19 19:41:38 UTC (rev 8315)
+++ trunk/docutils/test/functional/expected/odt_classifier.odt 2019-08-19 20:05:56 UTC (rev 8316)
Property changes on: trunk/docutils/test/functional/expected/odt_classifier.odt
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Added: trunk/docutils/test/functional/input/odt_classifier.txt
===================================================================
--- trunk/docutils/test/functional/input/odt_classifier.txt (rev 0)
+++ trunk/docutils/test/functional/input/odt_classifier.txt 2019-08-19 20:05:56 UTC (rev 8316)
@@ -0,0 +1,13 @@
+Definition Lists
+----------------
+
+Term
+ Definition
+Term : classifier
+ Definition paragraph 1.
+
+ Definition paragraph 2.
+Term
+ Definition
+
+
Property changes on: trunk/docutils/test/functional/input/odt_classifier.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Modified: trunk/docutils/test/test_writers/test_odt.py
===================================================================
--- trunk/docutils/test/test_writers/test_odt.py 2019-08-19 19:41:38 UTC (rev 8315)
+++ trunk/docutils/test/test_writers/test_odt.py 2019-08-19 20:05:56 UTC (rev 8316)
@@ -202,6 +202,9 @@
def test_odt_contents(self):
self.process_test('odt_contents.txt', 'odt_contents.odt')
+ def test_odt_classifier(self):
+ self.process_test('odt_classifier.txt', 'odt_classifier.odt')
+
#
# Template for new tests.
# Also add functional/input/odt_xxxx.txt and
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2019-08-20 12:26:23
|
Revision: 8325
http://sourceforge.net/p/docutils/code/8325
Author: grubert
Date: 2019-08-20 12:26:20 +0000 (Tue, 20 Aug 2019)
Log Message:
-----------
log
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/test/test_functional.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-08-20 12:24:58 UTC (rev 8324)
+++ trunk/docutils/HISTORY.txt 2019-08-20 12:26:20 UTC (rev 8325)
@@ -46,6 +46,10 @@
- Apply patch #157: avoid test failure because of a ``ResourceWarning``.
+* docutils/writers/odf_odt/__init__.py:
+
+ - Fix: ElementTree.getchildren deprecated warning
+
* test/test_writers/test_odt.py:
- Fix [ 359 ]: Test suite failes on Python 3.8. odt xml sorting.
Modified: trunk/docutils/test/test_functional.py
===================================================================
--- trunk/docutils/test/test_functional.py 2019-08-20 12:24:58 UTC (rev 8324)
+++ trunk/docutils/test/test_functional.py 2019-08-20 12:26:20 UTC (rev 8325)
@@ -126,9 +126,11 @@
namespace['settings_overrides'] = {'_disable_config': True}
# Read the variables set in the default config file and in
# the current config file into namespace:
- defaultpy = open(join_path(datadir, 'tests', '_default.py')).read()
- exec(defaultpy, namespace)
- exec(open(self.configfile).read(), namespace)
+ with open(join_path(datadir, 'tests', '_default.py')) as f:
+ defaultpy = f.read()
+ exec(defaultpy, namespace)
+ with open(self.configfile) as f:
+ exec(f.read(), namespace)
# Check for required settings:
assert 'test_source' in namespace,\
"No 'test_source' supplied in " + self.configfile
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2019-08-20 12:49:11
|
Revision: 8326
http://sourceforge.net/p/docutils/code/8326
Author: grubert
Date: 2019-08-20 12:49:09 +0000 (Tue, 20 Aug 2019)
Log Message:
-----------
Fix some [ 377 ] ResourceWarning: unclosed file
Modified Paths:
--------------
trunk/docutils/docutils/writers/s5_html/__init__.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
Modified: trunk/docutils/docutils/writers/s5_html/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/s5_html/__init__.py 2019-08-20 12:26:20 UTC (rev 8325)
+++ trunk/docutils/docutils/writers/s5_html/__init__.py 2019-08-20 12:49:09 UTC (rev 8326)
@@ -215,7 +215,8 @@
base_theme_file = os.path.join(path, self.base_theme_file)
# If it exists, read it and record the theme path:
if os.path.isfile(base_theme_file):
- lines = open(base_theme_file).readlines()
+ with open(base_theme_file) as f:
+ lines = f.readlines()
for line in lines:
line = line.strip()
if line and not line.startswith('#'):
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-20 12:26:20 UTC (rev 8325)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-20 12:49:09 UTC (rev 8326)
@@ -48,7 +48,8 @@
def null_bytes():
import csv
- csv_data = open(utf_16_csv, 'rb').read()
+ with open(utf_16_csv, 'rb') as f:
+ csv_data = f.read()
csv_data = unicode(csv_data, 'latin1').splitlines()
reader = csv.reader([tables.CSVTable.encode_for_csv(line + '\n')
for line in csv_data])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-21 11:53:36
|
Revision: 8331
http://sourceforge.net/p/docutils/code/8331
Author: milde
Date: 2019-08-21 11:53:33 +0000 (Wed, 21 Aug 2019)
Log Message:
-----------
Small comment/doc fixes.
Modified Paths:
--------------
trunk/docutils/docutils/__init__.py
trunk/docutils/test/test_utils.py
Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py 2019-08-21 11:46:58 UTC (rev 8330)
+++ trunk/docutils/docutils/__init__.py 2019-08-21 11:53:33 UTC (rev 8331)
@@ -61,7 +61,7 @@
major.minor[.micro][releaselevel[serial]][.dev]
-For version comparison operations, use `__version_info__` (which see, below)
+For version comparison operations, use `__version_info__` (see, below)
rather than parsing the text of `__version__`.
See 'Version Numbering' in docs/dev/policies.txt.
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2019-08-21 11:46:58 UTC (rev 8330)
+++ trunk/docutils/test/test_utils.py 2019-08-21 11:53:33 UTC (rev 8331)
@@ -237,6 +237,9 @@
class HelperFunctionTests(unittest.TestCase):
+ # Test conversion from `version information tuple` to a PEP 440 compliant
+ # Docutils version identifier.
+ # See 'Version Numbering' in docs/dev/policies.txt.
def test_version_identifier(self):
release_0_14_final = docutils.VersionInfo(
major=0, minor=14, micro=0,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-21 12:38:03
|
Revision: 8333
http://sourceforge.net/p/docutils/code/8333
Author: milde
Date: 2019-08-21 12:38:01 +0000 (Wed, 21 Aug 2019)
Log Message:
-----------
Remove legacy ImportError exception handlers (patch by Stephen Finucane).
See https://sourceforge.net/p/docutils/patches/150/
Modified Paths:
--------------
trunk/docutils/test/test_dependencies.py
trunk/docutils/tools/test/test_buildhtml.py
Modified: trunk/docutils/test/test_dependencies.py
===================================================================
--- trunk/docutils/test/test_dependencies.py 2019-08-21 11:55:48 UTC (rev 8332)
+++ trunk/docutils/test/test_dependencies.py 2019-08-21 12:38:01 UTC (rev 8333)
@@ -8,9 +8,9 @@
Test module for the --record-dependencies option.
"""
+import csv
import os.path
import unittest
-import sys
import DocutilsTestSupport # must be imported before docutils
import docutils.core
import docutils.utils
@@ -89,13 +89,9 @@
self.assertEqual(record, expected)
def test_csv_dependencies(self):
- try:
- import csv
- csvsource = os.path.join('data', 'csv_dep.txt')
- self.assertEqual(self.get_record(source_path=csvsource),
- ['data/csv_data.txt'])
- except ImportError:
- pass
+ csvsource = os.path.join('data', 'csv_dep.txt')
+ self.assertEqual(self.get_record(source_path=csvsource),
+ ['data/csv_data.txt'])
def test_stylesheet_dependencies(self):
stylesheet = paths['stylesheet']
Modified: trunk/docutils/tools/test/test_buildhtml.py
===================================================================
--- trunk/docutils/tools/test/test_buildhtml.py 2019-08-21 11:55:48 UTC (rev 8332)
+++ trunk/docutils/tools/test/test_buildhtml.py 2019-08-21 12:38:01 UTC (rev 8333)
@@ -24,15 +24,8 @@
import unittest
import os
-import re
-try:
- import tempfile
-except ImportError:
- pass
-try:
- from subprocess import Popen, PIPE, STDOUT
-except ImportError:
- pass
+from subprocess import Popen, PIPE, STDOUT
+import tempfile
buildhtml_path = os.path.abspath(os.path.join(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2019-08-25 09:53:38
|
Revision: 8336
http://sourceforge.net/p/docutils/code/8336
Author: grubert
Date: 2019-08-25 09:53:36 +0000 (Sun, 25 Aug 2019)
Log Message:
-----------
Apply fix for [ 289 ], line starting with ``.`` in a text.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_writers/test_manpage.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-08-25 09:40:56 UTC (rev 8335)
+++ trunk/docutils/HISTORY.txt 2019-08-25 09:53:36 UTC (rev 8336)
@@ -46,6 +46,10 @@
- Fix: ElementTree.getchildren deprecated warning
+* docutils/writers/manpage.py
+
+ - Apply fix for [ 289 ], line starting with ``.`` in a text.
+
* test/alltests.py
- Fix: 377 ResourceWarning: unclosed file python3.8
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2019-08-25 09:40:56 UTC (rev 8335)
+++ trunk/docutils/docutils/writers/manpage.py 2019-08-25 09:53:36 UTC (rev 8336)
@@ -958,8 +958,11 @@
self.ensure_eol()
if not self.first_child(node):
self.body.append('.sp\n')
+ # set in literal to escape dots after a new-line-character
+ self._in_literal = True
def depart_paragraph(self, node):
+ self._in_literal = False
self.body.append('\n')
def visit_problematic(self, node):
Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py 2019-08-25 09:40:56 UTC (rev 8335)
+++ trunk/docutils/test/test_writers/test_manpage.py 2019-08-25 09:53:36 UTC (rev 8336)
@@ -137,6 +137,9 @@
something important
. period at line start.
+
+and . in a line and at line start
+.in a paragraph
""",
r""".\" Man page generated from reStructuredText.
.
@@ -195,6 +198,9 @@
.UNINDENT
.sp
\&. period at line start.
+.sp
+and . in a line and at line start
+\&.in a paragraph
.SH AUTHOR
so...@so...
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 12:09:26
|
Revision: 8337
http://sourceforge.net/p/docutils/code/8337
Author: milde
Date: 2019-08-26 12:09:23 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
Remove unused lxml import blocks
These have been commented out for over 10 years [1] and aren't coming
back. Remove them along with checks for the 'xml' library, which is
present in all versions of Python we support.
[1] https://sourceforge.net/p/docutils/code/5846/
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/test/test_writers/test_odt.py
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-25 09:53:36 UTC (rev 8336)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-26 12:09:23 UTC (rev 8337)
@@ -15,16 +15,18 @@
import os.path
import tempfile
import zipfile
+from xml.etree import ElementTree as etree
from xml.dom import minidom
import time
import re
import copy
import itertools
-import docutils
+import weakref
try:
import locale # module missing in Jython
except ImportError:
pass
+import docutils
from docutils import frontend, nodes, utils, writers, languages
from docutils.readers import standalone
from docutils.transforms import references
@@ -40,27 +42,6 @@
VERSION = '1.0a'
IMAGE_NAME_COUNTER = itertools.count()
-WhichElementTree = ''
-try:
- # 1. Try to use lxml.
- #from lxml import etree
- #WhichElementTree = 'lxml'
- raise ImportError('Ignoring lxml')
-except ImportError:
- try:
- # 2. Try to use ElementTree from the Python standard library.
- from xml.etree import ElementTree as etree
- WhichElementTree = 'elementtree'
- except ImportError:
- try:
- # 3. Try to use a version of ElementTree installed as a separate
- # product.
- from elementtree import ElementTree as etree
- WhichElementTree = 'elementtree'
- except ImportError:
- s1 = 'Must install either a version of Python containing ' \
- 'ElementTree (Python version >=2.5) or install ElementTree.'
- raise ImportError(s1)
#
# Import pygments and odtwriter pygments formatters if possible.
@@ -104,24 +85,22 @@
# This wrapper class and the following support functions provide
# that support for the ability to get the parent of an element.
#
-if WhichElementTree == 'elementtree':
- import weakref
- _parents = weakref.WeakKeyDictionary()
- if isinstance(etree.Element, type):
- _ElementInterface = etree.Element
- else:
- _ElementInterface = etree._ElementInterface
+_parents = weakref.WeakKeyDictionary()
+if isinstance(etree.Element, type):
+ _ElementInterface = etree.Element
+else:
+ _ElementInterface = etree._ElementInterface
- class _ElementInterfaceWrapper(_ElementInterface):
- def __init__(self, tag, attrib=None):
- _ElementInterface.__init__(self, tag, attrib)
- _parents[self] = None
+class _ElementInterfaceWrapper(_ElementInterface):
+ def __init__(self, tag, attrib=None):
+ _ElementInterface.__init__(self, tag, attrib)
+ _parents[self] = None
- def setparent(self, parent):
- _parents[self] = parent
+ def setparent(self, parent):
+ _parents[self] = parent
- def getparent(self):
- return _parents[self]
+ def getparent(self):
+ return _parents[self]
#
@@ -209,9 +188,8 @@
'xlink': 'http://www.w3.org/1999/xlink',
}
-#
-# Attribute dictionaries for use with ElementTree (not lxml), which
-# does not support use of nsmap parameter on Element() and SubElement().
+# Attribute dictionaries for use with ElementTree, which
+# does not support use of nsmap parameter on Element() and SubElement().
CONTENT_NAMESPACE_ATTRIB = {
#'office:version': '1.0',
@@ -295,10 +273,7 @@
if attrib is None:
attrib = {}
tag, attrib = fix_ns(tag, attrib, nsdict)
- if WhichElementTree == 'lxml':
- el = etree.Element(tag, attrib, nsmap=nsmap)
- else:
- el = _ElementInterfaceWrapper(tag, attrib)
+ el = _ElementInterfaceWrapper(tag, attrib)
return el
@@ -306,12 +281,9 @@
if attrib is None:
attrib = {}
tag, attrib = fix_ns(tag, attrib, nsdict)
- if WhichElementTree == 'lxml':
- el = etree.SubElement(parent, tag, attrib, nsmap=nsmap)
- else:
- el = _ElementInterfaceWrapper(tag, attrib)
- parent.append(el)
- el.setparent(parent)
+ el = _ElementInterfaceWrapper(tag, attrib)
+ parent.append(el)
+ el.setparent(parent)
return el
@@ -325,12 +297,6 @@
def add_ns(tag, nsdict=CNSD):
- if WhichElementTree == 'lxml':
- nstag, name = tag.split(':')
- ns = nsdict.get(nstag)
- if ns is None:
- raise RuntimeError('Invalid namespace prefix: %s' % nstag)
- tag = '{%s}%s' % (ns, name,)
return tag
@@ -777,18 +743,11 @@
pass
def create_manifest(self):
- if WhichElementTree == 'lxml':
- root = Element(
- 'manifest:manifest',
- nsmap=MANIFEST_NAMESPACE_DICT,
- nsdict=MANIFEST_NAMESPACE_DICT,
- )
- else:
- root = Element(
- 'manifest:manifest',
- attrib=MANIFEST_NAMESPACE_ATTRIB,
- nsdict=MANIFEST_NAMESPACE_DICT,
- )
+ root = Element(
+ 'manifest:manifest',
+ attrib=MANIFEST_NAMESPACE_ATTRIB,
+ nsdict=MANIFEST_NAMESPACE_DICT,
+ )
doc = etree.ElementTree(root)
SubElement(root, 'manifest:file-entry', attrib={
'manifest:media-type': self.MIME_TYPE,
@@ -816,18 +775,11 @@
return s1
def create_meta(self):
- if WhichElementTree == 'lxml':
- root = Element(
- 'office:document-meta',
- nsmap=META_NAMESPACE_DICT,
- nsdict=META_NAMESPACE_DICT,
- )
- else:
- root = Element(
- 'office:document-meta',
- attrib=META_NAMESPACE_ATTRIB,
- nsdict=META_NAMESPACE_DICT,
- )
+ root = Element(
+ 'office:document-meta',
+ attrib=META_NAMESPACE_ATTRIB,
+ nsdict=META_NAMESPACE_DICT,
+ )
doc = etree.ElementTree(root)
root = SubElement(root, 'office:meta', nsdict=METNSD)
el1 = SubElement(root, 'meta:generator', nsdict=METNSD)
@@ -957,16 +909,10 @@
self.section_level = 0
self.section_count = 0
# Create ElementTree content and styles documents.
- if WhichElementTree == 'lxml':
- root = Element(
- 'office:document-content',
- nsmap=CONTENT_NAMESPACE_DICT,
- )
- else:
- root = Element(
- 'office:document-content',
- attrib=CONTENT_NAMESPACE_ATTRIB,
- )
+ root = Element(
+ 'office:document-content',
+ attrib=CONTENT_NAMESPACE_ATTRIB,
+ )
self.content_tree = etree.ElementTree(element=root)
self.current_element = root
SubElement(root, 'office:scripts')
@@ -1213,14 +1159,11 @@
return
el1 = master_el
if self.header_content or self.settings.custom_header:
- if WhichElementTree == 'lxml':
- el2 = SubElement(el1, 'style:header', nsdict=SNSD)
- else:
- el2 = SubElement(
- el1, 'style:header',
- attrib=STYLES_NAMESPACE_ATTRIB,
- nsdict=STYLES_NAMESPACE_DICT,
- )
+ el2 = SubElement(
+ el1, 'style:header',
+ attrib=STYLES_NAMESPACE_ATTRIB,
+ nsdict=STYLES_NAMESPACE_DICT,
+ )
for el in self.header_content:
attrkey = add_ns('text:style-name', nsdict=SNSD)
el.attrib[attrkey] = self.rststyle('header')
@@ -1230,14 +1173,11 @@
el2,
self.settings.custom_header, 'header', automatic_styles)
if self.footer_content or self.settings.custom_footer:
- if WhichElementTree == 'lxml':
- el2 = SubElement(el1, 'style:footer', nsdict=SNSD)
- else:
- el2 = SubElement(
- el1, 'style:footer',
- attrib=STYLES_NAMESPACE_ATTRIB,
- nsdict=STYLES_NAMESPACE_DICT,
- )
+ el2 = SubElement(
+ el1, 'style:footer',
+ attrib=STYLES_NAMESPACE_ATTRIB,
+ nsdict=STYLES_NAMESPACE_DICT,
+ )
for el in self.footer_content:
attrkey = add_ns('text:style-name', nsdict=SNSD)
el.attrib[attrkey] = self.rststyle('footer')
@@ -2758,8 +2698,7 @@
lines1.append(my_lines_str2)
lines1.append('</wrappertag1>')
s1 = ''.join(lines1)
- if WhichElementTree != "lxml":
- s1 = s1.encode("utf-8")
+ s1 = s1.encode("utf-8")
el1 = etree.fromstring(s1)
for child in el1:
self.current_element.append(child)
@@ -2981,8 +2920,7 @@
'%s="%s"' % (k, v, )
for k, v in list(CONTENT_NAMESPACE_ATTRIB.items())])
contentstr = '<stuff %s>%s</stuff>' % (attrstr, rawstr, )
- if WhichElementTree != "lxml":
- contentstr = contentstr.encode("utf-8")
+ contentstr = contentstr.encode("utf-8")
content = etree.fromstring(contentstr)
if len(content) > 0:
el1 = content[0]
Modified: trunk/docutils/test/test_writers/test_odt.py
===================================================================
--- trunk/docutils/test/test_writers/test_odt.py 2019-08-25 09:53:36 UTC (rev 8336)
+++ trunk/docutils/test/test_writers/test_odt.py 2019-08-26 12:09:23 UTC (rev 8337)
@@ -30,11 +30,9 @@
"""
-import sys
import os
import zipfile
-import xml.etree.ElementTree as ET
-import tempfile
+import xml.etree.ElementTree as etree
from __init__ import DocutilsTestSupport
@@ -49,41 +47,9 @@
EXPECTED_PATH = 'functional/expected/'
class DocutilsOdtTestCase(DocutilsTestSupport.StandardTestCase):
- #
- # Check to see if we can import the needed XML library.
- # Report failure if we cannot.
- def check_import(self):
- WhichElementTree = ''
- try:
- # 1. Try to use lxml.
- #from lxml import etree
- #WhichElementTree = 'lxml'
- raise ImportError('Ignoring lxml')
- except ImportError as e:
- try:
- # 2. Try to use ElementTree from the Python standard library.
- from xml.etree import ElementTree as etree
- WhichElementTree = 'elementtree'
- except ImportError as e:
- try:
- # 3. Try to use a version of ElementTree installed as a separate
- # product.
- from elementtree import ElementTree as etree
- WhichElementTree = 'elementtree'
- except ImportError as e:
- s1 = '\nSkipped test of odf_odt writer. ' \
- 'In order to test odf_odt writer ' \
- 'must install either a version of Python containing ' \
- 'ElementTree (Python version >=2.5) or ' \
- 'install ElementTree.\n\n'
- #self.fail(s1)
- sys.stderr.write(s1)
- return WhichElementTree
def process_test(self, input_filename, expected_filename,
save_output_name=None, settings_overrides=None):
- if not self.check_import():
- return
# Test that xmlcharrefreplace is the default output encoding
# error handler.
input_file = open(INPUT_PATH + input_filename, 'rb')
@@ -135,10 +101,10 @@
payloadfile.seek(0)
zfile = zipfile.ZipFile(payloadfile, 'r')
content1 = zfile.read(filename)
- doc = ET.fromstring(content1)
+ doc = etree.fromstring(content1)
self.reorder_attributes(doc)
#content2 = doc.toprettyxml(indent=' ')
- content2 = ET.tostring(doc)
+ content2 = etree.tostring(doc)
return content2
def assertEqual(self, first, second, msg=None):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 12:09:45
|
Revision: 8338
http://sourceforge.net/p/docutils/code/8338
Author: milde
Date: 2019-08-26 12:09:42 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
Drop support for Python 3.3
This doesn't involve a whole lot of changes, but references to Python
3.3 (plus some to the already removed Python 2.6) are removed and
'setup.py' is updated as necessary.
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/README.txt
trunk/docutils/docs/dev/distributing.txt
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/utils/code_analyzer.py
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/setup.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
trunk/docutils/test/test_utils.py
trunk/docutils/test/test_writers/test_odt.py
trunk/docutils/tools/buildhtml.py
trunk/docutils/tox.ini
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/HISTORY.txt 2019-08-26 12:09:42 UTC (rev 8338)
@@ -20,7 +20,7 @@
* General
- - Dropped support for Python 2.6 (work in progress).
+ - Dropped support for Python 2.6, Python 3.3 (work in progress).
- Keep `backslash escapes`__ in the document tree. Backslash characters in
text are be represented by NULL characters in the ``text`` attribute of
Doctree nodes and removed in the writing stage by the node's
Modified: trunk/docutils/README.txt
===================================================================
--- trunk/docutils/README.txt 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/README.txt 2019-08-26 12:09:42 UTC (rev 8338)
@@ -16,7 +16,7 @@
This is for those who want to get up & running quickly.
-1. Docutils requires Python (version 2.6 or later), available from
+1. Docutils requires Python (version 2.7 or later), available from
http://www.python.org/
Modified: trunk/docutils/docs/dev/distributing.txt
===================================================================
--- trunk/docutils/docs/dev/distributing.txt 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/docs/dev/distributing.txt 2019-08-26 12:09:42 UTC (rev 8338)
@@ -28,7 +28,7 @@
Docutils has the following dependencies:
-* Python 2.6 or later is required. Use ">= Python 2.6" in the
+* Python 2.7 or later is required. Use ">= Python 2.7" in the
dependencies.
* Docutils may optionally make use of the PIL (`Python Imaging
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/docutils/frontend.py 2019-08-26 12:09:42 UTC (rev 8338)
@@ -777,7 +777,7 @@
except IOError:
continue
try:
- if sys.version_info < (3,2):
+ if sys.version_info < (3, 0):
CP.RawConfigParser.readfp(self, fp, filename)
else:
CP.RawConfigParser.read_file(self, fp, filename)
Modified: trunk/docutils/docutils/utils/code_analyzer.py
===================================================================
--- trunk/docutils/docutils/utils/code_analyzer.py 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/docutils/utils/code_analyzer.py 2019-08-26 12:09:42 UTC (rev 8338)
@@ -18,7 +18,7 @@
from pygments.lexers import get_lexer_by_name
from pygments.formatters.html import _get_ttype_class
with_pygments = True
-except (ImportError, SyntaxError): # pygments 2.0.1 fails with Py 3.1 and 3.2
+except ImportError:
with_pygments = False
# Filter the following token types from the list of class arguments:
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-26 12:09:42 UTC (rev 8338)
@@ -22,10 +22,12 @@
import copy
import itertools
import weakref
+
try:
import locale # module missing in Jython
except ImportError:
pass
+
import docutils
from docutils import frontend, nodes, utils, writers, languages
from docutils.readers import standalone
@@ -91,6 +93,7 @@
else:
_ElementInterface = etree._ElementInterface
+
class _ElementInterfaceWrapper(_ElementInterface):
def __init__(self, tag, attrib=None):
_ElementInterface.__init__(self, tag, attrib)
@@ -302,7 +305,7 @@
def ToString(et):
outstream = StringIO()
- if sys.version_info >= (3, 2):
+ if sys.version_info >= (3, 0):
et.write(outstream, encoding="unicode")
else:
et.write(outstream)
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/setup.py 2019-08-26 12:09:42 UTC (rev 8338)
@@ -123,7 +123,7 @@
'maintainer_email': 'doc...@li...',
'license': 'public domain, Python, 2-Clause BSD, GPL 3 (see COPYING.txt)',
'platforms': 'OS-independent',
- 'python_requires': '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*',
+ 'python_requires': '>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*',
'package_dir': {'docutils': 'docutils',
'docutils.tools': 'tools'},
'packages': ['docutils',
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/test/test_error_reporting.py 2019-08-26 12:09:42 UTC (rev 8338)
@@ -27,7 +27,6 @@
import unittest
import sys, os
-import codecs
from io import StringIO, BytesIO
import DocutilsTestSupport # must be imported before docutils
@@ -35,15 +34,13 @@
from docutils.utils.error_reporting import SafeString, ErrorString, ErrorOutput
oldlocale = None
-if sys.version_info < (3,0): # problems solved in py3k
+if sys.version_info < (3, 0): # problems solved in py3k
try:
- import locale # module missing in Jython
+ import locale # module missing in Jython
oldlocale = locale.getlocale()
- # Why does getlocale return the defaultlocale in Python 3.2 ????
- # oldlocale = (None, None) # test suite runs without locale
except ImportError:
print ('cannot test error reporting with problematic locales,\n'
- '`import locale` failed.')
+ '`import locale` failed.')
# locales confirmed to use non-ASCII chars in the IOError message
@@ -81,8 +78,6 @@
us = u'\xfc' # bytes(us) fails; str(us) fails in Python 2
be = Exception(bs) # unicode(be) fails
ue = Exception(us) # bytes(ue) fails, str(ue) fails in Python 2;
- # unicode(ue) fails in Python < 2.6 (issue2517_)
- # .. _issue2517: http://bugs.python.org/issue2517
# wrapped test data:
wbs = SafeString(bs)
wus = SafeString(us)
@@ -114,7 +109,7 @@
self.assertEqual(unicode(self.us), unicode(self.wus))
# unicode(self.be) fails
self.assertEqual(unicode, type(unicode(self.wbe)))
- # unicode(ue) fails in Python < 2.6 (issue2517_)
+ self.assertEqual(unicode, type(unicode(self.ue)))
self.assertEqual(unicode, type(unicode(self.wue)))
self.assertEqual(self.us, unicode(self.wue))
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-26 12:09:42 UTC (rev 8338)
@@ -10,7 +10,8 @@
from __init__ import DocutilsTestSupport
-import os, sys
+import os
+import sys
import csv
import platform
from docutils.parsers.rst.directives import tables
@@ -33,21 +34,20 @@
else:
unichr_exception_string = str(unichr_exception)
-# some error messages changed in Python 3.3:
-# CPython has backported to 2.7.4, PyPy has not
-# platform.python_implementation is new in 2.6
+# some error messages changed in Python 3.3, CPython has backported to 2.7.4,
+# PyPy has not
csv_eod_error_str = 'unexpected end of data'
if sys.version_info < (2,7,4) or platform.python_implementation() == 'PyPy':
csv_eod_error_str = 'newline inside string'
# pypy adds a line number
-if sys.version_info > (2, 6) and platform.python_implementation() == 'PyPy':
+if sys.version_info > (2, 7) and platform.python_implementation() == 'PyPy':
csv_eod_error_str = 'line 1: ' + csv_eod_error_str
csv_unknown_url = "'bogus.csv'"
-if sys.version_info < (3,3,2):
+if sys.version_info < (3, 0):
csv_unknown_url = "bogus.csv"
+
def null_bytes():
- import csv
with open(utf_16_csv, 'rb') as f:
csv_data = f.read()
csv_data = unicode(csv_data, 'latin1').splitlines()
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/test/test_utils.py 2019-08-26 12:09:42 UTC (rev 8338)
@@ -9,14 +9,11 @@
Test module for utils/__init__.py.
"""
+from io import StringIO
+import os
import unittest
-import sys
-import os
+
from DocutilsTestSupport import docutils, utils, nodes
-try:
- from io import StringIO
-except ImportError: # io is new in Python 2.6
- from StringIO import StringIO
class ReporterTests(unittest.TestCase):
Modified: trunk/docutils/test/test_writers/test_odt.py
===================================================================
--- trunk/docutils/test/test_writers/test_odt.py 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/test/test_writers/test_odt.py 2019-08-26 12:09:42 UTC (rev 8338)
@@ -46,6 +46,7 @@
INPUT_PATH = 'functional/input/'
EXPECTED_PATH = 'functional/expected/'
+
class DocutilsOdtTestCase(DocutilsTestSupport.StandardTestCase):
def process_test(self, input_filename, expected_filename,
Modified: trunk/docutils/tools/buildhtml.py
===================================================================
--- trunk/docutils/tools/buildhtml.py 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/tools/buildhtml.py 2019-08-26 12:09:42 UTC (rev 8338)
@@ -241,7 +241,7 @@
writer_name=pub_struct.writer_name,
settings=settings)
except ApplicationError:
- error = sys.exc_info()[1] # get exception in Python <2.6 and 3.x
+ error = sys.exc_info()[1] # get exception in Python 3.x
errout.write(' %s\n' % ErrorString(error))
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2019-08-26 12:09:23 UTC (rev 8337)
+++ trunk/docutils/tox.ini 2019-08-26 12:09:42 UTC (rev 8338)
@@ -1,5 +1,5 @@
[tox]
-envlist = py27, py33, py34, py35, py36, py37
+envlist = py{27,34,35,36,37}
[testenv]
commands = python test/alltests.py
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 12:10:36
|
Revision: 8343
http://sourceforge.net/p/docutils/code/8343
Author: milde
Date: 2019-08-26 12:10:34 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
Drop support for Python 3.4
This doesn't involve a whole lot of changes, but references to Python
3.3 and 3.4 (plus some to the already removed Python 2.6) are removed
and 'setup.py' is updated as necessary. This has already been agreed
upon, as noted in RELEASE-NOTES.txt:
Docutils 0.15.x is the last version supporting Python 2.6, 3.3, and 3.4.
Docutils 0.16 is compatible with Python versions 2.7 and 3.5 to 3.7.
Signed-off-by: Stephen Finucane <st...@th...>
Small fixes by Gunter Milde.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/README.txt
trunk/docutils/docs/dev/testing.txt
trunk/docutils/setup.py
trunk/docutils/tox.ini
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2019-08-26 12:10:23 UTC (rev 8342)
+++ trunk/docutils/HISTORY.txt 2019-08-26 12:10:34 UTC (rev 8343)
@@ -20,7 +20,7 @@
* General
- - Dropped support for Python 2.6, Python 3.3 (work in progress).
+ - Dropped support for Python 2.6, 3.3 and 3.4 (work in progress).
- Keep `backslash escapes`__ in the document tree. Backslash characters in
text are be represented by NULL characters in the ``text`` attribute of
Doctree nodes and removed in the writing stage by the node's
Modified: trunk/docutils/README.txt
===================================================================
--- trunk/docutils/README.txt 2019-08-26 12:10:23 UTC (rev 8342)
+++ trunk/docutils/README.txt 2019-08-26 12:10:34 UTC (rev 8343)
@@ -104,7 +104,7 @@
To run the code, Python_ must be installed.
Docutils is compatible with Python versions 2.7, and
-versions 3.3 to 3.7 (cf. `Python 3 compatibility`_).
+versions 3.5 to 3.7 (cf. `Python 3 compatibility`_).
Docutils uses the following packages for enhanced functionality, if they are
installed:
Modified: trunk/docutils/docs/dev/testing.txt
===================================================================
--- trunk/docutils/docs/dev/testing.txt 2019-08-26 12:10:23 UTC (rev 8342)
+++ trunk/docutils/docs/dev/testing.txt 2019-08-26 12:10:34 UTC (rev 8343)
@@ -38,29 +38,27 @@
Python Versions
===============
-A docutils release has a commitment to support a minimum version and
-beyond. Before a release is cut, tests must pass in all supported python
-versions.
+A docutils release has a commitment to support a minimum version and beyond.
+Before a release is cut, tests must pass in all supported Python versions.
-The Docutils 0.15 release supports Python 2.6 or later.
+The Docutils 0.15 release supports Python 2.7 and Python 3.5 or later.
-Therefore, you should install python 2.6, 2.7 as well as 3.3 up to the
-latest Python (3.5 at the time of this writing) installed and always run the
-tests on all of them. In a pinch, the edge cases (2.6, and 3.5) should cover
-most of it.
+Therefore, you should install Python 2.7 as well as 3.5 up to the latest Python
+(3.7 at the time of this writing) and always run the tests on all of
+them. In a pinch, the edge cases (2.7, and 3.7) should cover most of it.
Good resources covering the differences between Python versions:
-* `What's New in Python 2.6`__
* `What's New in Python 2.7`__
-* `What's New in Python 3.3`__
-* `What's New in Python 3.4`__
+* `What's New in Python 3.5`__
+* `What's New in Python 3.6`__
+* `What's New in Python 3.7`__
* `PEP 290 - Code Migration and Modernization`__
-__ http://docs.python.org/whatsnew/2.6.html
-__ http://docs.python.org/whatsnew/2.7.html
-__ https://docs.python.org/3/whatsnew/3.3.html
-__ https://docs.python.org/3/whatsnew/3.4.html
+__ https://docs.python.org/whatsnew/2.6.html
+__ https://docs.python.org/3/whatsnew/3.5.html
+__ https://docs.python.org/3/whatsnew/3.6.html
+__ https://docs.python.org/3/whatsnew/3.7.html
__ http://www.python.org/peps/pep-0290.html
.. _Python Check-in Policies: http://www.python.org/dev/tools.html
@@ -76,20 +74,19 @@
test multiple python versions::
# assuming your system runs 2.7.x
- pyenv install 2.6.9
- pyenv install 3.3.6
- pyenv install 3.4.3
- pyenv global system 2.6.9 3.3.6 3.4.3
+ pyenv install 3.5.7
+ pyenv install 3.6.9
+ pyenv install 3.7.3
+ pyenv global system 3.5.7 3.6.9 3.7.3
# reset your shims
rm -rf ~/.pyenv/shims && pyenv rehash
-This will give you ``python2.6``, ``python2.7``, ``python3.3`` and
-``python3.4``. Along with that, ``pip2.6``, ``pip2.7`` and so on.
+This will give you ``python2.7`` and ``python3.5`` through ``python3.7``.
+You will also get ``pip2.7``, ``pip3.5``, etc.
-To save time, you can use `tox`_. To
-install tox, you can use ``easy_install tox`` or ``pip install tox``.
-From shell::
+To save time, you can use `tox`_. To install tox, run ``pip install tox``.
+Once installed, from shell::
cd docutils
tox
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2019-08-26 12:10:23 UTC (rev 8342)
+++ trunk/docutils/setup.py 2019-08-26 12:10:34 UTC (rev 8343)
@@ -199,7 +199,6 @@
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
- 'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2019-08-26 12:10:23 UTC (rev 8342)
+++ trunk/docutils/tox.ini 2019-08-26 12:10:34 UTC (rev 8343)
@@ -1,6 +1,6 @@
[tox]
minversion = 1.6
-envlist = py{27,34,35,36,37}
+envlist = py{27,35,36,37}
# NOTE(stephenfin): we need to skip generating and installing the sdist, opting
# to install manually instead. This is because we still use distutils and pip
# hasn't supported uninstalling distutils-packaged libraries since 6.0. Once we
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 12:11:02
|
Revision: 8345
http://sourceforge.net/p/docutils/code/8345
Author: milde
Date: 2019-08-26 12:10:59 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Use new style classes
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/__init__.py
trunk/docutils/docutils/core.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/parsers/rst/tableparser.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/__init__.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/alltests.py
trunk/docutils/test/test_statemachine.py
trunk/docutils/tools/buildhtml.py
trunk/docutils/tools/dev/create_unimap.py
trunk/docutils/tools/dev/unicode2rstsubs.py
Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/docutils/__init__.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -92,7 +92,7 @@
class DataError(ApplicationError): pass
-class SettingsSpec:
+class SettingsSpec(object):
"""
Runtime setting specification base class.
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/docutils/core.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -23,7 +23,7 @@
from docutils.utils.error_reporting import ErrorOutput, ErrorString
import docutils.readers.doctree
-class Publisher:
+class Publisher(object):
"""
A facade encapsulating the high-level logic of a Docutils system.
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/docutils/nodes.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -1112,12 +1112,12 @@
# Mixins
# ========
-class Resolvable:
+class Resolvable(object):
resolved = 0
-class BackLinkable:
+class BackLinkable(object):
def add_backref(self, refid):
self['backrefs'].append(refid)
@@ -1127,41 +1127,65 @@
# Element Categories
# ====================
-class Root: pass
+class Root(object):
+ pass
-class Titular: pass
-class PreBibliographic:
+class Titular(object):
+ pass
+
+
+class PreBibliographic(object):
"""Category of Node which may occur before Bibliographic Nodes."""
-class Bibliographic: pass
-class Decorative(PreBibliographic): pass
+class Bibliographic(object):
+ pass
-class Structural: pass
-class Body: pass
+class Decorative(PreBibliographic):
+ pass
-class General(Body): pass
+class Structural(object):
+ pass
+
+
+class Body(object):
+ pass
+
+
+class General(Body):
+ pass
+
+
class Sequential(Body):
"""List-like elements."""
+
class Admonition(Body): pass
+
class Special(Body):
"""Special internal body elements."""
+
class Invisible(PreBibliographic):
"""Internal elements that don't appear in output."""
-class Part: pass
-class Inline: pass
+class Part(object):
+ pass
-class Referential(Resolvable): pass
+class Inline(object):
+ pass
+
+class Referential(Resolvable):
+ pass
+
+
class Targetable(Resolvable):
referenced = 0
@@ -1171,7 +1195,7 @@
Required for MoinMoin/reST compatibility."""
-class Labeled:
+class Labeled(object):
"""Contains a `label` as its first element."""
@@ -1856,7 +1880,7 @@
"""A list of names of all concrete Node subclasses."""
-class NodeVisitor:
+class NodeVisitor(object):
"""
"Visitor" pattern [GoF95]_ abstract superclass implementation for
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -181,7 +181,7 @@
register_canonical_role(canonical_name, role)
-class GenericRole:
+class GenericRole(object):
"""
Generic interpreted text role, where the interpreted text is simply
@@ -198,7 +198,7 @@
return [self.node_class(rawtext, text, **options)], []
-class CustomRole:
+class CustomRole(object):
"""
Wrapper for custom interpreted text roles.
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -126,7 +126,7 @@
class MarkupMismatch(Exception): pass
-class Struct:
+class Struct(object):
"""Stores data attributes for dotted-attribute access."""
@@ -459,7 +459,7 @@
return regexp
-class Inliner:
+class Inliner(object):
"""
Parse inline markup; call the `parse()` method.
Modified: trunk/docutils/docutils/parsers/rst/tableparser.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/tableparser.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/docutils/parsers/rst/tableparser.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -40,7 +40,7 @@
DataError.__init__(self, *args)
-class TableParser:
+class TableParser(object):
"""
Abstract superclass for the common parts of the syntax-specific parsers.
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/docutils/statemachine.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -114,7 +114,7 @@
from docutils.utils.error_reporting import ErrorOutput
-class StateMachine:
+class StateMachine(object):
"""
A finite state machine for text filters using regular expressions.
@@ -518,7 +518,7 @@
observer(*info)
-class State:
+class State(object):
"""
State superclass. Contains a list of transitions, and transition methods.
@@ -1034,7 +1034,7 @@
return context, next_state, results
-class _SearchOverride:
+class _SearchOverride(object):
"""
Mix-in class to override `StateMachine` regular expression behavior.
@@ -1067,7 +1067,7 @@
pass
-class ViewList:
+class ViewList(object):
"""
List with extended functionality: slices of ViewList objects are child
Modified: trunk/docutils/docutils/transforms/__init__.py
===================================================================
--- trunk/docutils/docutils/transforms/__init__.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/docutils/transforms/__init__.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -30,7 +30,7 @@
class TransformError(ApplicationError): pass
-class Transform:
+class Transform(object):
"""
Docutils transform component abstract base class.
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/docutils/utils/__init__.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -33,7 +33,7 @@
class SystemMessagePropagation(ApplicationError): pass
-class Reporter:
+class Reporter(object):
"""
Info/warning/error reporter and ``system_message`` element generator.
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -155,7 +155,7 @@
r'\equiv': u'\u2262'}
# LaTeX to MathML translation stuff:
-class math:
+class math(object):
"""Base class for MathML elements."""
nchildren = 1000000
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -92,7 +92,7 @@
StringList.__repr__ = StringList.__str__
-class DevNull:
+class DevNull(object):
"""Output sink."""
Modified: trunk/docutils/test/alltests.py
===================================================================
--- trunk/docutils/test/alltests.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/test/alltests.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -25,7 +25,7 @@
import docutils
-class Tee:
+class Tee(object):
"""Write to a file and a stream (default: stdout) simultaneously."""
Modified: trunk/docutils/test/test_statemachine.py
===================================================================
--- trunk/docutils/test/test_statemachine.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/test/test_statemachine.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -203,7 +203,7 @@
self.assertEqual(self.sm.run(testtext), expected)
-class EmptyClass:
+class EmptyClass(object):
pass
Modified: trunk/docutils/tools/buildhtml.py
===================================================================
--- trunk/docutils/tools/buildhtml.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/tools/buildhtml.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -107,7 +107,7 @@
return source, destination
-class Struct:
+class Struct(object):
"""Stores data attributes for dotted-attribute access."""
@@ -115,7 +115,7 @@
self.__dict__.update(keywordargs)
-class Builder:
+class Builder(object):
def __init__(self):
self.publishers = {
Modified: trunk/docutils/tools/dev/create_unimap.py
===================================================================
--- trunk/docutils/tools/dev/create_unimap.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/tools/dev/create_unimap.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -28,8 +28,8 @@
text_map = {}
math_map = {}
-class Visitor:
-
+
+class Visitor(object):
"""Node visitor for contents of unicode.xml."""
def visit_character(self, node):
Modified: trunk/docutils/tools/dev/unicode2rstsubs.py
===================================================================
--- trunk/docutils/tools/dev/unicode2rstsubs.py 2019-08-26 12:10:43 UTC (rev 8344)
+++ trunk/docutils/tools/dev/unicode2rstsubs.py 2019-08-26 12:10:59 UTC (rev 8345)
@@ -59,7 +59,7 @@
grouper.write_sets()
-class CharacterEntitySetExtractor:
+class CharacterEntitySetExtractor(object):
"""
Extracts character entity information from unicode.xml file, groups it by
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 12:11:36
|
Revision: 8346
http://sourceforge.net/p/docutils/code/8346
Author: milde
Date: 2019-08-26 12:11:32 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Switch to print functions
Remove all uses of print as a statement. This includes comments, many of
which are simply removed as noise (they're in version control and can be
re-added later, if necessary).
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/core.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/directives/body.py
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/docutils/utils/math/tex2mathml_extern.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/install.py
trunk/docutils/setup.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/alltests.py
trunk/docutils/test/package_unittest.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_functional.py
trunk/docutils/test/test_io.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py
trunk/docutils/test/test_parsers/test_rst/test_doctest_blocks.py
trunk/docutils/test/test_settings.py
trunk/docutils/test/test_statemachine.py
trunk/docutils/test/test_transforms/test_smartquotes.py
trunk/docutils/test/test_transforms/test_strip_elements_with_class.py
trunk/docutils/test/test_viewlist.py
trunk/docutils/tools/dev/create_unimap.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
trunk/docutils/tools/dev/profile_docutils.py
trunk/docutils/tools/dev/unicode2rstsubs.py
trunk/docutils/tools/quicktest.py
trunk/docutils/tools/rst2odt_prepstyles.py
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/core.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -11,6 +11,7 @@
.. _The Docutils Publisher: http://docutils.sf.net/docs/api/publisher.html
"""
+from __future__ import print_function
__docformat__ = 'reStructuredText'
@@ -243,24 +244,24 @@
if not self.document:
return
if self.settings.dump_settings:
- print >>self._stderr, '\n::: Runtime settings:'
- print >>self._stderr, pprint.pformat(self.settings.__dict__)
+ print('\n::: Runtime settings:', file=self._stderr)
+ print(pprint.pformat(self.settings.__dict__), file=self._stderr)
if self.settings.dump_internals:
- print >>self._stderr, '\n::: Document internals:'
- print >>self._stderr, pprint.pformat(self.document.__dict__)
+ print('\n::: Document internals:', file=self._stderr)
+ print(pprint.pformat(self.document.__dict__), file=self._stderr)
if self.settings.dump_transforms:
- print >>self._stderr, '\n::: Transforms applied:'
- print >>self._stderr, (' (priority, transform class, '
- 'pending node details, keyword args)')
- print >>self._stderr, pprint.pformat(
+ print('\n::: Transforms applied:', file=self._stderr)
+ print(' (priority, transform class, pending node details, '
+ 'keyword args)', file=self._stderr)
+ print(pprint.pformat(
[(priority, '%s.%s' % (xclass.__module__, xclass.__name__),
pending and pending.details, kwargs)
for priority, xclass, pending, kwargs
- in self.document.transformer.applied])
+ in self.document.transformer.applied]), file=self._stderr)
if self.settings.dump_pseudo_xml:
- print >>self._stderr, '\n::: Pseudo-XML:'
- print >>self._stderr, self.document.pformat().encode(
- 'raw_unicode_escape')
+ print('\n::: Pseudo-XML:', file=self._stderr)
+ print(self.document.pformat().encode(
+ 'raw_unicode_escape'), file=self._stderr)
def report_Exception(self, error):
if isinstance(error, utils.SystemMessage):
@@ -275,8 +276,8 @@
u'Unable to open destination file for writing:\n'
u' %s\n' % ErrorString(error))
else:
- print >>self._stderr, u'%s' % ErrorString(error)
- print >>self._stderr, ("""\
+ print(u'%s' % ErrorString(error), file=self._stderr)
+ print(("""\
Exiting due to error. Use "--traceback" to diagnose.
Please report errors to <doc...@li...>.
Include "--traceback" output, Docutils version (%s%s),
@@ -284,12 +285,12 @@
command line used.""" % (__version__,
docutils.__version_details__ and
' [%s]'%docutils.__version_details__ or '',
- sys.version.split()[0]))
+ sys.version.split()[0])), file=self._stderr)
def report_SystemMessage(self, error):
- print >>self._stderr, ('Exiting due to level-%s (%s) system message.'
- % (error.level,
- utils.Reporter.levels[error.level]))
+ print('Exiting due to level-%s (%s) system message.' % (
+ error.level, utils.Reporter.levels[error.level]),
+ file=self._stderr)
def report_UnicodeError(self, error):
data = error.object[error.start:error.end]
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/io.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -6,6 +6,7 @@
I/O classes provide a uniform API for low-level input and output. Subclasses
exist for a variety of input/output mechanisms.
"""
+from __future__ import print_function
__docformat__ = 'reStructuredText'
@@ -343,9 +344,9 @@
elif (# destination is file-type object -> check mode:
mode and hasattr(self.destination, 'mode')
and mode != self.destination.mode):
- print >>self._stderr, ('Warning: Destination mode "%s" '
- 'differs from specified mode "%s"' %
- (self.destination.mode, mode))
+ print('Warning: Destination mode "%s" differs from specified '
+ 'mode "%s"' % (self.destination.mode, mode),
+ file=self._stderr)
if not destination_path:
try:
self.destination_path = self.destination.name
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/nodes.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -19,6 +19,7 @@
.. _DTD: http://docutils.sourceforge.net/docs/ref/docutils.dtd
"""
+from __future__ import print_function
__docformat__ = 'reStructuredText'
@@ -1724,7 +1725,7 @@
try:
Element.__init__(self, rawsource, *children, **attributes)
except:
- print 'system_message: children=%r' % (children,)
+ print('system_message: children=%r' % (children,))
raise
def astext(self):
Modified: trunk/docutils/docutils/parsers/rst/directives/body.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/body.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/parsers/rst/directives/body.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -11,7 +11,6 @@
__docformat__ = 'reStructuredText'
-import sys
from docutils import nodes
from docutils.parsers.rst import Directive
from docutils.parsers.rst import directives
@@ -18,6 +17,7 @@
from docutils.parsers.rst.roles import set_classes
from docutils.utils.code_analyzer import Lexer, LexerError, NumberLines
+
class BasePseudoSection(Directive):
required_arguments = 1
@@ -167,7 +167,6 @@
node.attributes['source'] = self.options['source']
# analyze content and add nodes for every token
for classes, value in tokens:
- # print (classes, value)
if classes:
node += nodes.inline(value, value, classes=classes)
else:
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -342,7 +342,6 @@
# analyse content and add nodes for every token
for classes, value in tokens:
- # print (classes, value)
if classes:
node += nodes.inline(value, value, classes=classes)
else:
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -2756,8 +2756,8 @@
src, srcline = self.state_machine.get_source_and_line()
# TODO: why is abs_line_number() == srcline+1
# if the error is in a table (try with test_tables.py)?
- # print "get_source_and_line", srcline
- # print "abs_line_number", self.state_machine.abs_line_number()
+ # print("get_source_and_line", srcline)
+ # print("abs_line_number", self.state_machine.abs_line_number())
msg = self.reporter.severe('Unexpected section title.',
nodes.literal_block(blocktext, blocktext),
source=src, line=srcline)
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/statemachine.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -103,6 +103,7 @@
sm.unlink()
"""
+from __future__ import print_function
__docformat__ = 'restructuredtext'
@@ -213,15 +214,15 @@
self.line_offset = -1
self.current_state = initial_state or self.initial_state
if self.debug:
- print >>self._stderr, (
+ print((
u'\nStateMachine.run: input_lines (line_offset=%s):\n| %s'
- % (self.line_offset, u'\n| '.join(self.input_lines)))
+ % (self.line_offset, u'\n| '.join(self.input_lines))), file=self._stderr)
transitions = None
results = []
state = self.get_state()
try:
if self.debug:
- print >>self._stderr, '\nStateMachine.run: bof transition'
+ print('\nStateMachine.run: bof transition', file=self._stderr)
context, result = state.bof(context)
results.extend(result)
while True:
@@ -231,17 +232,17 @@
if self.debug:
source, offset = self.input_lines.info(
self.line_offset)
- print >>self._stderr, (
+ print((
u'\nStateMachine.run: line (source=%r, '
u'offset=%r):\n| %s'
- % (source, offset, self.line))
+ % (source, offset, self.line)), file=self._stderr)
context, next_state, result = self.check_line(
context, state, transitions)
except EOFError:
if self.debug:
- print >>self._stderr, (
+ print((
'\nStateMachine.run: %s.eof transition'
- % state.__class__.__name__)
+ % state.__class__.__name__), file=self._stderr)
result = state.eof(context)
results.extend(result)
break
@@ -251,10 +252,10 @@
self.previous_line() # back up for another try
transitions = (exception.args[0],)
if self.debug:
- print >>self._stderr, (
+ print((
'\nStateMachine.run: TransitionCorrection to '
'state "%s", transition %s.'
- % (state.__class__.__name__, transitions[0]))
+ % (state.__class__.__name__, transitions[0])), file=self._stderr)
continue
except StateCorrection, exception:
self.previous_line() # back up for another try
@@ -264,10 +265,10 @@
else:
transitions = (exception.args[1],)
if self.debug:
- print >>self._stderr, (
+ print((
'\nStateMachine.run: StateCorrection to state '
'"%s", transition %s.'
- % (next_state, transitions[0]))
+ % (next_state, transitions[0])), file=self._stderr)
else:
transitions = None
state = self.get_state(next_state)
@@ -288,11 +289,11 @@
"""
if next_state:
if self.debug and next_state != self.current_state:
- print >>self._stderr, (
+ print((
'\nStateMachine.get_state: Changing state from '
'"%s" to "%s" (input line %s).'
% (self.current_state, next_state,
- self.abs_line_number()))
+ self.abs_line_number())), file=self._stderr)
self.current_state = next_state
try:
return self.states[self.current_state]
@@ -382,15 +383,11 @@
# line is None if index is "Just past the end"
src, srcline = self.get_source_and_line(offset + self.input_offset)
return src, srcline + 1
- except (IndexError): # `offset` is off the list
+ except (IndexError): # `offset` is off the list
src, srcline = None, None
# raise AssertionError('cannot find line %d in %s lines' %
# (offset, len(self.input_lines)))
# # list(self.input_lines.lines())))
- # assert offset == srcoffset, str(self.input_lines)
- # print "get_source_and_line(%s):" % lineno,
- # print offset + 1, '->', src, srcline
- # print self.input_lines
return (src, srcline)
def insert_input(self, input_lines, source):
@@ -445,24 +442,24 @@
transitions = state.transition_order
state_correction = None
if self.debug:
- print >>self._stderr, (
+ print((
'\nStateMachine.check_line: state="%s", transitions=%r.'
- % (state.__class__.__name__, transitions))
+ % (state.__class__.__name__, transitions)), file=self._stderr)
for name in transitions:
pattern, method, next_state = state.transitions[name]
match = pattern.match(self.line)
if match:
if self.debug:
- print >>self._stderr, (
+ print((
'\nStateMachine.check_line: Matched transition '
'"%s" in state "%s".'
- % (name, state.__class__.__name__))
+ % (name, state.__class__.__name__)), file=self._stderr)
return method(match, context, next_state)
else:
if self.debug:
- print >>self._stderr, (
+ print((
'\nStateMachine.check_line: No match in state "%s".'
- % state.__class__.__name__)
+ % state.__class__.__name__), file=self._stderr)
return state.no_match(context, transitions)
def add_state(self, state_class):
@@ -494,10 +491,10 @@
def error(self):
"""Report error details."""
type, value, module, line, function = _exception_data()
- print >>self._stderr, u'%s: %s' % (type, value)
- print >>self._stderr, 'input line %s' % (self.abs_line_number())
- print >>self._stderr, (u'module %s, line %s, function %s' %
- (module, line, function))
+ print(u'%s: %s' % (type, value), file=self._stderr)
+ print('input line %s' % (self.abs_line_number()), file=self._stderr)
+ print((u'module %s, line %s, function %s' %
+ (module, line, function)), file=self._stderr)
def attach_observer(self, observer):
"""
@@ -1329,7 +1326,7 @@
def pprint(self):
"""Print the list in `grep` format (`source:offset:value` lines)"""
for line in self.xitems():
- print "%s:%d:%s" % line
+ print("%s:%d:%s" % line)
class StringList(ViewList):
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/transforms/universal.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -17,12 +17,12 @@
__docformat__ = 'reStructuredText'
import re
-import sys
import time
from docutils import nodes, utils
from docutils.transforms import TransformError, Transform
from docutils.utils import smartquotes
+
class Decorations(Transform):
"""
@@ -258,7 +258,6 @@
alternative = smart_quotes.startswith('alt')
except AttributeError:
alternative = False
- # print repr(alternative)
document_language = self.document.settings.language_code
lc_smartquotes = self.document.settings.smartquotes_locales
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/utils/__init__.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -173,7 +173,6 @@
if not 'source' in attributes: # 'line' is absolute line number
try: # look up (source, line-in-source)
source, line = self.get_source_and_line(attributes.get('line'))
- # print "locator lookup", kwargs.get('line'), "->", source, line
except AttributeError:
source, line = None, None
if source is not None:
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -384,7 +384,6 @@
c2 = string[1]
else:
c2 = ''
-## print n, string, c, c2, node.__class__.__name__
if c == ' ':
pass
elif c == '\\':
Modified: trunk/docutils/docutils/utils/math/tex2mathml_extern.py
===================================================================
--- trunk/docutils/docutils/utils/math/tex2mathml_extern.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/utils/math/tex2mathml_extern.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -15,6 +15,7 @@
# Wrappers for TeX->MathML conversion by external tools
# =====================================================
+from __future__ import print_function
import subprocess
document_template = r"""\documentclass{article}
@@ -141,6 +142,6 @@
if __name__ == "__main__":
example = ur'\frac{\partial \sin^2(\alpha)}{\partial \vec r} \varpi \, \text{Grüße}'
- # print latexml(example).encode('utf8')
- # print ttm(example)#.encode('utf8')
- print blahtexml(example).encode('utf8')
+ # print(latexml(example).encode('utf8'))
+ # print(ttm(example))
+ print(blahtexml(example).encode('utf8'))
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/utils/smartquotes.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -315,6 +315,7 @@
1.5_1.0: Tue, 09 Mar 2004 08:08:35 -0500
- Initial release
"""
+from __future__ import print_function
options = r"""
Options
@@ -965,16 +966,16 @@
args = parser.parse_args()
if args.doc:
- print (__doc__)
+ print(__doc__)
elif args.actionhelp:
- print options
+ print(options)
elif args.stylehelp:
- print
- print "Available styles (primary open/close, secondary open/close)"
- print "language tag quotes"
- print "============ ======"
+ print()
+ print("Available styles (primary open/close, secondary open/close)")
+ print("language tag quotes")
+ print("============ ======")
for key in sorted(smartchars.quotes.keys()):
- print "%-14s %s" % (key, smartchars.quotes[key])
+ print("%-14s %s" % (key, smartchars.quotes[key]))
elif args.test:
# Unit test output goes to stderr.
import unittest
@@ -1007,5 +1008,5 @@
else:
args.language += '-x-altquot'
text = sys.stdin.read().decode(args.encoding)
- print smartyPants(text, attr=args.action,
- language=args.language).encode(args.encoding)
+ print(smartyPants(text, attr=args.action,
+ language=args.language).encode(args.encoding))
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/writers/_html_base.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -494,7 +494,6 @@
# the end of this file).
def is_compactable(self, node):
- # print "is_compactable %s ?" % node.__class__,
# explicite class arguments have precedence
if 'compact' in node['classes']:
return True
@@ -503,11 +502,9 @@
# check config setting:
if (isinstance(node, (nodes.field_list, nodes.definition_list))
and not self.settings.compact_field_lists):
- # print "`compact-field-lists` is False"
return False
if (isinstance(node, (nodes.enumerated_list, nodes.bullet_list))
and not self.settings.compact_lists):
- # print "`compact-lists` is False"
return False
# more special cases:
if (self.topic_classes == ['contents']): # TODO: self.in_contents
@@ -882,7 +879,6 @@
if 'sectnum' in node['classes']:
# get section number (strip trailing no-break-spaces)
sectnum = node.astext().rstrip(u' ')
- # print sectnum.encode('utf-8')
self.body.append('<span class="sectnum">%s</span> '
% self.encode(sectnum))
# Content already processed:
@@ -1194,7 +1190,6 @@
pass # never reached
def visit_math_block(self, node):
- # print node.astext().encode('utf8')
math_env = pick_math_environment(node.astext())
self.visit_math(node, math_env=math_env)
@@ -1611,20 +1606,16 @@
raise nodes.NodeFound
def visit_list_item(self, node):
- # print "visiting list item", node.__class__
children = [child for child in node.children
if not isinstance(child, nodes.Invisible)]
- # print "has %s visible children" % len(children)
if (children and isinstance(children[0], nodes.paragraph)
and (isinstance(children[-1], nodes.bullet_list) or
isinstance(children[-1], nodes.enumerated_list) or
isinstance(children[-1], nodes.field_list))):
children.pop()
- # print "%s children remain" % len(children)
if len(children) <= 1:
return
else:
- # print "found", child.__class__, "in", node.__class__
raise nodes.NodeFound
def pass_node(self, node):
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -15,7 +15,6 @@
import sys
import os
-import time
import re
import string
import urllib
@@ -28,6 +27,7 @@
from docutils.transforms import writer_aux
from docutils.utils.math import pick_math_environment, unichar2tex
+
class Writer(writers.Writer):
supported = ('latex','latex2e')
@@ -2283,14 +2283,14 @@
href = self.document.nameids[node['refname']]
# if not self.docutils_footnotes:
# TODO: insert footnote content at (or near) this place
- # print "footnote-ref to", node['refid']
+ # print("footnote-ref to", node['refid'])
# footnotes = (self.document.footnotes +
# self.document.autofootnotes +
# self.document.symbol_footnotes)
# for footnote in footnotes:
- # # print footnote['ids']
+ # # print(footnote['ids'])
# if node.get('refid', '') in footnote['ids']:
- # print 'matches', footnote['ids']
+ # print('matches', footnote['ids'])
format = self.settings.footnote_references
if format == 'brackets':
self.append_hypertargets(node)
@@ -2623,7 +2623,6 @@
r'\begin{%s}' % math_env,
'%s',
r'\end{%s}' % math_env])
- # print repr(wrapper), repr(math_code)
self.out.append(wrapper % math_code)
if node['classes']:
self.depart_inline(node)
Modified: trunk/docutils/install.py
===================================================================
--- trunk/docutils/install.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/install.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -15,12 +15,13 @@
python setup.py install --help
python setup.py --help
"""
+from __future__ import print_function
from distutils import core
from setup import do_setup
-if __name__ == '__main__' :
- print __doc__
+if __name__ == '__main__':
+ print(__doc__)
core._setup_stop_after = 'config'
dist = do_setup()
dist.commands = ['install']
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/setup.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -2,9 +2,12 @@
# $Id$
# Copyright: This file has been placed in the public domain.
+from __future__ import print_function
+
import sys
import os
import glob
+
try:
import setuptools
from distutils.core import setup, Command
@@ -17,10 +20,10 @@
from distutils.util import convert_path
from distutils import log
except ImportError:
- print ('Error: The "distutils" standard module, which is required for the ')
- print ('installation of Docutils, could not be found. You may need to ')
- print ('install a package called "python-devel" (or similar) on your ')
- print ('system using your package manager.')
+ print('Error: The "distutils" standard module, which is required for the ')
+ print('installation of Docutils, could not be found. You may need to ')
+ print('install a package called "python-devel" (or similar) on your ')
+ print('system using your package manager.')
sys.exit(1)
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -38,6 +38,7 @@
- `HtmlFragmentTestSuite`
- `DevNull` (output sink)
"""
+from __future__ import print_function
__docformat__ = 'reStructuredText'
import sys
@@ -230,17 +231,17 @@
try:
self.assertEqual(output, expected)
except AssertionError, error:
- print >>sys.stderr, '\n%s\ninput:' % (self,)
- print >>sys.stderr, input
+ print('\n%s\ninput:' % (self,), file=sys.stderr)
+ print(input, file=sys.stderr)
try:
comparison = ''.join(self.compare(expected.splitlines(1),
output.splitlines(1)))
- print >>sys.stderr, '-: expected\n+: output'
- print >>sys.stderr, comparison
+ print('-: expected\n+: output', file=sys.stderr)
+ ...
[truncated message content] |
|
From: <mi...@us...> - 2019-08-26 12:12:04
|
Revision: 8347
http://sourceforge.net/p/docutils/code/8347
Author: milde
Date: 2019-08-26 12:12:02 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Switch to 'except foo as bar' syntax
This is the only form supported in Python 3.x.
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/core.py
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/parsers/rst/directives/__init__.py
trunk/docutils/docutils/parsers/rst/directives/body.py
trunk/docutils/docutils/parsers/rst/directives/html.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/package_unittest.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_language.py
trunk/docutils/test/test_publisher.py
trunk/docutils/test/test_utils.py
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/core.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -219,10 +219,10 @@
self.apply_transforms()
output = self.writer.write(self.document, self.destination)
self.writer.assemble_parts()
- except SystemExit, error:
+ except SystemExit as error:
exit = 1
exit_status = error.code
- except Exception, error:
+ except Exception as error:
if not self.settings: # exception too early to report nicely
raise
if self.settings.traceback: # Propagate exceptions?
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/frontend.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -62,7 +62,7 @@
"""
try:
new_settings = parser.get_config_file_settings(value)
- except ValueError, error:
+ except ValueError as error:
parser.error(error)
parser.values.update(new_settings, parser)
@@ -346,7 +346,7 @@
value = getattr(values, setting)
try:
new_value = self.validator(setting, value, parser)
- except Exception, error:
+ except Exception as error:
raise (optparse.OptionValueError(
'Error in option "%s":\n %s'
% (opt, ErrorString(error))),
@@ -605,7 +605,7 @@
if read_config_files and not self.defaults['_disable_config']:
try:
config_settings = self.get_standard_config_settings()
- except ValueError, error:
+ except ValueError as error:
self.error(SafeString(error))
self.set_defaults_from_dict(config_settings.__dict__)
@@ -826,7 +826,7 @@
new_value = option.validator(
setting, value, option_parser,
config_parser=self, config_section=section)
- except Exception, error:
+ except Exception as error:
raise (ValueError(
'Error in config file "%s", section "[%s]":\n'
' %s\n'
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/io.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -114,7 +114,7 @@
self.successful_encoding = enc
# Return decoded, removing BOMs.
return decoded.replace(u'\ufeff', u'')
- except (UnicodeError, LookupError), err:
+ except (UnicodeError, LookupError) as err:
error = err # in Python 3, the <exception instance> is
# local to the except clause
raise UnicodeError(
@@ -244,7 +244,7 @@
try:
self.source = open(source_path, mode, **kwargs)
- except IOError, error:
+ except IOError as error:
raise InputError(error.errno, error.strerror, source_path)
else:
self.source = sys.stdin
@@ -272,7 +272,7 @@
data = b'\n'.join(data.splitlines()) + b'\n'
else:
data = self.source.read()
- except (UnicodeError, LookupError), err: # (in Py3k read() decodes)
+ except (UnicodeError, LookupError) as err: # (in Py3k read() decodes)
if not self.encoding and self.source_path:
# re-read in binary mode and decode with heuristics
b_source = open(self.source_path, 'rb')
@@ -362,7 +362,7 @@
kwargs = {}
try:
self.destination = open(self.destination_path, self.mode, **kwargs)
- except IOError, error:
+ except IOError as error:
raise OutputError(error.errno, error.strerror,
self.destination_path)
self.opened = True
@@ -384,7 +384,7 @@
try:
self.destination.write(data)
- except TypeError, e:
+ except TypeError as e:
if sys.version_info >= (3,0) and isinstance(data, bytes):
try:
self.destination.buffer.write(data)
@@ -397,7 +397,7 @@
self.destination.encoding, self.encoding))
else:
raise e
- except (UnicodeError, LookupError), err:
+ except (UnicodeError, LookupError) as err:
raise UnicodeError(
'Unable to encode output data. output-encoding is: '
'%s.\n(%s)' % (self.encoding, ErrorString(err)))
Modified: trunk/docutils/docutils/parsers/rst/directives/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/__init__.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/directives/__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -86,7 +86,7 @@
canonicalname = None
try:
canonicalname = language_module.directives[normname]
- except AttributeError, error:
+ except AttributeError as error:
msg_text.append('Problem retrieving directive entry from language '
'module %r: %s.' % (language_module, error))
except KeyError:
@@ -113,7 +113,7 @@
return None, messages
try:
module = __import__(modulename, globals(), locals(), level=1)
- except ImportError, detail:
+ except ImportError as detail:
messages.append(document.reporter.error(
'Error importing directive module "%s" (directive "%s"):\n%s'
% (modulename, directive_name, detail),
@@ -309,7 +309,7 @@
return unichr(int(value, 16))
else: # other text
return code
- except OverflowError, detail:
+ except OverflowError as detail:
raise ValueError('code too large (%s)' % detail)
def single_char_or_unicode(argument):
Modified: trunk/docutils/docutils/parsers/rst/directives/body.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/body.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/directives/body.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -147,7 +147,7 @@
try:
tokens = Lexer(u'\n'.join(self.content), language,
self.state.document.settings.syntax_highlight)
- except LexerError, error:
+ except LexerError as error:
raise self.warning(error)
if 'number-lines' in self.options:
Modified: trunk/docutils/docutils/parsers/rst/directives/html.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/html.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/directives/html.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -55,7 +55,7 @@
try:
attname, val = utils.extract_name_value(token)[0]
node[attname.lower()] = val
- except utils.NameValueError, detail:
+ except utils.NameValueError as detail:
line = self.state_machine.line
msg = self.reporter.error(
'Error parsing meta tag attribute "%s": %s.'
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -73,12 +73,12 @@
include_file = io.FileInput(source_path=path,
encoding=encoding,
error_handler=e_handler)
- except UnicodeEncodeError, error:
+ except UnicodeEncodeError as error:
raise self.severe(u'Problems with "%s" directive path:\n'
'Cannot encode input file path "%s" '
'(wrong locale?).' %
(self.name, SafeString(path)))
- except IOError, error:
+ except IOError as error:
raise self.severe(u'Problems with "%s" directive path:\n%s.' %
(self.name, ErrorString(error)))
startline = self.options.get('start-line', None)
@@ -89,7 +89,7 @@
rawtext = ''.join(lines[startline:endline])
else:
rawtext = include_file.read()
- except UnicodeError, error:
+ except UnicodeError as error:
raise self.severe(u'Problem with "%s" directive:\n%s' %
(self.name, ErrorString(error)))
# start-after/end-before: no restrictions on newlines in match-text,
@@ -213,12 +213,12 @@
# TODO: currently, raw input files are recorded as
# dependencies even if not used for the chosen output format.
self.state.document.settings.record_dependencies.add(path)
- except IOError, error:
+ except IOError as error:
raise self.severe(u'Problems with "%s" directive path:\n%s.'
% (self.name, ErrorString(error)))
try:
text = raw_file.read()
- except UnicodeError, error:
+ except UnicodeError as error:
raise self.severe(u'Problem with "%s" directive:\n%s'
% (self.name, ErrorString(error)))
attributes['source'] = path
@@ -230,7 +230,7 @@
import urllib2
try:
raw_text = urllib2.urlopen(source).read()
- except (urllib2.URLError, IOError, OSError), error:
+ except (urllib2.URLError, IOError, OSError) as error:
raise self.severe(u'Problems with "%s" directive URL "%s":\n%s.'
% (self.name, self.options['url'], ErrorString(error)))
raw_file = io.StringInput(source=raw_text, source_path=source,
@@ -238,7 +238,7 @@
error_handler=e_handler)
try:
text = raw_file.read()
- except UnicodeError, error:
+ except UnicodeError as error:
raise self.severe(u'Problem with "%s" directive:\n%s'
% (self.name, ErrorString(error)))
attributes['source'] = source
@@ -320,7 +320,7 @@
for code in codes:
try:
decoded = directives.unicode_code(code)
- except ValueError, error:
+ except ValueError as error:
raise self.error(u'Invalid character code: %s\n%s'
% (code, ErrorString(error)))
element += nodes.Text(decoded)
@@ -406,7 +406,7 @@
self.state.parse_directive_block(
self.content[1:], self.content_offset, converted_role,
option_presets={}))
- except states.MarkupError, detail:
+ except states.MarkupError as detail:
error = self.state_machine.reporter.error(
'Error in "%s" directive:\n%s.' % (self.name, detail),
nodes.literal_block(self.block_text, self.block_text),
@@ -415,7 +415,7 @@
if 'class' not in options:
try:
options['class'] = directives.class_option(new_role_name)
- except ValueError, detail:
+ except ValueError as detail:
error = self.state_machine.reporter.error(
u'Invalid argument for "%s" directive:\n%s.'
% (self.name, SafeString(detail)), nodes.literal_block(
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -259,9 +259,9 @@
col_widths = self.get_column_widths(max_cols)
self.extend_short_rows_with_empty_cells(max_cols,
(table_head, table_body))
- except SystemMessagePropagation, detail:
+ except SystemMessagePropagation as detail:
return [detail.args[0]]
- except csv.Error, detail:
+ except csv.Error as detail:
message = str(detail)
if sys.version_info < (3,) and '1-character string' in message:
message += '\nwith Python 2.x this must be an ASCII character.'
@@ -320,7 +320,7 @@
encoding=encoding,
error_handler=error_handler)
csv_data = csv_file.read().splitlines()
- except IOError, error:
+ except IOError as error:
severe = self.state_machine.reporter.severe(
u'Problems with "%s" directive path:\n%s.'
% (self.name, SafeString(error)),
@@ -336,7 +336,7 @@
source = self.options['url']
try:
csv_text = urllib2.urlopen(source).read()
- except (urllib2.URLError, IOError, OSError, ValueError), error:
+ except (urllib2.URLError, IOError, OSError, ValueError) as error:
severe = self.state_machine.reporter.severe(
'Problems with "%s" directive URL "%s":\n%s.'
% (self.name, self.options['url'], SafeString(error)),
@@ -424,7 +424,7 @@
header_rows = self.options.get('header-rows', 0)
stub_columns = self.options.get('stub-columns', 0)
self.check_table_dimensions(table_data, header_rows, stub_columns)
- except SystemMessagePropagation, detail:
+ except SystemMessagePropagation as detail:
return [detail.args[0]]
table_node = self.build_table_from_list(table_data, col_widths,
header_rows, stub_columns)
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -109,7 +109,7 @@
canonicalname = None
try:
canonicalname = language_module.roles[normname]
- except AttributeError, error:
+ except AttributeError as error:
msg_text.append('Problem retrieving role entry from language '
'module %r: %s.' % (language_module, error))
except KeyError:
@@ -333,7 +333,7 @@
try:
tokens = Lexer(utils.unescape(text, True), language,
inliner.document.settings.syntax_highlight)
- except LexerError, error:
+ except LexerError as error:
msg = inliner.reporter.warning(error)
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -1495,7 +1495,7 @@
(optionlist.source, optionlist.line) = self.state_machine.get_source_and_line()
try:
listitem, blank_finish = self.option_list_item(match)
- except MarkupError, error:
+ except MarkupError as error:
# This shouldn't happen; pattern won't match.
msg = self.reporter.error(u'Invalid option list marker: %s' %
error)
@@ -1684,7 +1684,7 @@
+ 1)
table = self.build_table(tabledata, tableline)
nodelist = [table] + messages
- except tableparser.TableMarkupError, err:
+ except tableparser.TableMarkupError as err:
nodelist = self.malformed_table(block, ' '.join(err.args),
offset=err.offset) + messages
else:
@@ -1696,7 +1696,7 @@
blank_finish = 1
try:
block = self.state_machine.get_text_block(flush_left=True)
- except statemachine.UnexpectedIndentationError, err:
+ except statemachine.UnexpectedIndentationError as err:
block, src, srcline = err.args
messages.append(self.reporter.error('Unexpected indentation.',
source=src, line=srcline))
@@ -2133,7 +2133,7 @@
arguments, options, content, content_offset = (
self.parse_directive_block(indented, line_offset,
directive, option_presets))
- except MarkupError, detail:
+ except MarkupError as detail:
error = self.reporter.error(
'Error in "%s" directive:\n%s.' % (type_name,
' '.join(detail.args)),
@@ -2144,7 +2144,7 @@
content_offset, block_text, self, self.state_machine)
try:
result = directive_instance.run()
- except docutils.parsers.rst.DirectiveError, error:
+ except docutils.parsers.rst.DirectiveError as error:
msg_node = self.reporter.system_message(error.level, error.msg,
line=lineno)
msg_node += nodes.literal_block(block_text, block_text)
@@ -2261,11 +2261,11 @@
return 0, 'invalid option block'
try:
options = utils.extract_extension_options(node, option_spec)
- except KeyError, detail:
+ except KeyError as detail:
return 0, ('unknown option: "%s"' % detail.args[0])
- except (ValueError, TypeError), detail:
+ except (ValueError, TypeError) as detail:
return 0, ('invalid option value: %s' % ' '.join(detail.args))
- except utils.ExtensionOptionError, detail:
+ except utils.ExtensionOptionError as detail:
return 0, ('invalid option data: %s' % ' '.join(detail.args))
if blank_finish:
return 1, options
@@ -2352,7 +2352,7 @@
if expmatch:
try:
return method(self, expmatch)
- except MarkupError, error:
+ except MarkupError as error:
lineno = self.state_machine.abs_line_number()
message = ' '.join(error.args)
errors.append(self.reporter.warning(message, line=lineno))
@@ -2775,7 +2775,7 @@
msg = None
try:
block = self.state_machine.get_text_block(flush_left=True)
- except statemachine.UnexpectedIndentationError, err:
+ except statemachine.UnexpectedIndentationError as err:
block, src, srcline = err.args
msg = self.reporter.error('Unexpected indentation.',
source=src, line=srcline)
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/statemachine.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -248,7 +248,7 @@
break
else:
results.extend(result)
- except TransitionCorrection, exception:
+ except TransitionCorrection as exception:
self.previous_line() # back up for another try
transitions = (exception.args[0],)
if self.debug:
@@ -257,7 +257,7 @@
'state "%s", transition %s.'
% (state.__class__.__name__, transitions[0])), file=self._stderr)
continue
- except StateCorrection, exception:
+ except StateCorrection as exception:
self.previous_line() # back up for another try
next_state = exception.args[0]
if len(exception.args) == 1:
@@ -413,7 +413,7 @@
flush_left)
self.next_line(len(block) - 1)
return block
- except UnexpectedIndentationError, err:
+ except UnexpectedIndentationError as err:
block = err.args[0]
self.next_line(len(block) - 1) # advance to last line of block
raise
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/utils/__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -326,7 +326,7 @@
raise DuplicateOptionError('duplicate option "%s"' % name)
try:
options[name] = convertor(value)
- except (ValueError, TypeError), detail:
+ except (ValueError, TypeError) as detail:
raise detail.__class__('(option: "%s"; value: %r)\n%s'
% (name, value, ' '.join(detail.args)))
return options
Modified: trunk/docutils/docutils/utils/error_reporting.py
===================================================================
--- trunk/docutils/docutils/utils/error_reporting.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/utils/error_reporting.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -49,7 +49,7 @@
# locale.getpreferredencoding([do_setlocale=True|False])
# has side-effects | might return a wrong guess.
# (cf. Update 1 in http://stackoverflow.com/questions/4082645/using-python-2-xs-locale-module-to-format-numbers-and-currency)
- except ValueError, error: # OS X may set UTF-8 without language code
+ except ValueError as error: # OS X may set UTF-8 without language code
# see http://bugs.python.org/issue18378
# and https://sourceforge.net/p/docutils/bugs/298/
if "unknown locale: UTF-8" in error.args:
@@ -113,7 +113,7 @@
if isinstance(self.data, EnvironmentError):
u = u.replace(": u'", ": '") # normalize filename quoting
return u
- except UnicodeError, error: # catch ..Encode.. and ..Decode.. errors
+ except UnicodeError as error: # catch ..Encode.. and ..Decode.. errors
if isinstance(self.data, EnvironmentError):
return u"[Errno %s] %s: '%s'" % (self.data.errno,
SafeString(self.data.strerror, self.encoding,
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/writers/_html_base.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -302,7 +302,7 @@
content = io.FileInput(source_path=path,
encoding='utf-8').read()
self.settings.record_dependencies.add(path)
- except IOError, err:
+ except IOError as err:
msg = u"Cannot embed stylesheet '%s': %s." % (
path, SafeString(err.strerror))
self.document.reporter.error(msg)
@@ -1159,7 +1159,7 @@
'with math-output "MathML"')
except OSError:
raise OSError('is "latexmlmath" in your PATH?')
- except SyntaxError, err:
+ except SyntaxError as err:
err_node = self.document.reporter.error(err, base_node=node)
self.visit_system_message(err_node)
self.body.append(self.starttag(node, 'p'))
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -173,7 +173,7 @@
xml_string = xml_string.encode('utf8')
try:
self.xmlparser.parse(StringIO(xml_string))
- except xml.sax._exceptions.SAXParseException, error:
+ except xml.sax._exceptions.SAXParseException as error:
col_num = self.the_handle.locator.getColumnNumber()
line_num = self.the_handle.locator.getLineNumber()
srcline = node.line
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -1416,7 +1416,7 @@
content = io.FileInput(source_path=path,
encoding='utf-8').read()
self.settings.record_dependencies.add(path)
- except IOError, err:
+ except IOError as err:
msg = u"Cannot embed stylesheet '%s':\n %s." % (
path, SafeString(err.strerror))
self.document.reporter.error(msg)
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -230,7 +230,7 @@
output = '\n'.join(output.splitlines())
try:
self.assertEqual(output, expected)
- except AssertionError, error:
+ except AssertionError as error:
print('\n%s\ninput:' % (self,), file=sys.stderr)
print(input, file=sys.stderr)
try:
@@ -543,7 +543,7 @@
self.parser.find_head_body_sep()
self.parser.parse_table()
output = self.parser.cells
- except Exception, details:
+ except Exception as details:
output = '%s: %s' % (details.__class__.__name__, details)
self.compare_output(self.input, pformat(output) + '\n',
pformat(self.expected) + '\n')
@@ -552,7 +552,7 @@
try:
output = self.parser.parse(StringList(string2lines(self.input),
'test data'))
- except Exception, details:
+ except Exception as details:
output = '%s: %s' % (details.__class__.__name__, details)
self.compare_output(self.input, pformat(output) + '\n',
pformat(self.expected) + '\n')
@@ -865,7 +865,7 @@
"""
try:
func(*args, **kwds)
- except Exception, detail:
+ except Exception as detail:
return (detail, detail.args,
'%s: %s' % (detail.__class__.__name__, detail))
Modified: trunk/docutils/test/package_unittest.py
===================================================================
--- trunk/docutils/test/package_unittest.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/test/package_unittest.py 2019-08-26 12:12:02 UTC (rev 8347)
@@ -64,7 +64,7 @@
debug =1
if len(args) != 0:
usageExit("No command-line arguments supported yet.")
- except getopt.error, msg:
+ except getopt.error as msg:
usageExit(msg)
def loadTestModules(path, name='', packages=None):
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2019-08-26 12:11:32 UTC (rev 8346)
+++ trunk/docutils/test/test_error_reporting.py 2019-08-26 12:12:02 UTC (rev 83...
[truncated message content] |
|
From: <mi...@us...> - 2019-08-26 12:12:36
|
Revision: 8348
http://sourceforge.net/p/docutils/code/8348
Author: milde
Date: 2019-08-26 12:12:32 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Add aliases for removed symbols
Add aliases for symbols that have been removed in Python 3.x, namely
basestring, unicode, unichr and StandardError.
Signed-off-by: Stephen Finucane <st...@th...>
small fixes by Gunter Milde.
Modified Paths:
--------------
trunk/docutils/docutils/__init__.py
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/directives/__init__.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/test__init__.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_language.py
trunk/docutils/test/test_nodes.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py
trunk/docutils/tools/dev/create_unimap.py
Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/__init__.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -88,7 +88,8 @@
"""
-class ApplicationError(StandardError): pass
+class ApplicationError(Exception): pass
+
class DataError(ApplicationError): pass
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/frontend.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -43,7 +43,10 @@
from docutils.utils.error_reporting import (locale_encoding, SafeString,
ErrorOutput, ErrorString)
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
def store_multiple(option, opt, value, parser, *args, **kwargs):
"""
Store multiple values in `parser.values`. (Option callback.)
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/io.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -17,7 +17,10 @@
from docutils import TransformSpec
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
class InputError(IOError): pass
class OutputError(IOError): pass
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/nodes.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -30,6 +30,10 @@
import types
import unicodedata
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+ basestring = str # noqa
+
# ==============================
# Functional Node Base Classes
# ==============================
@@ -61,7 +65,7 @@
"""
return True
- if sys.version_info < (3,):
+ if sys.version_info < (3, 0):
# on 2.x, str(node) will be a byte string with Unicode
# characters > 255 escaped; on 3.x this is no longer necessary
def __str__(self):
@@ -301,7 +305,7 @@
except IndexError:
return None
-if sys.version_info < (3,):
+if sys.version_info < (3, 0):
class reprunicode(unicode):
"""
A unicode sub-class that removes the initial u from unicode's repr.
Modified: trunk/docutils/docutils/parsers/rst/directives/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/parsers/rst/directives/__init__.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -16,7 +16,10 @@
from docutils.utils import split_escaped_whitespace, escape2null, unescape
from docutils.parsers.rst.languages import en as _fallback_language_module
+if sys.version_info >= (3, 0):
+ unichr = chr # noqa
+
_directive_registry = {
'attention': ('admonitions', 'Attention'),
'caution': ('admonitions', 'Caution'),
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/statemachine.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -114,7 +114,10 @@
from docutils import utils
from docutils.utils.error_reporting import ErrorOutput
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
class StateMachine(object):
"""
@@ -1124,8 +1127,13 @@
def __ne__(self, other): return self.data != self.__cast(other)
def __gt__(self, other): return self.data > self.__cast(other)
def __ge__(self, other): return self.data >= self.__cast(other)
- def __cmp__(self, other): return cmp(self.data, self.__cast(other))
+ def __cmp__(self, other):
+ # from https://docs.python.org/3.0/whatsnew/3.0.html
+ mine = self.data
+ yours = self.__cast(other)
+ return (mine > yours) - (yours < mine)
+
def __cast(self, other):
if isinstance(other, ViewList):
return other.data
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -22,10 +22,16 @@
__docformat__ = 'reStructuredText'
import re
+import sys
+
from docutils import nodes, utils
from docutils.transforms import TransformError, Transform
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
+
class TitlePromoter(Transform):
"""
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/transforms/universal.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -17,6 +17,7 @@
__docformat__ = 'reStructuredText'
import re
+import sys
import time
from docutils import nodes, utils
from docutils.transforms import TransformError, Transform
@@ -23,6 +24,10 @@
from docutils.utils import smartquotes
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
+
class Decorations(Transform):
"""
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/utils/__init__.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -22,7 +22,10 @@
import docutils.io
from docutils.utils.error_reporting import ErrorOutput, SafeString
+if sys.version_info >= (3, 0):
+ unicode = str
+
class SystemMessage(ApplicationError):
def __init__(self, system_message, level):
Modified: trunk/docutils/docutils/utils/error_reporting.py
===================================================================
--- trunk/docutils/docutils/utils/error_reporting.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/utils/error_reporting.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -35,7 +35,8 @@
common exceptions.
"""
-import sys, codecs
+import codecs
+import sys
# Guess the locale's encoding.
# If no valid guess can be made, locale_encoding is set to `None`:
@@ -64,7 +65,10 @@
locale_encoding = None
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
class SafeString(object):
"""
A wrapper providing robust conversion to `str` and `unicode`.
@@ -199,9 +203,9 @@
self.stream.write(data)
except UnicodeEncodeError:
self.stream.write(data.encode(self.encoding, self.encoding_errors))
- except TypeError:
+ except TypeError:
if isinstance(data, unicode): # passed stream may expect bytes
- self.stream.write(data.encode(self.encoding,
+ self.stream.write(data.encode(self.encoding,
self.encoding_errors))
return
if self.stream in (sys.stderr, sys.stdout):
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/utils/math/math2html.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -20,10 +20,21 @@
# Alex 20101110
# eLyXer standalone formula conversion to HTML.
+import codecs
+import datetime
+import gettext
+import io
+import os.path
+import sys
+import unicodedata
+import urllib
+if sys.version_info >= (3,0):
+ unicode = str #noqa
+ basestring = str # noqa
+ file = io.IOBase # noqa
-import sys
class Trace(object):
"A tracing class"
@@ -73,12 +84,6 @@
show = classmethod(show)
-
-
-import os.path
-import sys
-
-
class BibStylesConfig(object):
"Configuration class from elyxer.config file"
@@ -1305,17 +1310,6 @@
return 'options for ' + self.name + ': ' + unicode(self.options)
-
-
-import urllib
-
-
-
-
-
-
-
-
class Cloner(object):
"An object used to clone other objects."
@@ -1699,15 +1693,6 @@
return [container.string]
-
-
-
-
-
-import sys
-import codecs
-
-
class LineReader(object):
"Reads a file line by line"
@@ -3094,24 +3079,6 @@
return whole
-
-
-import unicodedata
-
-
-
-
-
-
-
-
-
-
-
-
-import gettext
-
-
class Translator(object):
"Reads the configuration file and tries to find a translation."
"Otherwise falls back to the messages in the config file."
@@ -4589,9 +4556,7 @@
FormulaCommand.types += [BeginCommand]
-import datetime
-
class CombiningFunction(OneParamFunction):
commandmap = FormulaConfig.combiningfunctions
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/writers/_html_base.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -40,6 +40,10 @@
math2html, latex2mathml, tex2mathml_extern)
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
+
class Writer(writers.Writer):
supported = ('html', 'xhtml') # update in subclass
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -17,7 +17,10 @@
import docutils
from docutils import frontend, writers, nodes
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
class RawXmlError(docutils.ApplicationError): pass
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -28,6 +28,10 @@
from docutils.utils.math import pick_math_environment, unichar2tex
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
+
class Writer(writers.Writer):
supported = ('latex','latex2e')
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/docutils/writers/manpage.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -45,7 +45,11 @@
__docformat__ = 'reStructuredText'
import re
+import sys
+if sys.version_info < (3, 0):
+ range = xrange
+
import docutils
from docutils import nodes, writers, languages
try:
@@ -255,7 +259,7 @@
# ensure we get a ".TH" as viewers require it.
self.append_header()
# filter body
- for i in xrange(len(self.body)-1, 0, -1):
+ for i in range(len(self.body)-1, 0, -1):
# remove superfluous vertical gaps.
if self.body[i] == '.sp\n':
if self.body[i - 1][:4] in ('.BI ','.IP '):
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -89,6 +89,10 @@
import pdb
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
+
# Hack to make repr(StringList) look like repr(list):
StringList.__repr__ = StringList.__str__
Modified: trunk/docutils/test/test__init__.py
===================================================================
--- trunk/docutils/test/test__init__.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/test/test__init__.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -16,6 +16,10 @@
import docutils.utils
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
+
class ApplicationErrorTests(unittest.TestCase):
def test_message(self):
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/test/test_error_reporting.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -44,7 +44,10 @@
print('cannot test error reporting with problematic locales,\n'
'`import locale` failed.')
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
# locales confirmed to use non-ASCII chars in the IOError message
# for a missing file (https://bugs.gentoo.org/show_bug.cgi?id=349101)
# TODO: add more confirmed problematic locales
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/test/test_language.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -26,7 +26,10 @@
reference_language = 'en'
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
class LanguageTestSuite(DocutilsTestSupport.CustomTestSuite):
language_module_pattern = re.compile(r'^([a-z]{2,3}(_[a-z]{2,8})*)\.py$')
@@ -156,7 +159,7 @@
if failures:
text = ('Module docutils.parsers.rst.languages.%s:\n %s'
% (self.language, '\n '.join(failures)))
- if type(text) is unicode:
+ if isinstance(text, unicode):
text = text.encode('raw_unicode_escape')
self.fail(text)
@@ -191,7 +194,7 @@
if failures:
text = ('Module docutils.parsers.rst.languages.%s:\n %s'
% (self.language, '\n '.join(failures)))
- if type(text) is unicode:
+ if isinstance(text, unicode):
text = text.encode('raw_unicode_escape')
self.fail(text)
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/test/test_nodes.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -17,7 +17,10 @@
debug = False
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+
class TextTests(unittest.TestCase):
def setUp(self):
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -14,6 +14,11 @@
from docutils.parsers.rst import states
from docutils.utils.code_analyzer import with_pygments
+
+if sys.version_info >= (3, 0):
+ unichr = chr # noqa
+
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
if not with_pygments:
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -17,6 +17,11 @@
from docutils.parsers.rst.directives import tables
+if sys.version_info >= (3, 0):
+ unicode = str # noqa
+ unichr = chr # noqa
+
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -8,9 +8,15 @@
Tests for misc.py "unicode" directive.
"""
+import sys
+
from __init__ import DocutilsTestSupport
+if sys.version_info >= (3, 0):
+ unichr = chr # noqa
+
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/tools/dev/create_unimap.py
===================================================================
--- trunk/docutils/tools/dev/create_unimap.py 2019-08-26 12:12:02 UTC (rev 8347)
+++ trunk/docutils/tools/dev/create_unimap.py 2019-08-26 12:12:32 UTC (rev 8348)
@@ -14,15 +14,15 @@
import sys
import pprint
-if sys.version_info >= (3,0):
- unicode = str
+if sys.version_info >= (3, 0):
+ unicode = str #noqa
else:
- bytes = str
- chr = unichr
+ bytes = str # noqa
+ chr = unichr # noqa
def w(s):
- if sys.version_info >= (3,0) and isinstance(s, unicode):
+ if sys.version_info >= (3, 0) and isinstance(s, unicode):
s = s.encode('utf8')
sys.stdout.write(s)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 16:42:09
|
Revision: 8352
http://sourceforge.net/p/docutils/code/8352
Author: milde
Date: 2019-08-26 16:42:06 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Resolve some additional undefined symbols
Found with flake8
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
trunk/docutils/tox.ini
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2019-08-26 16:41:48 UTC (rev 8351)
+++ trunk/docutils/docutils/utils/math/math2html.py 2019-08-26 16:42:06 UTC (rev 8352)
@@ -1624,7 +1624,7 @@
def open(self, container):
"Get opening line."
- if not self.checktag():
+ if not self.checktag(container):
return ''
open = '<' + self.tag + '>'
if self.breaklines:
@@ -1633,7 +1633,7 @@
def close(self, container):
"Get closing line."
- if not self.checktag():
+ if not self.checktag(container):
return ''
close = '</' + self.tag.split()[0] + '>'
if self.breaklines:
@@ -1642,7 +1642,7 @@
def selfclosing(self, container):
"Get self-closing line."
- if not self.checktag():
+ if not self.checktag(container):
return ''
selfclosing = '<' + self.tag + '/>'
if self.breaklines:
@@ -1649,7 +1649,7 @@
return selfclosing + '\n'
return selfclosing
- def checktag(self):
+ def checktag(self, container):
"Check that the tag is valid."
if not self.tag:
Trace.error('No tag in ' + unicode(container))
Modified: trunk/docutils/tools/dev/generate_punctuation_chars.py
===================================================================
--- trunk/docutils/tools/dev/generate_punctuation_chars.py 2019-08-26 16:41:48 UTC (rev 8351)
+++ trunk/docutils/tools/dev/generate_punctuation_chars.py 2019-08-26 16:42:06 UTC (rev 8352)
@@ -319,17 +319,6 @@
else:
print('%s unchanged' % name)
-def print_quote_pairs():
- pairs = [(o,c) for o,c in quote_pairs.items()]
- for o,c in sorted(pairs):
- print((u'%s %s' % (o,c)).encode('utf8'))
-
- # # Test open/close matching:
- # for i in range(min(len(openers),len(closers))):
- # print('%4d %s %s' % (i, openers[i].encode('utf8'),
- # closers[i].encode('utf8'))
-
-
# Output
# ------
#
Modified: trunk/docutils/tox.ini
===================================================================
--- trunk/docutils/tox.ini 2019-08-26 16:41:48 UTC (rev 8351)
+++ trunk/docutils/tox.ini 2019-08-26 16:42:06 UTC (rev 8352)
@@ -112,3 +112,8 @@
ignore = E101,E111,E114,E115,E116,E117,E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E201,E202,E203,E211,E221,E222,E225,E226,E228,E231,E241,E251,E261,E262,E265,E266,E271,E301,E302,E303,E305,E306,E401,E402,E501,E502,E701,E704,E711,E713,E721,E722,E731,E741,W191,W291,W293,W391,W503,W504,W605,F401,F841
exclude = .venv,.tox,dist,*egg,build
max-complexity = 35
+# Some rules are disabled for specific files (requires flake8 3.7.0)
+#
+# F821, disabled due to use of 'settings_overrides'
+per-file-ignores =
+ docutils/test/functional/tests/*:F821
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 16:42:26
|
Revision: 8353
http://sourceforge.net/p/docutils/code/8353
Author: milde
Date: 2019-08-26 16:42:23 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Replace deprecated form of raising exception
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/docutils/utils/roman.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/package_unittest.py
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/docutils/frontend.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -74,9 +74,8 @@
try:
codecs.lookup(value)
except LookupError:
- raise (LookupError('setting "%s": unknown encoding: "%s"'
- % (setting, value)),
- None, sys.exc_info()[2])
+ raise LookupError('setting "%s": unknown encoding: "%s"'
+ % (setting, value))
return value
def validate_encoding_error_handler(setting, value, option_parser,
@@ -84,12 +83,11 @@
try:
codecs.lookup_error(value)
except LookupError:
- raise (LookupError(
+ raise LookupError(
'unknown encoding error handler: "%s" (choices: '
'"strict", "ignore", "replace", "backslashreplace", '
'"xmlcharrefreplace", and possibly others; see documentation for '
- 'the Python ``codecs`` module)' % value),
- None, sys.exc_info()[2])
+ 'the Python ``codecs`` module)' % value)
return value
def validate_encoding_and_error_handler(
@@ -125,8 +123,7 @@
try:
return option_parser.booleans[value.strip().lower()]
except KeyError:
- raise (LookupError('unknown boolean value: "%s"' % value),
- None, sys.exc_info()[2])
+ raise LookupError('unknown boolean value: "%s"' % value)
def validate_ternary(setting, value, option_parser,
config_parser=None, config_section=None):
@@ -157,8 +154,7 @@
try:
return option_parser.thresholds[value.lower()]
except (KeyError, AttributeError):
- raise (LookupError('unknown threshold: %r.' % value),
- None, sys.exc_info[2])
+ raise LookupError('unknown threshold: %r.' % value)
def validate_colon_separated_string_list(
setting, value, option_parser, config_parser=None, config_section=None):
@@ -350,10 +346,9 @@
try:
new_value = self.validator(setting, value, parser)
except Exception as error:
- raise (optparse.OptionValueError(
+ raise optparse.OptionValueError(
'Error in option "%s":\n %s'
- % (opt, ErrorString(error))),
- None, sys.exc_info()[2])
+ % (opt, ErrorString(error)))
setattr(values, setting, new_value)
if self.overrides:
setattr(values, self.overrides, None)
@@ -830,12 +825,12 @@
setting, value, option_parser,
config_parser=self, config_section=section)
except Exception as error:
- raise (ValueError(
+ raise ValueError(
'Error in config file "%s", section "[%s]":\n'
' %s\n'
' %s = %s'
% (filename, section, ErrorString(error),
- setting, value)), None, sys.exc_info()[2])
+ setting, value))
self.set(section, setting, new_value)
if option.overrides:
self.set(section, option.overrides, None)
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/docutils/nodes.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -594,8 +594,8 @@
assert key.step in (None, 1), 'cannot handle slice with stride'
return self.children[key.start:key.stop]
else:
- raise TypeError, ('element index must be an integer, a slice, or '
- 'an attribute name string')
+ raise TypeError('element index must be an integer, a slice, or '
+ 'an attribute name string')
def __setitem__(self, key, item):
if isinstance(key, basestring):
@@ -609,8 +609,8 @@
self.setup_child(node)
self.children[key.start:key.stop] = item
else:
- raise TypeError, ('element index must be an integer, a slice, or '
- 'an attribute name string')
+ raise TypeError('element index must be an integer, a slice, or '
+ 'an attribute name string')
def __delitem__(self, key):
if isinstance(key, basestring):
@@ -621,8 +621,8 @@
assert key.step in (None, 1), 'cannot handle slice with stride'
del self.children[key.start:key.stop]
else:
- raise TypeError, ('element index must be an integer, a simple '
- 'slice, or an attribute name string')
+ raise TypeError('element index must be an integer, a simple '
+ 'slice, or an attribute name string')
def __add__(self, other):
return self.children + other
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -57,7 +57,7 @@
"""
# Type check
if not isinstance(node, nodes.Element):
- raise TypeError, 'node must be of Element-derived type.'
+ raise TypeError('node must be of Element-derived type.')
# `node` must not have a title yet.
assert not (len(node) and isinstance(node[0], nodes.title))
@@ -100,7 +100,7 @@
"""
# Type check
if not isinstance(node, nodes.Element):
- raise TypeError, 'node must be of Element-derived type.'
+ raise TypeError('node must be of Element-derived type.')
subsection, index = self.candidate_index(node)
if index is None:
Modified: trunk/docutils/docutils/utils/roman.py
===================================================================
--- trunk/docutils/docutils/utils/roman.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/docutils/utils/roman.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -40,9 +40,9 @@
def toRoman(n):
"""convert integer to Roman numeral"""
if not (0 < n < 5000):
- raise OutOfRangeError, "number out of range (must be 1..4999)"
+ raise OutOfRangeError("number out of range (must be 1..4999)")
if int(n) != n:
- raise NotIntegerError, "decimals can not be converted"
+ raise NotIntegerError("decimals can not be converted")
result = ""
for numeral, integer in romanNumeralMap:
@@ -67,9 +67,10 @@
def fromRoman(s):
"""convert Roman numeral to integer"""
if not s:
- raise InvalidRomanNumeralError, 'Input can not be blank'
+ raise InvalidRomanNumeralError('Input can not be blank')
+
if not romanNumeralPattern.search(s):
- raise InvalidRomanNumeralError, 'Invalid Roman numeral: %s' % s
+ raise InvalidRomanNumeralError('Invalid Roman numeral: %s' % s)
result = 0
index = 0
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/docutils/writers/manpage.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -715,7 +715,7 @@
pass
def visit_header(self, node):
- raise NotImplementedError, node.astext()
+ raise NotImplementedError(node.astext())
def depart_header(self, node):
pass
@@ -855,7 +855,7 @@
self.depart_literal_block(node)
def visit_meta(self, node):
- raise NotImplementedError, node.astext()
+ raise NotImplementedError(node.astext())
def depart_meta(self, node):
pass
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -123,8 +123,8 @@
operator.
"""
if not first == second:
- raise self.failureException, (
- msg or '%s != %s' % _format_str(first, second))
+ raise self.failureException(
+ msg or '%s != %s' % _format_str(first, second))
def assertNotEqual(self, first, second, msg=None):
"""Fail if the two objects are equal as determined by the '=='
@@ -131,22 +131,9 @@
operator.
"""
if first == second:
- raise self.failureException, (
- msg or '%s == %s' % _format_str(first, second))
+ raise self.failureException(
+ msg or '%s == %s' % _format_str(first, second))
- # assertIn and assertNotIn: new in Python 2.7:
- if sys.version_info < (2,7):
-
- def assertIn(self, a, b, msg=None):
- if a not in b:
- raise self.failureException, (
- msg or '%s not in %s' % _format_str(a, b))
-
- def assertNotIn(self, a, b, msg=None):
- if a in b:
- raise self.failureException, (
- msg or '%s in %s' % _format_str(a, b))
-
# aliases for assertion methods, deprecated since Python 2.7
failUnlessEqual = assertEquals = assertEqual
Modified: trunk/docutils/test/package_unittest.py
===================================================================
--- trunk/docutils/test/package_unittest.py 2019-08-26 16:42:06 UTC (rev 8352)
+++ trunk/docutils/test/package_unittest.py 2019-08-26 16:42:23 UTC (rev 8353)
@@ -120,7 +120,7 @@
elif isinstance(suite, unittest.TestSuite):
testSuite.addTest(suite)
else:
- raise AssertionError, "don't understand suite (%s)" % mod
+ raise AssertionError("don't understand suite (%s)" % mod)
sys.path.pop(0)
return testSuite
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 16:42:52
|
Revision: 8355
http://sourceforge.net/p/docutils/code/8355
Author: milde
Date: 2019-08-26 16:42:50 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Replace 'types.SliceType' with slice, remove 'types.ClassType'.
These types have been removed in Python 3,
`SliceType` is an alias for `slice` already in Python 2.7,
`ClassType` is for user-defined old-style classes (we now use only new style classes).
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/test/test_nodes.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2019-08-26 16:42:38 UTC (rev 8354)
+++ trunk/docutils/docutils/nodes.py 2019-08-26 16:42:50 UTC (rev 8355)
@@ -27,7 +27,6 @@
import os
import re
import warnings
-import types
import unicodedata
if sys.version_info >= (3, 0):
@@ -257,11 +256,11 @@
if include_self and descend and not siblings:
if condition is None:
return self._all_traverse()
- elif isinstance(condition, (types.ClassType, type)):
+ elif isinstance(condition, type):
return self._fast_traverse(condition)
# Check if `condition` is a class (check for TypeType for Python
# implementations that use only new-style classes, like PyPy).
- if isinstance(condition, (types.ClassType, type)):
+ if isinstance(condition, type):
node_class = condition
def condition(node, node_class=node_class):
return isinstance(node, node_class)
@@ -590,7 +589,7 @@
return self.attributes[key]
elif isinstance(key, int):
return self.children[key]
- elif isinstance(key, types.SliceType):
+ elif isinstance(key, slice):
assert key.step in (None, 1), 'cannot handle slice with stride'
return self.children[key.start:key.stop]
else:
@@ -603,7 +602,7 @@
elif isinstance(key, int):
self.setup_child(item)
self.children[key] = item
- elif isinstance(key, types.SliceType):
+ elif isinstance(key, slice):
assert key.step in (None, 1), 'cannot handle slice with stride'
for node in item:
self.setup_child(node)
@@ -617,7 +616,7 @@
del self.attributes[key]
elif isinstance(key, int):
del self.children[key]
- elif isinstance(key, types.SliceType):
+ elif isinstance(key, slice):
assert key.step in (None, 1), 'cannot handle slice with stride'
del self.children[key.start:key.stop]
else:
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-26 16:42:38 UTC (rev 8354)
+++ trunk/docutils/docutils/statemachine.py 2019-08-26 16:42:50 UTC (rev 8355)
@@ -109,7 +109,6 @@
import sys
import re
-import types
import unicodedata
from docutils import utils
from docutils.utils.error_reporting import ErrorOutput
@@ -1148,7 +1147,7 @@
# just works.
def __getitem__(self, i):
- if isinstance(i, types.SliceType):
+ if isinstance(i, slice):
assert i.step in (None, 1), 'cannot handle slice with stride'
return self.__class__(self.data[i.start:i.stop],
items=self.items[i.start:i.stop],
@@ -1157,7 +1156,7 @@
return self.data[i]
def __setitem__(self, i, item):
- if isinstance(i, types.SliceType):
+ if isinstance(i, slice):
assert i.step in (None, 1), 'cannot handle slice with stride'
if not isinstance(item, ViewList):
raise TypeError('assigning non-ViewList to ViewList slice')
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2019-08-26 16:42:38 UTC (rev 8354)
+++ trunk/docutils/test/test_nodes.py 2019-08-26 16:42:50 UTC (rev 8355)
@@ -11,7 +11,7 @@
import sys
import unittest
-import types
+
import DocutilsTestSupport # must be imported before docutils
from DocutilsTestSupport import nodes, utils
@@ -359,7 +359,7 @@
node_class_names = []
for x in dir(nodes):
c = getattr(nodes, x)
- if isinstance(c, (type, types.ClassType)) and \
+ if isinstance(c, type) and \
issubclass(c, nodes.Node) and len(c.__bases__) > 1:
node_class_names.append(x)
node_class_names.sort()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 16:44:23
|
Revision: 8356
http://sourceforge.net/p/docutils/code/8356
Author: milde
Date: 2019-08-26 16:44:19 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Use 'absolute_import' future
This mostly applies to tests.
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/test/test_parsers/test_get_parser_class.py
trunk/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py
trunk/docutils/test/test_parsers/test_rst/test_TableParser.py
trunk/docutils/test/test_parsers/test_rst/test_block_quotes.py
trunk/docutils/test/test_parsers/test_rst/test_bullet_lists.py
trunk/docutils/test/test_parsers/test_rst/test_character_level_inline_markup.py
trunk/docutils/test/test_parsers/test_rst/test_citations.py
trunk/docutils/test/test_parsers/test_rst/test_comments.py
trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_block_quotes.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_class.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_compound.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_container.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_contents.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_decorations.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_default_role.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_figures.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_line_blocks.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_parsed_literals.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_raw.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_rubrics.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_sectnum.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_sidebars.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_target_notes.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_test_directives.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_title.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_topics.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_unknown.py
trunk/docutils/test/test_parsers/test_rst/test_doctest_blocks.py
trunk/docutils/test/test_parsers/test_rst/test_east_asian_text.py
trunk/docutils/test/test_parsers/test_rst/test_enumerated_lists.py
trunk/docutils/test/test_parsers/test_rst/test_field_lists.py
trunk/docutils/test/test_parsers/test_rst/test_footnotes.py
trunk/docutils/test/test_parsers/test_rst/test_inline_markup.py
trunk/docutils/test/test_parsers/test_rst/test_interpreted.py
trunk/docutils/test/test_parsers/test_rst/test_interpreted_fr.py
trunk/docutils/test/test_parsers/test_rst/test_line_blocks.py
trunk/docutils/test/test_parsers/test_rst/test_literal_blocks.py
trunk/docutils/test/test_parsers/test_rst/test_option_lists.py
trunk/docutils/test/test_parsers/test_rst/test_outdenting.py
trunk/docutils/test/test_parsers/test_rst/test_paragraphs.py
trunk/docutils/test/test_parsers/test_rst/test_section_headers.py
trunk/docutils/test/test_parsers/test_rst/test_substitutions.py
trunk/docutils/test/test_parsers/test_rst/test_tables.py
trunk/docutils/test/test_parsers/test_rst/test_targets.py
trunk/docutils/test/test_parsers/test_rst/test_transitions.py
trunk/docutils/test/test_readers/test_get_reader_class.py
trunk/docutils/test/test_readers/test_pep/test_inline_markup.py
trunk/docutils/test/test_readers/test_pep/test_rfc2822.py
trunk/docutils/test/test_transforms/test___init__.py
trunk/docutils/test/test_transforms/test_class.py
trunk/docutils/test/test_transforms/test_contents.py
trunk/docutils/test/test_transforms/test_docinfo.py
trunk/docutils/test/test_transforms/test_doctitle.py
trunk/docutils/test/test_transforms/test_expose_internals.py
trunk/docutils/test/test_transforms/test_filter.py
trunk/docutils/test/test_transforms/test_footnotes.py
trunk/docutils/test/test_transforms/test_hyperlinks.py
trunk/docutils/test/test_transforms/test_messages.py
trunk/docutils/test/test_transforms/test_peps.py
trunk/docutils/test/test_transforms/test_sectnum.py
trunk/docutils/test/test_transforms/test_smartquotes.py
trunk/docutils/test/test_transforms/test_strip_comments.py
trunk/docutils/test/test_transforms/test_strip_elements_with_class.py
trunk/docutils/test/test_transforms/test_substitutions.py
trunk/docutils/test/test_transforms/test_target_notes.py
trunk/docutils/test/test_transforms/test_transitions.py
trunk/docutils/test/test_transforms/test_writer_aux.py
trunk/docutils/test/test_writers/test_docutils_xml.py
trunk/docutils/test/test_writers/test_get_writer_class.py
trunk/docutils/test/test_writers/test_html4css1_misc.py
trunk/docutils/test/test_writers/test_html4css1_parts.py
trunk/docutils/test/test_writers/test_html4css1_template.py
trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
trunk/docutils/test/test_writers/test_latex2e.py
trunk/docutils/test/test_writers/test_manpage.py
trunk/docutils/test/test_writers/test_null.py
trunk/docutils/test/test_writers/test_odt.py
trunk/docutils/test/test_writers/test_pseudoxml.py
trunk/docutils/test/test_writers/test_s5.py
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -6,6 +6,7 @@
Open Document Format (ODF) Writer.
"""
+from __future__ import absolute_import
__docformat__ = 'reStructuredText'
@@ -54,7 +55,7 @@
from .pygmentsformatter import OdtPygmentsProgFormatter, \
OdtPygmentsLaTeXFormatter
else:
- from pygmentsformatter import OdtPygmentsProgFormatter, \
+ from .pygmentsformatter import OdtPygmentsProgFormatter, \
OdtPygmentsLaTeXFormatter
except (ImportError, SyntaxError):
pygments = None
Modified: trunk/docutils/test/test_parsers/test_get_parser_class.py
===================================================================
--- trunk/docutils/test/test_parsers/test_get_parser_class.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_get_parser_class.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -8,8 +8,9 @@
"""
test get_parser_class
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
from docutils.parsers import get_parser_class
class GetParserClassTestCase(DocutilsTestSupport.StandardTestCase):
Modified: trunk/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_SimpleTableParser.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -8,8 +8,9 @@
"""
Tests for states.py.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.SimpleTableParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_TableParser.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_TableParser.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_TableParser.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -8,8 +8,9 @@
"""
Tests for states.py.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.GridTableParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_block_quotes.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_block_quotes.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_block_quotes.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for states.py.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_bullet_lists.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_bullet_lists.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_bullet_lists.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for states.py.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_character_level_inline_markup.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_character_level_inline_markup.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_character_level_inline_markup.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -11,8 +11,9 @@
Experimental.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite(suite_settings={'character_level_inline_markup': True})
Modified: trunk/docutils/test/test_parsers/test_rst/test_citations.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_citations.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_citations.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for states.py.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_comments.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_comments.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_comments.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for states.py.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_definition_lists.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for states.py.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for admonitions.py directives.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_block_quotes.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_block_quotes.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_block_quotes.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -8,8 +8,9 @@
Tests for the block quote directives "epigraph", "highlights", and
"pull-quote".
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_class.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_class.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_class.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for the 'class' directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Test the 'code' directive in parsers/rst/directives/body.py.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
from docutils.utils.code_analyzer import with_pygments
def suite():
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Test the 'code' directive in body.py with syntax_highlight = 'long'.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
from docutils.utils.code_analyzer import with_pygments
def suite():
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Test the 'code' directive in body.py with syntax_highlight = 'none'.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite(suite_settings={'syntax_highlight':'none'})
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_compound.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_compound.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_compound.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for the 'compound' directive from body.py.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_container.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_container.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_container.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for the 'container' directive from body.py.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_contents.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_contents.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_contents.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for parts.py contents directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_date.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for the misc.py "date" directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
import time
from docutils.utils.error_reporting import locale_encoding
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_decorations.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_decorations.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_decorations.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,9 +7,11 @@
"""
Tests for the "header" & "footer" directives.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_default_role.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_default_role.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_default_role.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for misc.py "default-role" directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_figures.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_figures.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_figures.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,9 +7,11 @@
"""
Tests for images.py figure directives.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_images.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,11 +7,13 @@
"""
Tests for images.py image directives.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
from docutils.nodes import reprunicode
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,10 +7,11 @@
"""
Tests for misc.py "include" directive.
"""
+from __future__ import absolute_import
import os.path
import sys
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
from docutils.parsers.rst import states
from docutils.utils.code_analyzer import with_pygments
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_line_blocks.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_line_blocks.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_line_blocks.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,9 +7,11 @@
"""
Tests for the body.py 'line-block' directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,9 +7,11 @@
"""
Tests for the 'math' directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,9 +7,11 @@
"""
Tests for html meta directives.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_parsed_literals.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_parsed_literals.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_parsed_literals.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,9 +7,11 @@
"""
Tests for the body.py 'parsed-literal' directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_raw.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_raw.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_raw.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,11 +7,14 @@
"""
Tests for misc.py "raw" directive.
"""
+from __future__ import absolute_import
import os.path
import sys
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
+
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for misc.py "replace" directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -8,8 +8,9 @@
Tests for misc.py "replace" directive.
Test in french (not default/fallback language).
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_role.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for misc.py "role" directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_rubrics.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_rubrics.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_rubrics.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,8 +7,9 @@
"""
Tests for the "rubric" directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
def suite():
s = DocutilsTestSupport.ParserTestSuite()
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_sectnum.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_sectnum.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_sectnum.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,9 +7,11 @@
"""
Tests for the 'sectnum' directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_sidebars.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_sidebars.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_sidebars.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,9 +7,11 @@
"""
Tests for the "sidebar" directive.
"""
+from __future__ import absolute_import
-from __init__ import DocutilsTestSupport
+from . import DocutilsTestSupport
+
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-26 16:42:50 UTC (rev 8355)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-26 16:44:19 UTC (rev 8356)
@@ -7,13 +7,14 @@
"""
Tests for tables.py directives.
"""
+from __future__ impo...
[truncated message content] |
|
From: <mi...@us...> - 2019-08-26 16:44:53
|
Revision: 8357
http://sourceforge.net/p/docutils/code/8357
Author: milde
Date: 2019-08-26 16:44:51 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Use 'sorted(foo)' instead of 'foo.sort()'
This works with iterators also (like 'dict.keys()' in Python 3)
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/tableparser.py
trunk/docutils/docutils/transforms/__init__.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/test_dependencies.py
trunk/docutils/test/test_language.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
trunk/docutils/tools/dev/unicode2rstsubs.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/docutils/nodes.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -649,8 +649,7 @@
return atts
def attlist(self):
- attlist = self.non_default_attributes().items()
- attlist.sort()
+ attlist = sorted(self.non_default_attributes().items())
return attlist
def get(self, key, failobj=None):
@@ -1782,8 +1781,7 @@
' .transform: %s.%s' % (self.transform.__module__,
self.transform.__name__),
' .details:']
- details = self.details.items()
- details.sort()
+ details = sorted(self.details.items())
for key, value in details:
if isinstance(value, Node):
internals.append('%7s%s:' % ('', key))
Modified: trunk/docutils/docutils/parsers/rst/tableparser.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/tableparser.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/docutils/parsers/rst/tableparser.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -286,8 +286,7 @@
From the data collected by `scan_cell()`, convert to the final data
structure.
"""
- rowseps = self.rowseps.keys() # list of row boundaries
- rowseps.sort()
+ rowseps = sorted(self.rowseps.keys()) # list of row boundaries
rowindex = {}
for i in range(len(rowseps)):
rowindex[rowseps[i]] = i # row boundary -> row number mapping
Modified: trunk/docutils/docutils/transforms/__init__.py
===================================================================
--- trunk/docutils/docutils/transforms/__init__.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/docutils/transforms/__init__.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -153,8 +153,7 @@
unknown_reference_resolvers = []
for i in components:
unknown_reference_resolvers.extend(i.unknown_reference_resolvers)
- decorated_list = [(f.priority, f) for f in unknown_reference_resolvers]
- decorated_list.sort()
+ decorated_list = sorted([(f.priority, f) for f in unknown_reference_resolvers])
self.unknown_reference_resolvers.extend([f[1] for f in decorated_list])
def apply_transforms(self):
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/docutils/utils/math/math2html.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -2193,9 +2193,8 @@
def escape(self, line, replacements = EscapeConfig.entities):
"Escape a line with replacements from elyxer.a map"
- pieces = replacements.keys()
+ pieces = sorted(replacements.keys())
# do them in order
- pieces.sort()
for piece in pieces:
if piece in line:
line = line.replace(piece, replacements[piece])
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/docutils/writers/_html_base.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -366,8 +366,7 @@
# Non-empty tag. Place the auxiliary <span> tag
# *inside* the element, as the first child.
suffix += '<span id="%s"></span>' % id
- attlist = atts.items()
- attlist.sort()
+ attlist = sorted(atts.items())
parts = [tagname]
for name, value in attlist:
# value=None was used for boolean attributes without
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -457,8 +457,7 @@
"""
def sortedkeys(self):
"""Return sorted list of keys"""
- keys = self.keys()
- keys.sort()
+ keys = sorted(self.keys())
return keys
def sortedvalues(self):
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -815,8 +815,7 @@
if not parts[key]:
del parts[key]
# standard output format:
- keys = parts.keys()
- keys.sort()
+ keys = sorted(parts.keys())
output = []
for key in keys:
output.append("%r: '''%s'''"
Modified: trunk/docutils/test/test_dependencies.py
===================================================================
--- trunk/docutils/test/test_dependencies.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/test/test_dependencies.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -54,9 +54,8 @@
if PIL:
keys += ['figure-image']
expected = [paths[key] for key in keys]
- record = self.get_record(writer_name='xml')
+ record = sorted(self.get_record(writer_name='xml'))
# the order of the files is arbitrary
- record.sort()
expected.sort()
self.assertEqual(record, expected)
@@ -67,9 +66,8 @@
expected = [paths[key] for key in keys]
# stylesheets are tested separately in test_stylesheet_dependencies():
so = {'stylesheet_path': None, 'stylesheet': None}
- record = self.get_record(writer_name='html', settings_overrides=so)
+ record = sorted(self.get_record(writer_name='html', settings_overrides=so))
# the order of the files is arbitrary
- record.sort()
expected.sort()
self.assertEqual(record, expected)
@@ -82,9 +80,8 @@
if PIL:
keys += ['figure-image']
expected = [paths[key] for key in keys]
- record = self.get_record(writer_name='latex')
+ record = sorted(self.get_record(writer_name='latex'))
# the order of the files is arbitrary
- record.sort()
expected.sort()
self.assertEqual(record, expected)
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/test/test_language.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -150,8 +150,7 @@
except Exception as error:
failures.append('"%s": %s' % (d, error))
inverted = self._invert(module.directives)
- canonical = directives._directive_registry.keys()
- canonical.sort()
+ canonical = sorted(directives._directive_registry.keys())
canonical.remove('restructuredtext-test-directive')
for name in canonical:
if name not in inverted:
@@ -185,8 +184,7 @@
except KeyError as error:
failures.append('"%s": %s' % (d, error))
inverted = self._invert(module.roles)
- canonical = roles._role_registry.keys()
- canonical.sort()
+ canonical = sorted(roles._role_registry.keys())
canonical.remove('restructuredtext-unimplemented-role')
for name in canonical:
if name not in inverted:
Modified: trunk/docutils/tools/dev/generate_punctuation_chars.py
===================================================================
--- trunk/docutils/tools/dev/generate_punctuation_chars.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/tools/dev/generate_punctuation_chars.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -269,8 +269,7 @@
Sort string and replace 'cdef' by 'c-f' and similar.
"""
l =[]
- s = [ord(ch) for ch in s]
- s.sort()
+ s = sorted([ord(ch) for ch in s])
for n in s:
try:
if l[-1][-1]+1 == n:
Modified: trunk/docutils/tools/dev/unicode2rstsubs.py
===================================================================
--- trunk/docutils/tools/dev/unicode2rstsubs.py 2019-08-26 16:44:19 UTC (rev 8356)
+++ trunk/docutils/tools/dev/unicode2rstsubs.py 2019-08-26 16:44:51 UTC (rev 8357)
@@ -163,8 +163,7 @@
return name
def write_sets(self):
- sets = list(self.sets.keys())
- sets.sort()
+ sets = sorted(self.sets.keys())
for set_name in sets:
self.write_set(set_name)
@@ -177,8 +176,7 @@
print('writing file "%s"' % outname)
outfile.write(self.header + '\n')
set = self.sets[set_name]
- entities = [(e.lower(), e) for e in set.keys()]
- entities.sort()
+ entities = sorted([(e.lower(), e) for e in set.keys()])
longest = 0
for _, entity_name in entities:
longest = max(longest, len(entity_name))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 16:45:35
|
Revision: 8359
http://sourceforge.net/p/docutils/code/8359
Author: milde
Date: 2019-08-26 16:45:33 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
Use 'isinstance(foo, bar)' instead of 'type(foo) is bar'
This one is more stylistic than anything.
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/test/package_unittest.py
trunk/docutils/test/test_nodes.py
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -104,7 +104,7 @@
return self.options.get('widths', '')
def get_column_widths(self, max_cols):
- if type(self.widths) == list:
+ if isinstance(self.widths, list):
if len(self.widths) != max_cols:
error = self.state_machine.reporter.error(
'"%s" widths do not match the number of columns in table '
@@ -152,7 +152,7 @@
if 'align' in self.options:
table_node['align'] = self.options.get('align')
tgroup = table_node[0]
- if type(self.widths) == list:
+ if isinstance(self.widths, list):
colspecs = [child for child in tgroup.children
if child.tagname == 'colspec']
for colspec, col_width in zip(colspecs, self.widths):
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/docutils/parsers/rst/states.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -447,7 +447,7 @@
name, prefix, suffix, parts = definition
part_strings = []
for part in parts:
- if type(part) is tuple:
+ if isinstance(part, tuple):
part_strings.append(build_regexp(part, None))
else:
part_strings.append(part)
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/docutils/statemachine.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -737,7 +737,7 @@
names = []
transitions = {}
for namestate in name_list:
- if type(namestate) is stringtype:
+ if isinstance(namestate, stringtype):
transitions[namestate] = self.make_transition(namestate)
names.append(namestate)
else:
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -168,7 +168,7 @@
self.children = []
if children is not None:
- if type(children) is list:
+ if isinstance(children, list):
for child in children:
self.append(child)
else:
Modified: trunk/docutils/test/package_unittest.py
===================================================================
--- trunk/docutils/test/package_unittest.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/test/package_unittest.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -115,7 +115,7 @@
# to cheat:
testSuite.addTest(moduleTests)
continue
- if type(suite) == types.FunctionType:
+ if isinstance(suite, types.FunctionType):
testSuite.addTest(suite())
elif isinstance(suite, unittest.TestSuite):
testSuite.addTest(suite)
@@ -152,7 +152,7 @@
print("Debug: Suite=%s" % suite, file=sys.stderr)
testRunner = unittest.TextTestRunner(verbosity=verbosity)
# run suites (if we were called from test_all) or suite...
- if type(suite) == type([]):
+ if isinstance(suite, type([])):
for s in suite:
testRunner.run(s)
else:
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2019-08-26 16:45:09 UTC (rev 8358)
+++ trunk/docutils/test/test_nodes.py 2019-08-26 16:45:33 UTC (rev 8359)
@@ -121,7 +121,7 @@
self.assertEqual(repr(uelement), "<Element: <#text: 'gr\\xfcn'>>")
else:
self.assertEqual(repr(uelement), u"<Element: <#text: 'grün'>>")
- self.assertTrue(isinstance(repr(uelement),str))
+ self.assertTrue(isinstance(repr(uelement), str))
self.assertEqual(str(element), '<Element>text\nmore</Element>')
self.assertEqual(str(uelement), '<Element>gr\xfcn</Element>')
dom = element.asdom()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 16:46:25
|
Revision: 8360
http://sourceforge.net/p/docutils/code/8360
Author: milde
Date: 2019-08-26 16:46:17 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
Consistent Python 3 checks.
Modified Paths:
--------------
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/directives/__init__.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/setup.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/test__init__.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_language.py
trunk/docutils/test/test_nodes.py
trunk/docutils/test/test_parsers/test_parser.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py
trunk/docutils/tools/dev/create_unimap.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/frontend.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -43,7 +43,7 @@
from docutils.utils.error_reporting import (locale_encoding, SafeString,
ErrorOutput, ErrorString)
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
@@ -775,7 +775,7 @@
except IOError:
continue
try:
- if sys.version_info < (3, 0):
+ if sys.version_info < (3,0):
CP.RawConfigParser.readfp(self, fp, filename)
else:
CP.RawConfigParser.read_file(self, fp, filename)
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/io.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -17,7 +17,7 @@
from docutils import TransformSpec
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
@@ -208,7 +208,7 @@
def __init__(self, source=None, source_path=None,
encoding=None, error_handler='strict',
autoclose=True,
- mode='r' if sys.version_info >= (3, 4) else 'rU', **kwargs):
+ mode='r' if sys.version_info >= (3,0) else 'rU', **kwargs):
"""
:Parameters:
- `source`: either a file-like object (which is read directly), or
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/nodes.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -29,7 +29,7 @@
import warnings
import unicodedata
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
basestring = str # noqa
@@ -64,7 +64,7 @@
"""
return True
- if sys.version_info < (3, 0):
+ if sys.version_info < (3,0):
# on 2.x, str(node) will be a byte string with Unicode
# characters > 255 escaped; on 3.x this is no longer necessary
def __str__(self):
@@ -304,7 +304,7 @@
except IndexError:
return None
-if sys.version_info < (3, 0):
+if sys.version_info < (3,0):
class reprunicode(unicode):
"""
A unicode sub-class that removes the initial u from unicode's repr.
@@ -320,7 +320,7 @@
"""
Failsave conversion of `unicode` to `str`.
"""
- if sys.version_info < (3,) and isinstance(s, unicode):
+ if sys.version_info < (3,0) and isinstance(s, unicode):
return s.encode('ascii', 'backslashreplace')
return s
@@ -352,7 +352,7 @@
children = ()
"""Text nodes have no children, and cannot have children."""
- if sys.version_info > (3,):
+ if sys.version_info > (3,0):
def __new__(cls, data, rawsource=None):
"""Prevent the rawsource argument from propagating to str."""
if isinstance(data, bytes):
@@ -544,7 +544,7 @@
else:
return self.emptytag()
- if sys.version_info > (3,):
+ if sys.version_info > (3,0):
# 2to3 doesn't convert __unicode__ to __str__
__str__ = __unicode__
Modified: trunk/docutils/docutils/parsers/rst/directives/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/__init__.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/parsers/rst/directives/__init__.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -16,7 +16,7 @@
from docutils.utils import split_escaped_whitespace, escape2null, unescape
from docutils.parsers.rst.languages import en as _fallback_language_module
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unichr = chr # noqa
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -473,7 +473,7 @@
'Invalid context: the "%s" directive can only be used within '
'a substitution definition.' % self.name)
format_str = '\n'.join(self.content) or '%Y-%m-%d'
- if sys.version_info< (3, 0):
+ if sys.version_info< (3,0):
try:
format_str = format_str.encode(locale_encoding or 'utf-8')
except UnicodeEncodeError:
@@ -496,7 +496,7 @@
# time.gmtime(int(source_date_epoch)))
# else:
text = time.strftime(format_str)
- if sys.version_info< (3, 0):
+ if sys.version_info< (3,0):
# `text` is a byte string that may contain non-ASCII characters:
try:
text = text.decode(locale_encoding or 'utf-8')
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -263,7 +263,7 @@
return [detail.args[0]]
except csv.Error as detail:
message = str(detail)
- if sys.version_info < (3,) and '1-character string' in message:
+ if sys.version_info < (3,0) and '1-character string' in message:
message += '\nwith Python 2.x this must be an ASCII character.'
error = self.state_machine.reporter.error(
'Error with CSV data in "%s" directive:\n%s'
@@ -356,7 +356,7 @@
raise SystemMessagePropagation(error)
return csv_data, source
- if sys.version_info < (3,):
+ if sys.version_info < (3,0):
# 2.x csv module doesn't do Unicode
def decode_from_csv(s):
return s.decode('utf-8')
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/statemachine.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -113,7 +113,7 @@
from docutils import utils
from docutils.utils.error_reporting import ErrorOutput
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -28,7 +28,7 @@
from docutils.transforms import TransformError, Transform
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/transforms/universal.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -24,7 +24,7 @@
from docutils.utils import smartquotes
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/utils/__init__.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -22,7 +22,7 @@
import docutils.io
from docutils.utils.error_reporting import ErrorOutput, SafeString
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str
Modified: trunk/docutils/docutils/utils/error_reporting.py
===================================================================
--- trunk/docutils/docutils/utils/error_reporting.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/utils/error_reporting.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -65,7 +65,7 @@
locale_encoding = None
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/writers/_html_base.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -40,7 +40,7 @@
math2html, latex2mathml, tex2mathml_extern)
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -17,7 +17,7 @@
import docutils
from docutils import frontend, writers, nodes
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
@@ -172,7 +172,7 @@
self.output.append(xml_string)
self.default_departure(node) # or not?
# Check validity of raw XML:
- if isinstance(xml_string, unicode) and sys.version_info < (3,):
+ if isinstance(xml_string, unicode) and sys.version_info < (3,0):
xml_string = xml_string.encode('utf8')
try:
self.xmlparser.parse(StringIO(xml_string))
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -28,7 +28,7 @@
from docutils.utils.math import pick_math_environment, unichar2tex
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/writers/manpage.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -47,7 +47,7 @@
import re
import sys
-if sys.version_info < (3, 0):
+if sys.version_info < (3,0):
range = xrange
import docutils
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -33,7 +33,7 @@
from docutils import frontend, nodes, utils, writers, languages
from docutils.readers import standalone
from docutils.transforms import references
-if sys.version_info.major >= 3:
+if sys.version_info >= (3,0):
from io import StringIO
from urllib.request import urlopen
from urllib.error import HTTPError
@@ -302,7 +302,7 @@
def ToString(et):
outstream = StringIO()
- if sys.version_info >= (3, 0):
+ if sys.version_info >= (3,0):
et.write(outstream, encoding="unicode")
else:
et.write(outstream)
@@ -902,7 +902,7 @@
self.document.reporter.warning(
'Style "%s" is not a style used by odtwriter.' % (
rststyle, ))
- if sys.version_info.major >= 3:
+ if sys.version_info >= (3,0):
self.format_map[rststyle] = format
else:
self.format_map[rststyle] = format.decode('utf-8')
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/setup.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -13,7 +13,7 @@
from distutils.core import setup, Command
from distutils.command.build import build
from distutils.command.build_py import build_py
- if sys.version_info >= (3,):
+ if sys.version_info >= (3,0):
from distutils.command.build_py import build_py_2to3
from distutils.util import copydir_run_2to3
from distutils.command.install_data import install_data
@@ -27,7 +27,7 @@
sys.exit(1)
-if sys.version_info >= (3,):
+if sys.version_info >= (3,0):
# copy-convert auxiliary python sources
class copy_build_py_2to3(build_py_2to3):
"""Copy/convert Python source files in given directories recursively.
@@ -97,7 +97,7 @@
kwargs['cmdclass'] = {'build_data': build_data,
'install_data': smart_install_data}
# Auto-convert source code for Python 3
- if sys.version_info >= (3,):
+ if sys.version_info >= (3,0):
kwargs['cmdclass']['build_py'] = copy_build_py_2to3
else:
kwargs['cmdclass']['build_py'] = build_py
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/test/DocutilsTestSupport.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -89,7 +89,7 @@
import pdb
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
@@ -202,7 +202,7 @@
"""`input`, `output`, and `expected` should all be strings."""
if isinstance(input, unicode):
input = input.encode('raw_unicode_escape')
- if sys.version_info > (3,):
+ if sys.version_info > (3,0):
# API difference: Python 3's node.__str__ doesn't escape
#assert expected is None or isinstance(expected, unicode)
if isinstance(expected, bytes):
Modified: trunk/docutils/test/test__init__.py
===================================================================
--- trunk/docutils/test/test__init__.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/test/test__init__.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -16,7 +16,7 @@
import docutils.utils
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/test/test_error_reporting.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -36,7 +36,7 @@
from docutils.utils.error_reporting import SafeString, ErrorString, ErrorOutput
oldlocale = None
-if sys.version_info < (3, 0): # problems solved in py3k
+if sys.version_info < (3,0): # problems solved in py3k
try:
import locale # module missing in Jython
oldlocale = locale.getlocale()
@@ -44,7 +44,7 @@
print('cannot test error reporting with problematic locales,\n'
'`import locale` failed.')
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/test/test_language.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -26,7 +26,7 @@
reference_language = 'en'
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/test/test_nodes.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -17,7 +17,7 @@
debug = False
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
@@ -36,7 +36,7 @@
self.assertEqual(self.text.shortrepr(),
r"<#text: 'Line 1.\nLine 2.'>")
self.assertEqual(nodes.reprunicode('foo'), u'foo')
- if sys.version_info < (3,):
+ if sys.version_info < (3,0):
self.assertEqual(repr(self.unicode_text), r"<#text: 'M\xf6hren'>")
else:
self.assertEqual(repr(self.unicode_text), u"<#text: 'Möhren'>")
@@ -65,7 +65,7 @@
self.assertEqual(stripped2, u's noc')
def test_asciirestriction(self):
- if sys.version_info < (3,):
+ if sys.version_info < (3,0):
self.assertRaises(UnicodeDecodeError, nodes.Text,
b'hol%s' % chr(224))
else:
@@ -98,7 +98,7 @@
del element['attr']
element['mark'] = u'\u2022'
self.assertEqual(repr(element), '<Element: >')
- if sys.version_info < (3,):
+ if sys.version_info < (3,0):
self.assertEqual(str(element), '<Element mark="\\u2022"/>')
else:
self.assertEqual(str(element), u'<Element mark="\u2022"/>')
@@ -106,7 +106,7 @@
self.assertEqual(dom.toxml(), u'<Element mark="\u2022"/>')
dom.unlink()
element['names'] = ['nobody', u'имя', u'näs']
- if sys.version_info < (3,):
+ if sys.version_info < (3,0):
self.assertEqual(repr(element),
'<Element "nobody; \\u0438\\u043c\\u044f; n\\xe4s": >')
else:
@@ -117,7 +117,7 @@
element = nodes.Element('text\nmore', nodes.Text('text\nmore'))
uelement = nodes.Element(u'grün', nodes.Text(u'grün'))
self.assertEqual(repr(element), r"<Element: <#text: 'text\nmore'>>")
- if sys.version_info < (3,):
+ if sys.version_info < (3,0):
self.assertEqual(repr(uelement), "<Element: <#text: 'gr\\xfcn'>>")
else:
self.assertEqual(repr(uelement), u"<Element: <#text: 'grün'>>")
@@ -341,7 +341,7 @@
self.assertTrue(isinstance(nodes.reprunicode('foo'), unicode))
self.assertEqual(nodes.reprunicode('foo'), u'foo')
self.assertEqual(nodes.reprunicode(u'Möhre'), u'Möhre')
- if sys.version_info < (3,): # strip leading "u" from representation
+ if sys.version_info < (3,0): # strip leading "u" from representation
self.assertEqual(repr(nodes.reprunicode(u'Möhre')),
repr(u'Möhre')[1:])
else: # no change to `unicode` under Python 3k
@@ -350,7 +350,7 @@
def test_ensure_str(self):
self.assertTrue(isinstance(nodes.ensure_str(u'über'), str))
self.assertEqual(nodes.ensure_str('over'), 'over')
- if sys.version_info < (3,): # strip leading "u" from representation
+ if sys.version_info < (3,0): # strip leading "u" from representation
self.assertEqual(nodes.ensure_str(u'über'), r'\xfcber')
else:
self.assertEqual(nodes.ensure_str(u'über'), r'über')
Modified: trunk/docutils/test/test_parsers/test_parser.py
===================================================================
--- trunk/docutils/test/test_parsers/test_parser.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/test/test_parsers/test_parser.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -23,7 +23,7 @@
document = utils.new_document('test data', frontend.OptionParser(
components=(parser, )).get_default_values())
- if sys.version_info < (3,):
+ if sys.version_info < (3,0):
# supplying string input is supported, but only if ascii-decodable
self.assertRaises(UnicodeDecodeError,
parser.parse, b'hol%s' % chr(224), document)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -16,7 +16,7 @@
from docutils.utils.code_analyzer import with_pygments
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unichr = chr # noqa
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -18,7 +18,7 @@
from docutils.parsers.rst.directives import tables
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str # noqa
unichr = chr # noqa
@@ -46,10 +46,10 @@
if sys.version_info < (2,7,4) or platform.python_implementation() == 'PyPy':
csv_eod_error_str = 'newline inside string'
# pypy adds a line number
-if sys.version_info > (2, 7) and platform.python_implementation() == 'PyPy':
+if sys.version_info >= (3,0) and platform.python_implementation() == 'PyPy':
csv_eod_error_str = 'line 1: ' + csv_eod_error_str
csv_unknown_url = "'bogus.csv'"
-if sys.version_info < (3, 0):
+if sys.version_info < (3,0):
csv_unknown_url = "bogus.csv"
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -14,7 +14,7 @@
from . import DocutilsTestSupport
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unichr = chr # noqa
Modified: trunk/docutils/tools/dev/create_unimap.py
===================================================================
--- trunk/docutils/tools/dev/create_unimap.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/tools/dev/create_unimap.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -14,7 +14,7 @@
import sys
import pprint
-if sys.version_info >= (3, 0):
+if sys.version_info >= (3,0):
unicode = str #noqa
else:
bytes = str # noqa
@@ -22,7 +22,7 @@
def w(s):
- if sys.version_info >= (3, 0) and isinstance(s, unicode):
+ if sys.version_info >= (3,0) and isinstance(s, unicode):
s = s.encode('utf8')
sys.stdout.write(s)
Modified: trunk/docutils/tools/dev/generate_punctuation_chars.py
===================================================================
--- trunk/docutils/tools/dev/generate_punctuation_chars.py 2019-08-26 16:45:33 UTC (rev 8359)
+++ trunk/docutils/tools/dev/generate_punctuation_chars.py 2019-08-26 16:46:17 UTC (rev 8360)
@@ -38,7 +38,7 @@
import sys
import unicodedata
-if sys.version_info >= (3,):
+if sys.version_info >= (3,0):
unichr = chr # unichr not available in Py3k
else:
import codecs
@@ -361,7 +361,7 @@
# Import the punctuation_chars module from the source
# or Py3k build path for local Python modules::
- if sys.version_info < (3,):
+ if sys.version_info < (3,0):
sys.path.insert(0, '../../docutils')
else:
sys.path.insert(0, '../../build/lib')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-26 16:46:53
|
Revision: 8361
http://sourceforge.net/p/docutils/code/8361
Author: milde
Date: 2019-08-26 16:46:50 +0000 (Mon, 26 Aug 2019)
Log Message:
-----------
py3: Replace 'foo.next()' with 'next(foo)'
The former only works in Python 2, while the latter works in Python 2.7
and 3.x.
Signed-off-by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/utils/code_analyzer.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
Modified: trunk/docutils/docutils/utils/code_analyzer.py
===================================================================
--- trunk/docutils/docutils/utils/code_analyzer.py 2019-08-26 16:46:17 UTC (rev 8360)
+++ trunk/docutils/docutils/utils/code_analyzer.py 2019-08-26 16:46:50 UTC (rev 8361)
@@ -83,7 +83,7 @@
Also strip the final newline (added by pygments).
"""
tokens = iter(tokens)
- (lasttype, lastval) = tokens.next()
+ (lasttype, lastval) = next(tokens)
for ttype, value in tokens:
if ttype is lasttype:
lastval += value
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2019-08-26 16:46:17 UTC (rev 8360)
+++ trunk/docutils/docutils/utils/math/math2html.py 2019-08-26 16:46:50 UTC (rev 8361)
@@ -2208,7 +2208,7 @@
if ord(pos.current()) > 128:
codepoint = hex(ord(pos.current()))
if codepoint == '0xd835':
- codepoint = hex(ord(pos.next()) + 0xf800)
+ codepoint = hex(ord(next(pos)) + 0xf800)
result += '&#' + codepoint[1:] + ';'
else:
result += pos.current()
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2019-08-26 16:46:17 UTC (rev 8360)
+++ trunk/docutils/docutils/writers/manpage.py 2019-08-26 16:46:50 UTC (rev 8361)
@@ -812,7 +812,7 @@
def visit_list_item(self, node):
# man 7 man argues to use ".IP" instead of ".TP"
self.body.append('.IP %s %d\n' % (
- self._list_char[-1].next(),
+ next(self._list_char[-1]),
self._list_char[-1].get_width(),))
def depart_list_item(self, node):
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-26 16:46:17 UTC (rev 8360)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2019-08-26 16:46:50 UTC (rev 8361)
@@ -59,7 +59,7 @@
csv_data = unicode(csv_data, 'latin1').splitlines()
reader = csv.reader([tables.CSVTable.encode_for_csv(line + '\n')
for line in csv_data])
- reader.next()
+ next(reader)
null_bytes_exception = DocutilsTestSupport.exception_data(null_bytes)[0]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-27 12:09:20
|
Revision: 8366
http://sourceforge.net/p/docutils/code/8366
Author: milde
Date: 2019-08-27 12:09:19 +0000 (Tue, 27 Aug 2019)
Log Message:
-----------
py3: Replace 'ur' prefix
While the 'u' prefix was backported to Python 3.3 or thereabouts, 'ur'
remains invalid in Python 3. Just escape all backslashes and use plain
old 'u'.
Based on patch by Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/docutils/utils/math/tex2mathml_extern.py
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_parsers/test_rst/test_east_asian_text.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2019-08-27 12:09:01 UTC (rev 8365)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2019-08-27 12:09:19 UTC (rev 8366)
@@ -6,12 +6,12 @@
# Based on rst2mathml.py from the latex_math sandbox project
# © 2005 Jens Jørgen Mortensen
# :License: Released under the terms of the `2-Clause BSD license`_, in short:
-#
+#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.
# This file is offered as-is, without any warranty.
-#
+#
# .. _2-Clause BSD license: http://www.spdx.org/licenses/BSD-2-Clause
@@ -412,7 +412,7 @@
node = entry
skip = 2
else:
- raise SyntaxError(ur'Syntax error: "%s%s"' % (c, c2))
+ raise SyntaxError(u'Syntax error: "%s%s"' % (c, c2))
elif c.isalpha():
node = node.append(mi(c))
elif c.isdigit():
@@ -453,7 +453,7 @@
node.close().append(entry)
node = entry
else:
- raise SyntaxError(ur'Illegal character: "%s"' % c)
+ raise SyntaxError(u'Illegal character: "%s"' % c)
string = string[skip:]
return tree
@@ -474,15 +474,15 @@
node = entry
elif name == 'end':
if not string.startswith('{matrix}'):
- raise SyntaxError(ur'Expected "\end{matrix}"!')
+ raise SyntaxError(u'Expected "\\end{matrix}"!')
skip += 8
node = node.close().close().close()
elif name in ('text', 'mathrm'):
if string[0] != '{':
- raise SyntaxError(ur'Expected "\text{...}"!')
+ raise SyntaxError(u'Expected "\\text{...}"!')
i = string.find('}')
if i == -1:
- raise SyntaxError(ur'Expected "\text{...}"!')
+ raise SyntaxError(u'Expected "\\text{...}"!')
node = node.append(mtext(string[1:i]))
skip += i + 1
elif name == 'sqrt':
@@ -520,7 +520,7 @@
if string.startswith(operator):
break
else:
- raise SyntaxError(ur'Expected something to negate: "\not ..."!')
+ raise SyntaxError(u'Expected something to negate: "\\not ..."!')
node = node.append(mo(negatables[operator]))
skip += len(operator)
elif name == 'mathbf':
@@ -529,12 +529,12 @@
node = style
elif name == 'mathbb':
if string[0] != '{' or not string[1].isupper() or string[2] != '}':
- raise SyntaxError(ur'Expected something like "\mathbb{A}"!')
+ raise SyntaxError(u'Expected something like "\\mathbb{A}"!')
node = node.append(mi(mathbb[string[1]]))
skip += 3
elif name in ('mathscr', 'mathcal'):
if string[0] != '{' or string[2] != '}':
- raise SyntaxError(ur'Expected something like "\mathscr{A}"!')
+ raise SyntaxError(u'Expected something like "\\mathscr{A}"!')
node = node.append(mi(mathscr[string[1]]))
skip += 3
elif name == 'colon': # "normal" colon, not binary operator
@@ -559,12 +559,10 @@
return node, skip
def tex2mathml(tex_math, inline=True):
- """Return string with MathML code corresponding to `tex_math`.
-
+ """Return string with MathML code corresponding to `tex_math`.
+
`inline`=True is for inline math and `inline`=False for displayed math.
"""
-
+
mathml_tree = parse_latex_math(tex_math, inline=inline)
return ''.join(mathml_tree.xml())
-
-
Modified: trunk/docutils/docutils/utils/math/tex2mathml_extern.py
===================================================================
--- trunk/docutils/docutils/utils/math/tex2mathml_extern.py 2019-08-27 12:09:01 UTC (rev 8365)
+++ trunk/docutils/docutils/utils/math/tex2mathml_extern.py 2019-08-27 12:09:19 UTC (rev 8366)
@@ -141,7 +141,8 @@
# self-test
if __name__ == "__main__":
- example = ur'\frac{\partial \sin^2(\alpha)}{\partial \vec r} \varpi \, \text{Grüße}'
+ example = (u'\\frac{\\partial \\sin^2(\\alpha)}{\\partial \\vec r}'
+ u'\\varpi \\, \\text{Grüße}')
# print(latexml(example).encode('utf8'))
# print(ttm(example))
print(blahtexml(example).encode('utf8'))
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2019-08-27 12:09:01 UTC (rev 8365)
+++ trunk/docutils/docutils/utils/smartquotes.py 2019-08-27 12:09:19 UTC (rev 8366)
@@ -658,20 +658,21 @@
text = re.sub(r"'(?=\d{2}s)", smart.apostrophe, text)
# Get most opening single quotes:
- opening_single_quotes_regex = re.compile(ur"""
+ opening_single_quotes_regex = re.compile(u"""
(# ?<= # look behind fails: requires fixed-width pattern
- \s | # a whitespace char, or
+ \\s | # a whitespace char, or
%s | # another separating char, or
| # a non-breaking space entity, or
- [–—] | # literal dashes, or
+ [\u2013 \u2014 ] | # literal dashes, or
-- | # dumb dashes, or
&[mn]dash; | # dash entities (named or
%s | # decimal or
- &\#x201[34]; # hex)
+ &\\#x201[34]; # hex)
)
' # the quote
- (?=\w) # followed by a word character
- """ % (open_class,dec_dashes), re.VERBOSE | re.UNICODE)
+ (?=\\w) # followed by a word character
+ """ % (open_class, dec_dashes), re.VERBOSE | re.UNICODE)
+
text = opening_single_quotes_regex.sub(r'\1'+smart.osquote, text)
# In many locales, single closing quotes are different from apostrophe:
@@ -691,20 +692,21 @@
text = re.sub(r"""'""", smart.osquote, text)
# Get most opening double quotes:
- opening_double_quotes_regex = re.compile(ur"""
+ opening_double_quotes_regex = re.compile(u"""
(
- \s | # a whitespace char, or
+ \\s | # a whitespace char, or
%s | # another separating char, or
| # a non-breaking space entity, or
- [–—] | # literal dashes, or
+ [\u2013 \u2014 ] | # literal dashes, or
-- | # dumb dashes, or
&[mn]dash; | # dash entities (named or
%s | # decimal or
- &\#x201[34]; # hex)
+ &\\#x201[34]; # hex)
)
" # the quote
- (?=\w) # followed by a word character
+ (?=\\w) # followed by a word character
""" % (open_class,dec_dashes), re.VERBOSE | re.UNICODE)
+
text = opening_double_quotes_regex.sub(r'\1'+smart.opquote, text)
# Double closing quotes:
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-27 12:09:01 UTC (rev 8365)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-27 12:09:19 UTC (rev 8366)
@@ -704,21 +704,21 @@
# characters that need escaping even in `alltt` environments:
alltt = {
- ord('\\'): ur'\textbackslash{}',
- ord('{'): ur'\{',
- ord('}'): ur'\}',
+ ord('\\'): u'\\textbackslash{}',
+ ord('{'): u'\\{',
+ ord('}'): u'\\}',
}
# characters that normally need escaping:
special = {
- ord('#'): ur'\#',
- ord('$'): ur'\$',
- ord('%'): ur'\%',
- ord('&'): ur'\&',
- ord('~'): ur'\textasciitilde{}',
- ord('_'): ur'\_',
- ord('^'): ur'\textasciicircum{}',
+ ord('#'): u'\\#',
+ ord('$'): u'\\$',
+ ord('%'): u'\\%',
+ ord('&'): u'\\&',
+ ord('~'): u'\\textasciitilde{}',
+ ord('_'): u'\\_',
+ ord('^'): u'\\textasciicircum{}',
# straight double quotes are 'active' in many languages
- ord('"'): ur'\textquotedbl{}',
+ ord('"'): u'\\textquotedbl{}',
# Square brackets are ordinary chars and cannot be escaped with '\',
# so we put them in a group '{[}'. (Alternative: ensure that all
# macros with optional arguments are terminated with {} and text
@@ -725,144 +725,144 @@
# inside any optional argument is put in a group ``[{text}]``).
# Commands with optional args inside an optional arg must be put in a
# group, e.g. ``\item[{\hyperref[label]{text}}]``.
- ord('['): ur'{[}',
- ord(']'): ur'{]}',
+ ord('['): u'{[}',
+ ord(']'): u'{]}',
# the soft hyphen is unknown in 8-bit text
# and not properly handled by XeTeX
- 0x00AD: ur'\-', # SOFT HYPHEN
+ 0x00AD: u'\\-', # SOFT HYPHEN
}
# Unicode chars that are not recognized by LaTeX's utf8 encoding
unsupported_unicode = {
# TODO: ensure white space also at the beginning of a line?
- # 0x00A0: ur'\leavevmode\nobreak\vadjust{}~'
- 0x2000: ur'\enskip', # EN QUAD
- 0x2001: ur'\quad', # EM QUAD
- 0x2002: ur'\enskip', # EN SPACE
- 0x2003: ur'\quad', # EM SPACE
- 0x2008: ur'\,', # PUNCTUATION SPACE
- 0x200b: ur'\hspace{0pt}', # ZERO WIDTH SPACE
- 0x202F: ur'\,', # NARROW NO-BREAK SPACE
- # 0x02d8: ur'\\u{ }', # BREVE
- 0x2011: ur'\hbox{-}', # NON-BREAKING HYPHEN
- 0x212b: ur'\AA', # ANGSTROM SIGN
- 0x21d4: ur'\ensuremath{\Leftrightarrow}',
+ # 0x00A0: u'\\leavevmode\\nobreak\\vadjust{}~'
+ 0x2000: u'\\enskip', # EN QUAD
+ 0x2001: u'\\quad', # EM QUAD
+ 0x2002: u'\\enskip', # EN SPACE
+ 0x2003: u'\\quad', # EM SPACE
+ 0x2008: u'\\,', # PUNCTUATION SPACE
+ 0x200b: u'\\hspace{0pt}', # ZERO WIDTH SPACE
+ 0x202F: u'\\,', # NARROW NO-BREAK SPACE
+ # 0x02d8: u'\\\u{ }', # BREVE
+ 0x2011: u'\\hbox{-}', # NON-BREAKING HYPHEN
+ 0x212b: u'\\AA', # ANGSTROM SIGN
+ 0x21d4: u'\\ensuremath{\\Leftrightarrow}',
# Docutils footnote symbols:
- 0x2660: ur'\ensuremath{\spadesuit}',
- 0x2663: ur'\ensuremath{\clubsuit}',
- 0xfb00: ur'ff', # LATIN SMALL LIGATURE FF
- 0xfb01: ur'fi', # LATIN SMALL LIGATURE FI
- 0xfb02: ur'fl', # LATIN SMALL LIGATURE FL
- 0xfb03: ur'ffi', # LATIN SMALL LIGATURE FFI
- 0xfb04: ur'ffl', # LATIN SMALL LIGATURE FFL
+ 0x2660: u'\\ensuremath{\\spadesuit}',
+ 0x2663: u'\\ensuremath{\\clubsuit}',
+ 0xfb00: u'ff', # LATIN SMALL LIGATURE FF
+ 0xfb01: u'fi', # LATIN SMALL LIGATURE FI
+ 0xfb02: u'fl', # LATIN SMALL LIGATURE FL
+ 0xfb03: u'ffi', # LATIN SMALL LIGATURE FFI
+ 0xfb04: u'ffl', # LATIN SMALL LIGATURE FFL
}
# Unicode chars that are recognized by LaTeX's utf8 encoding
utf8_supported_unicode = {
- 0x00A0: ur'~', # NO-BREAK SPACE
- 0x00AB: ur'\guillemotleft{}', # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
- 0x00bb: ur'\guillemotright{}', # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
- 0x200C: ur'\textcompwordmark{}', # ZERO WIDTH NON-JOINER
- 0x2013: ur'\textendash{}',
- 0x2014: ur'\textemdash{}',
- 0x2018: ur'\textquoteleft{}',
- 0x2019: ur'\textquoteright{}',
- 0x201A: ur'\quotesinglbase{}', # SINGLE LOW-9 QUOTATION MARK
- 0x201C: ur'\textquotedblleft{}',
- 0x201D: ur'\textquotedblright{}',
- 0x201E: ur'\quotedblbase{}', # DOUBLE LOW-9 QUOTATION MARK
- 0x2030: ur'\textperthousand{}', # PER MILLE SIGN
- 0x2031: ur'\textpertenthousand{}', # PER TEN THOUSAND SIGN
- 0x2039: ur'\guilsinglleft{}',
- 0x203A: ur'\guilsinglright{}',
- 0x2423: ur'\textvisiblespace{}', # OPEN BOX
- 0x2020: ur'\dag{}',
- 0x2021: ur'\ddag{}',
- 0x2026: ur'\dots{}',
- 0x2122: ur'\texttrademark{}',
+ 0x00A0: u'~', # NO-BREAK SPACE
+ 0x00AB: u'\\guillemotleft{}', # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
+ 0x00bb: u'\\guillemotright{}', # RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
+ 0x200C: u'\\textcompwordmark{}', # ZERO WIDTH NON-JOINER
+ 0x2013: u'\\textendash{}',
+ 0x2014: u'\\textemdash{}',
+ 0x2018: u'\\textquoteleft{}',
+ 0x2019: u'\\textquoteright{}',
+ 0x201A: u'\\quotesinglbase{}', # SINGLE LOW-9 QUOTATION MARK
+ 0x201C: u'\\textquotedblleft{}',
+ 0x201D: u'\\textquotedblright{}',
+ 0x201E: u'\\quotedblbase{}', # DOUBLE LOW-9 QUOTATION MARK
+ 0x2030: u'\\textperthousand{}', # PER MILLE SIGN
+ 0x2031: u'\\textpertenthousand{}', # PER TEN THOUSAND SIGN
+ 0x2039: u'\\guilsinglleft{}',
+ 0x203A: u'\\guilsinglright{}',
+ 0x2423: u'\\textvisiblespace{}', # OPEN BOX
+ 0x2020: u'\\dag{}',
+ 0x2021: u'\\ddag{}',
+ 0x2026: u'\\dots{}',
+ 0x2122: u'\\texttrademark{}',
}
# recognized with 'utf8', if textcomp is loaded
textcomp = {
# Latin-1 Supplement
- 0x00a2: ur'\textcent{}', # ¢ CENT SIGN
- 0x00a4: ur'\textcurrency{}', # ¤ CURRENCY SYMBOL
- 0x00a5: ur'\textyen{}', # ¥ YEN SIGN
- 0x00a6: ur'\textbrokenbar{}', # ¦ BROKEN BAR
- 0x00a7: ur'\textsection{}', # § SECTION SIGN
- 0x00a8: ur'\textasciidieresis{}', # ¨ DIAERESIS
- 0x00a9: ur'\textcopyright{}', # © COPYRIGHT SIGN
- 0x00aa: ur'\textordfeminine{}', # ª FEMININE ORDINAL INDICATOR
- 0x00ac: ur'\textlnot{}', # ¬ NOT SIGN
- 0x00ae: ur'\textregistered{}', # ® REGISTERED SIGN
- 0x00af: ur'\textasciimacron{}', # ¯ MACRON
- 0x00b0: ur'\textdegree{}', # ° DEGREE SIGN
- 0x00b1: ur'\textpm{}', # ± PLUS-MINUS SIGN
- 0x00b2: ur'\texttwosuperior{}', # ² SUPERSCRIPT TWO
- 0x00b3: ur'\textthreesuperior{}', # ³ SUPERSCRIPT THREE
- 0x00b4: ur'\textasciiacute{}', # ´ ACUTE ACCENT
- 0x00b5: ur'\textmu{}', # µ MICRO SIGN
- 0x00b6: ur'\textparagraph{}', # ¶ PILCROW SIGN # != \textpilcrow
- 0x00b9: ur'\textonesuperior{}', # ¹ SUPERSCRIPT ONE
- 0x00ba: ur'\textordmasculine{}', # º MASCULINE ORDINAL INDICATOR
- 0x00bc: ur'\textonequarter{}', # 1/4 FRACTION
- 0x00bd: ur'\textonehalf{}', # 1/2 FRACTION
- 0x00be: ur'\textthreequarters{}', # 3/4 FRACTION
- 0x00d7: ur'\texttimes{}', # × MULTIPLICATION SIGN
- 0x00f7: ur'\textdiv{}', # ÷ DIVISION SIGN
+ 0x00a2: u'\\textcent{}', # ¢ CENT SIGN
+ 0x00a4: u'\\textcurrency{}', # ¤ CURRENCY SYMBOL
+ 0x00a5: u'\\textyen{}', # ¥ YEN SIGN
+ 0x00a6: u'\\textbrokenbar{}', # ¦ BROKEN BAR
+ 0x00a7: u'\\textsection{}', # § SECTION SIGN
+ 0x00a8: u'\\textasciidieresis{}', # ¨ DIAERESIS
+ 0x00a9: u'\\textcopyright{}', # © COPYRIGHT SIGN
+ 0x00aa: u'\\textordfeminine{}', # ª FEMININE ORDINAL INDICATOR
+ 0x00ac: u'\\textlnot{}', # ¬ NOT SIGN
+ 0x00ae: u'\\textregistered{}', # ® REGISTERED SIGN
+ 0x00af: u'\\textasciimacron{}', # ¯ MACRON
+ 0x00b0: u'\\textdegree{}', # ° DEGREE SIGN
+ 0x00b1: u'\\textpm{}', # ± PLUS-MINUS SIGN
+ 0x00b2: u'\\texttwosuperior{}', # ² SUPERSCRIPT TWO
+ 0x00b3: u'\\textthreesuperior{}', # ³ SUPERSCRIPT THREE
+ 0x00b4: u'\\textasciiacute{}', # ´ ACUTE ACCENT
+ 0x00b5: u'\\textmu{}', # µ MICRO SIGN
+ 0x00b6: u'\\textparagraph{}', # ¶ PILCROW SIGN # != \textpilcrow
+ 0x00b9: u'\\textonesuperior{}', # ¹ SUPERSCRIPT ONE
+ 0x00ba: u'\\textordmasculine{}', # º MASCULINE ORDINAL INDICATOR
+ 0x00bc: u'\\textonequarter{}', # 1/4 FRACTION
+ 0x00bd: u'\\textonehalf{}', # 1/2 FRACTION
+ 0x00be: u'\\textthreequarters{}', # 3/4 FRACTION
+ 0x00d7: u'\\texttimes{}', # × MULTIPLICATION SIGN
+ 0x00f7: u'\\textdiv{}', # ÷ DIVISION SIGN
# others
- 0x0192: ur'\textflorin{}', # LATIN SMALL LETTER F WITH HOOK
- 0x02b9: ur'\textasciiacute{}', # MODIFIER LETTER PRIME
- 0x02ba: ur'\textacutedbl{}', # MODIFIER LETTER DOUBLE PRIME
- 0x2016: ur'\textbardbl{}', # DOUBLE VERTICAL LINE
- 0x2022: ur'\textbullet{}', # BULLET
- 0x2032: ur'\textasciiacute{}', # PRIME
- 0x2033: ur'\textacutedbl{}', # DOUBLE PRIME
- 0x2035: ur'\textasciigrave{}', # REVERSED PRIME
- 0x2036: ur'\textgravedbl{}', # REVERSED DOUBLE PRIME
- 0x203b: ur'\textreferencemark{}', # REFERENCE MARK
- 0x203d: ur'\textinterrobang{}', # INTERROBANG
- 0x2044: ur'\textfractionsolidus{}', # FRACTION SLASH
- 0x2045: ur'\textlquill{}', # LEFT SQUARE BRACKET WITH QUILL
- 0x2046: ur'\textrquill{}', # RIGHT SQUARE BRACKET WITH QUILL
- 0x2052: ur'\textdiscount{}', # COMMERCIAL MINUS SIGN
- 0x20a1: ur'\textcolonmonetary{}', # COLON SIGN
- 0x20a3: ur'\textfrenchfranc{}', # FRENCH FRANC SIGN
- 0x20a4: ur'\textlira{}', # LIRA SIGN
- 0x20a6: ur'\textnaira{}', # NAIRA SIGN
- 0x20a9: ur'\textwon{}', # WON SIGN
- 0x20ab: ur'\textdong{}', # DONG SIGN
- 0x20ac: ur'\texteuro{}', # EURO SIGN
- 0x20b1: ur'\textpeso{}', # PESO SIGN
- 0x20b2: ur'\textguarani{}', # GUARANI SIGN
- 0x2103: ur'\textcelsius{}', # DEGREE CELSIUS
- 0x2116: ur'\textnumero{}', # NUMERO SIGN
- 0x2117: ur'\textcircledP{}', # SOUND RECORDING COYRIGHT
- 0x211e: ur'\textrecipe{}', # PRESCRIPTION TAKE
- 0x2120: ur'\textservicemark{}', # SERVICE MARK
- 0x2122: ur'\texttrademark{}', # TRADE MARK SIGN
- 0x2126: ur'\textohm{}', # OHM SIGN
- 0x2127: ur'\textmho{}', # INVERTED OHM SIGN
- 0x212e: ur'\textestimated{}', # ESTIMATED SYMBOL
- 0x2190: ur'\textleftarrow{}', # LEFTWARDS ARROW
- 0x2191: ur'\textuparrow{}', # UPWARDS ARROW
- 0x2192: ur'\textrightarrow{}', # RIGHTWARDS ARROW
- 0x2193: ur'\textdownarrow{}', # DOWNWARDS ARROW
- 0x2212: ur'\textminus{}', # MINUS SIGN
- 0x2217: ur'\textasteriskcentered{}', # ASTERISK OPERATOR
- 0x221a: ur'\textsurd{}', # SQUARE ROOT
- 0x2422: ur'\textblank{}', # BLANK SYMBOL
- 0x25e6: ur'\textopenbullet{}', # WHITE BULLET
- 0x25ef: ur'\textbigcircle{}', # LARGE CIRCLE
- 0x266a: ur'\textmusicalnote{}', # EIGHTH NOTE
- 0x26ad: ur'\textmarried{}', # MARRIAGE SYMBOL
- 0x26ae: ur'\textdivorced{}', # DIVORCE SYMBOL
- 0x27e8: ur'\textlangle{}', # MATHEMATICAL LEFT ANGLE BRACKET
- 0x27e9: ur'\textrangle{}', # MATHEMATICAL RIGHT ANGLE BRACKET
+ 0x0192: u'\\textflorin{}', # LATIN SMALL LETTER F WITH HOOK
+ 0x02b9: u'\\textasciiacute{}', # MODIFIER LETTER PRIME
+ 0x02ba: u'\\textacutedbl{}', # MODIFIER LETTER DOUBLE PRIME
+ 0x2016: u'\\textbardbl{}', # DOUBLE VERTICAL LINE
+ 0x2022: u'\\textbullet{}', # BULLET
+ 0x2032: u'\\textasciiacute{}', # PRIME
+ 0x2033: u'\\textacutedbl{}', # DOUBLE PRIME
+ 0x2035: u'\\textasciigrave{}', # REVERSED PRIME
+ 0x2036: u'\\textgravedbl{}', # REVERSED DOUBLE PRIME
+ 0x203b: u'\\textreferencemark{}', # REFERENCE MARK
+ 0x203d: u'\\textinterrobang{}', # INTERROBANG
+ 0x2044: u'\\textfractionsolidus{}', # FRACTION SLASH
+ 0x2045: u'\\textlquill{}', # LEFT SQUARE BRACKET WITH QUILL
+ 0x2046: u'\\textrquill{}', # RIGHT SQUARE BRACKET WITH QUILL
+ 0x2052: u'\\textdiscount{}', # COMMERCIAL MINUS SIGN
+ 0x20a1: u'\\textcolonmonetary{}', # COLON SIGN
+ 0x20a3: u'\\textfrenchfranc{}', # FRENCH FRANC SIGN
+ 0x20a4: u'\\textlira{}', # LIRA SIGN
+ 0x20a6: u'\\textnaira{}', # NAIRA SIGN
+ 0x20a9: u'\\textwon{}', # WON SIGN
+ 0x20ab: u'\\textdong{}', # DONG SIGN
+ 0x20ac: u'\\texteuro{}', # EURO SIGN
+ 0x20b1: u'\\textpeso{}', # PESO SIGN
+ 0x20b2: u'\\textguarani{}', # GUARANI SIGN
+ 0x2103: u'\\textcelsius{}', # DEGREE CELSIUS
+ 0x2116: u'\\textnumero{}', # NUMERO SIGN
+ 0x2117: u'\\textcircledP{}', # SOUND RECORDING COYRIGHT
+ 0x211e: u'\\textrecipe{}', # PRESCRIPTION TAKE
+ 0x2120: u'\\textservicemark{}', # SERVICE MARK
+ 0x2122: u'\\texttrademark{}', # TRADE MARK SIGN
+ 0x2126: u'\\textohm{}', # OHM SIGN
+ 0x2127: u'\\textmho{}', # INVERTED OHM SIGN
+ 0x212e: u'\\textestimated{}', # ESTIMATED SYMBOL
+ 0x2190: u'\\textleftarrow{}', # LEFTWARDS ARROW
+ 0x2191: u'\\textuparrow{}', # UPWARDS ARROW
+ 0x2192: u'\\textrightarrow{}', # RIGHTWARDS ARROW
+ 0x2193: u'\\textdownarrow{}', # DOWNWARDS ARROW
+ 0x2212: u'\\textminus{}', # MINUS SIGN
+ 0x2217: u'\\textasteriskcentered{}', # ASTERISK OPERATOR
+ 0x221a: u'\\textsurd{}', # SQUARE ROOT
+ 0x2422: u'\\textblank{}', # BLANK SYMBOL
+ 0x25e6: u'\\textopenbullet{}', # WHITE BULLET
+ 0x25ef: u'\\textbigcircle{}', # LARGE CIRCLE
+ 0x266a: u'\\textmusicalnote{}', # EIGHTH NOTE
+ 0x26ad: u'\\textmarried{}', # MARRIAGE SYMBOL
+ 0x26ae: u'\\textdivorced{}', # DIVORCE SYMBOL
+ 0x27e8: u'\\textlangle{}', # MATHEMATICAL LEFT ANGLE BRACKET
+ 0x27e9: u'\\textrangle{}', # MATHEMATICAL RIGHT ANGLE BRACKET
}
# Unicode chars that require a feature/package to render
pifont = {
- 0x2665: ur'\ding{170}', # black heartsuit
- 0x2666: ur'\ding{169}', # black diamondsuit
- 0x2713: ur'\ding{51}', # check mark
- 0x2717: ur'\ding{55}', # check mark
+ 0x2665: u'\\ding{170}', # black heartsuit
+ 0x2666: u'\\ding{169}', # black diamondsuit
+ 0x2713: u'\\ding{51}', # check mark
+ 0x2717: u'\\ding{55}', # check mark
}
# TODO: greek alphabet ... ?
# see also LaTeX codec
@@ -1511,14 +1511,14 @@
# the backslash doesn't work, so we use a mirrored slash.
# \reflectbox is provided by graphicx:
self.requirements['graphicx'] = self.graphicx_package
- table[ord('\\')] = ur'\reflectbox{/}'
+ table[ord('\\')] = u'\\reflectbox{/}'
# * ``< | >`` come out as different chars (except for cmtt):
else:
- table[ord('|')] = ur'\textbar{}'
- table[ord('<')] = ur'\textless{}'
- table[ord('>')] = ur'\textgreater{}'
+ table[ord('|')] = u'\\textbar{}'
+ table[ord('<')] = u'\\textless{}'
+ table[ord('>')] = u'\\textgreater{}'
if self.insert_non_breaking_blanks:
- table[ord(' ')] = ur'~'
+ table[ord(' ')] = u'~'
# tab chars may occur in included files (literal or code)
# quick-and-dirty replacement with spaces
# (for better results use `--literal-block-env=lstlisting`)
@@ -2618,7 +2618,7 @@
math_code = '\n'.join([math_code] + self.ids_to_labels(node))
if math_env == '$':
if self.alltt:
- wrapper = ur'\(%s\)'
+ wrapper = u'\\(%s\\)'
else:
wrapper = u'$%s$'
else:
@@ -2769,9 +2769,9 @@
def visit_reference(self, node):
# We need to escape #, \, and % if we use the URL in a command.
- special_chars = {ord('#'): ur'\#',
- ord('%'): ur'\%',
- ord('\\'): ur'\\',
+ special_chars = {ord('#'): u'\\#',
+ ord('%'): u'\\%',
+ ord('\\'): u'\\\\',
}
# external reference (URL)
if 'refuri' in node:
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2019-08-27 12:09:01 UTC (rev 8365)
+++ trunk/docutils/docutils/writers/manpage.py 2019-08-27 12:09:19 UTC (rev 8366)
@@ -284,10 +284,10 @@
text = node.astext()
text = text.replace('\\','\\e')
replace_pairs = [
- (u'-', ur'\-'),
- (u'\'', ur'\(aq'),
- (u'´', ur'\''),
- (u'`', ur'\(ga'),
+ (u'-', u'\\-'),
+ (u'\'', u'\\(aq'),
+ (u'´', u"\\'"),
+ (u'`', u'\\(ga'),
]
for (in_char, out_markup) in replace_pairs:
text = text.replace(in_char, out_markup)
Modified: trunk/docutils/test/test_parsers/test_rst/test_east_asian_text.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_east_asian_text.py 2019-08-27 12:09:01 UTC (rev 8365)
+++ trunk/docutils/test/test_parsers/test_rst/test_east_asian_text.py 2019-08-27 12:09:19 UTC (rev 8366)
@@ -50,12 +50,12 @@
タイトル2
========
"""],
-[ur"""
+[u"""
+-----------------------+
| * ヒョウ:ダイ1ギョウ |
| * ダイ2ギョウ |
+-----------------------+
-| \* ダイ1ギョウ |
+| \\* ダイ1ギョウ |
| * ダイ2ギョウ |
+-----------------------+
""",
Modified: trunk/docutils/tools/dev/generate_punctuation_chars.py
===================================================================
--- trunk/docutils/tools/dev/generate_punctuation_chars.py 2019-08-27 12:09:01 UTC (rev 8365)
+++ trunk/docutils/tools/dev/generate_punctuation_chars.py 2019-08-27 12:09:19 UTC (rev 8366)
@@ -375,10 +375,16 @@
print_differences(openers, o, 'openers')
if o_wide:
- print('+ openers-wide = ur"""%s"""' % o_wide.encode('utf8'))
+ if sys.version_info < (3, 0):
+ print('+ openers-wide = ur"""%s"""' % o_wide.encode('utf8'))
+ else:
+ print('+ openers-wide = r"""%s"""' % o_wide.encode('utf8'))
print_differences(closers, c, 'closers')
if c_wide:
- print('+ closers-wide = ur"""%s"""' % c_wide.encode('utf8'))
+ if sys.version_info < (3, 0):
+ print('+ closers-wide = ur"""%s"""' % c_wide.encode('utf8'))
+ else:
+ print('+ closers-wide = r"""%s"""' % c_wide.encode('utf8'))
print_differences(delimiters, d + d_wide, 'delimiters')
print_differences(closing_delimiters, cd, 'closing_delimiters')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2019-08-27 12:10:00
|
Revision: 8367
http://sourceforge.net/p/docutils/code/8367
Author: milde
Date: 2019-08-27 12:09:56 +0000 (Tue, 27 Aug 2019)
Log Message:
-----------
Formatting changes to facilitate integration of "py3" patchset.
Modified Paths:
--------------
trunk/docutils/docutils/_compat.py
trunk/docutils/docutils/core.py
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/directives/__init__.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/error_reporting.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/setup.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/test__init__.py
trunk/docutils/test/test_command_line.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_functional.py
trunk/docutils/test/test_io.py
trunk/docutils/test/test_language.py
trunk/docutils/test/test_nodes.py
trunk/docutils/test/test_parsers/test_parser.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_raw.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_unicode.py
trunk/docutils/tools/dev/create_unimap.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
trunk/docutils/tools/dev/unicode2rstsubs.py
Modified: trunk/docutils/docutils/_compat.py
===================================================================
--- trunk/docutils/docutils/_compat.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/_compat.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -14,7 +14,7 @@
import sys
-if sys.version_info < (3,0):
+if sys.version_info < (3, 0):
u_prefix = 'u'
from StringIO import StringIO as BytesIO
else:
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/core.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -155,7 +155,7 @@
if argv is None:
argv = sys.argv[1:]
# converting to Unicode (Python 3 does this automatically):
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
# TODO: make this failsafe and reversible?
argv_encoding = (frontend.locale_encoding or 'ascii')
argv = [a.decode(argv_encoding) for a in argv]
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/frontend.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -36,7 +36,7 @@
import codecs
import optparse
from optparse import SUPPRESS_HELP
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
from configparser import RawConfigParser
else:
from ConfigParser import RawConfigParser
@@ -47,7 +47,7 @@
from docutils.utils.error_reporting import (locale_encoding, SafeString,
ErrorOutput, ErrorString)
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
@@ -779,7 +779,7 @@
except IOError:
continue
try:
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
RawConfigParser.readfp(self, fp, filename)
else:
RawConfigParser.read_file(self, fp, filename)
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/io.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -17,7 +17,7 @@
from docutils import TransformSpec
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
@@ -208,7 +208,7 @@
def __init__(self, source=None, source_path=None,
encoding=None, error_handler='strict',
autoclose=True,
- mode='r' if sys.version_info >= (3,0) else 'rU', **kwargs):
+ mode='r' if sys.version_info >= (3, 0) else 'rU', **kwargs):
"""
:Parameters:
- `source`: either a file-like object (which is read directly), or
@@ -239,7 +239,7 @@
if source is None:
if source_path:
# Specify encoding in Python 3
- if sys.version_info >= (3,0):
+ if sys.version_info >= (3, 0):
kwargs = {'encoding': self.encoding,
'errors': self.error_handler}
else:
@@ -251,7 +251,7 @@
raise InputError(error.errno, error.strerror, source_path)
else:
self.source = sys.stdin
- elif (sys.version_info >= (3,0) and
+ elif (sys.version_info >= (3, 0) and
check_encoding(self.source, self.encoding) is False):
# TODO: re-open, warn or raise error?
raise UnicodeError('Encoding clash: encoding given is "%s" '
@@ -268,7 +268,7 @@
Read and decode a single file and return the data (Unicode string).
"""
try:
- if self.source is sys.stdin and sys.version_info >= (3,0):
+ if self.source is sys.stdin and sys.version_info >= (3, 0):
# read as binary data to circumvent auto-decoding
data = self.source.buffer.read()
# normalize newlines
@@ -358,7 +358,7 @@
def open(self):
# Specify encoding in Python 3.
- if sys.version_info >= (3,0) and 'b' not in self.mode:
+ if sys.version_info >= (3, 0) and 'b' not in self.mode:
kwargs = {'encoding': self.encoding,
'errors': self.error_handler}
else:
@@ -378,17 +378,17 @@
"""
if not self.opened:
self.open()
- if ('b' not in self.mode and sys.version_info < (3,0)
+ if ('b' not in self.mode and sys.version_info < (3, 0)
or check_encoding(self.destination, self.encoding) is False
):
data = self.encode(data)
- if sys.version_info >= (3,0) and os.linesep != '\n':
+ if sys.version_info >= (3, 0) and os.linesep != '\n':
data = data.replace(b'\n', bytes(os.linesep, 'ascii')) # fix endings
try:
self.destination.write(data)
except TypeError as e:
- if sys.version_info >= (3,0) and isinstance(data, bytes):
+ if sys.version_info >= (3, 0) and isinstance(data, bytes):
try:
self.destination.buffer.write(data)
except AttributeError:
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/nodes.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -29,7 +29,7 @@
import warnings
import unicodedata
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
basestring = str # noqa
@@ -64,7 +64,7 @@
"""
return True
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
# on 2.x, str(node) will be a byte string with Unicode
# characters > 255 escaped; on 3.x this is no longer necessary
def __str__(self):
@@ -304,7 +304,7 @@
except IndexError:
return None
-if sys.version_info < (3,0):
+if sys.version_info < (3, 0):
class reprunicode(unicode):
"""
A unicode sub-class that removes the initial u from unicode's repr.
@@ -320,7 +320,7 @@
"""
Failsave conversion of `unicode` to `str`.
"""
- if sys.version_info < (3,0) and isinstance(s, unicode):
+ if sys.version_info < (3, 0) and isinstance(s, unicode):
return s.encode('ascii', 'backslashreplace')
return s
@@ -352,7 +352,7 @@
children = ()
"""Text nodes have no children, and cannot have children."""
- if sys.version_info > (3,0):
+ if sys.version_info > (3, 0):
def __new__(cls, data, rawsource=None):
"""Prevent the rawsource argument from propagating to str."""
if isinstance(data, bytes):
@@ -544,7 +544,7 @@
else:
return self.emptytag()
- if sys.version_info > (3,0):
+ if sys.version_info > (3, 0):
# 2to3 doesn't convert __unicode__ to __str__
__str__ = __unicode__
Modified: trunk/docutils/docutils/parsers/rst/directives/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/__init__.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/parsers/rst/directives/__init__.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -16,7 +16,7 @@
from docutils.utils import split_escaped_whitespace, escape2null, unescape
from docutils.parsers.rst.languages import en as _fallback_language_module
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unichr = chr # noqa
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -473,7 +473,7 @@
'Invalid context: the "%s" directive can only be used within '
'a substitution definition.' % self.name)
format_str = '\n'.join(self.content) or '%Y-%m-%d'
- if sys.version_info< (3,0):
+ if sys.version_info< (3, 0):
try:
format_str = format_str.encode(locale_encoding or 'utf-8')
except UnicodeEncodeError:
@@ -496,7 +496,7 @@
# time.gmtime(int(source_date_epoch)))
# else:
text = time.strftime(format_str)
- if sys.version_info< (3,0):
+ if sys.version_info< (3, 0):
# `text` is a byte string that may contain non-ASCII characters:
try:
text = text.decode(locale_encoding or 'utf-8')
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -263,7 +263,7 @@
return [detail.args[0]]
except csv.Error as detail:
message = str(detail)
- if sys.version_info < (3,0) and '1-character string' in message:
+ if sys.version_info < (3, 0) and '1-character string' in message:
message += '\nwith Python 2.x this must be an ASCII character.'
error = self.state_machine.reporter.error(
'Error with CSV data in "%s" directive:\n%s'
@@ -356,7 +356,7 @@
raise SystemMessagePropagation(error)
return csv_data, source
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
# 2.x csv module doesn't do Unicode
def decode_from_csv(s):
return s.decode('utf-8')
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/statemachine.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -113,7 +113,7 @@
from docutils import utils
from docutils.utils.error_reporting import ErrorOutput
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -28,7 +28,7 @@
from docutils.transforms import TransformError, Transform
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/transforms/universal.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -24,7 +24,7 @@
from docutils.utils import smartquotes
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/utils/__init__.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -22,7 +22,7 @@
import docutils.io
from docutils.utils.error_reporting import ErrorOutput, SafeString
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str
@@ -592,7 +592,7 @@
return list(itertools.chain(*strings))
def strip_combining_chars(text):
- if isinstance(text, str) and sys.version_info < (3,0):
+ if isinstance(text, str) and sys.version_info < (3, 0):
return text
return u''.join([c for c in text if not unicodedata.combining(c)])
@@ -604,7 +604,7 @@
[3, 6, 9]
"""
- if isinstance(text, str) and sys.version_info < (3,0):
+ if isinstance(text, str) and sys.version_info < (3, 0):
return []
return [i for i,c in enumerate(text) if unicodedata.combining(c)]
@@ -638,7 +638,7 @@
Correct ``len(text)`` for wide East Asian and combining Unicode chars.
"""
- if isinstance(text, str) and sys.version_info < (3,0):
+ if isinstance(text, str) and sys.version_info < (3, 0):
return len(text)
width = sum([east_asian_widths[unicodedata.east_asian_width(c)]
for c in text])
Modified: trunk/docutils/docutils/utils/error_reporting.py
===================================================================
--- trunk/docutils/docutils/utils/error_reporting.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/utils/error_reporting.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -65,7 +65,7 @@
locale_encoding = None
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
@@ -93,7 +93,7 @@
for arg in self.data.args]
return ', '.join(args)
if isinstance(self.data, unicode):
- if sys.version_info > (3,0):
+ if sys.version_info > (3, 0):
return self.data
else:
return self.data.encode(self.encoding,
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/utils/math/math2html.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -30,7 +30,7 @@
import urllib
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str #noqa
basestring = str # noqa
file = io.IOBase # noqa
@@ -73,7 +73,7 @@
def show(cls, message, channel):
"Show a message out of a channel"
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
message = message.encode('utf-8')
channel.write(message + '\n')
@@ -1785,7 +1785,7 @@
"Write a string"
if not self.file:
self.file = codecs.open(self.filename, 'w', "utf-8")
- if self.file == sys.stdout and sys.version_info < (3,0):
+ if self.file == sys.stdout and sys.version_info < (3, 0):
string = string.encode('utf-8')
self.file.write(string)
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/writers/_html_base.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -40,7 +40,7 @@
math2html, latex2mathml, tex2mathml_extern)
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -17,7 +17,7 @@
import docutils
from docutils import frontend, writers, nodes
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
@@ -172,7 +172,7 @@
self.output.append(xml_string)
self.default_departure(node) # or not?
# Check validity of raw XML:
- if isinstance(xml_string, unicode) and sys.version_info < (3,0):
+ if isinstance(xml_string, unicode) and sys.version_info < (3, 0):
xml_string = xml_string.encode('utf8')
try:
self.xmlparser.parse(StringIO(xml_string))
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -28,7 +28,7 @@
from docutils.utils.math import pick_math_environment, unichar2tex
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/writers/manpage.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -47,7 +47,7 @@
import re
import sys
-if sys.version_info < (3,0):
+if sys.version_info < (3, 0):
range = xrange
import docutils
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -33,7 +33,8 @@
from docutils import frontend, nodes, utils, writers, languages
from docutils.readers import standalone
from docutils.transforms import references
-if sys.version_info >= (3,0):
+
+if sys.version_info >= (3, 0):
from configparser import ConfigParser
from io import StringIO
from urllib.request import urlopen
@@ -41,7 +42,8 @@
else:
from ConfigParser import ConfigParser
from StringIO import StringIO
- from urllib2 import urlopen, HTTPError
+ from urllib2 import HTTPError
+ from urllib2 import urlopen
VERSION = '1.0a'
@@ -304,7 +306,7 @@
def ToString(et):
outstream = StringIO()
- if sys.version_info >= (3,0):
+ if sys.version_info >= (3, 0):
et.write(outstream, encoding="unicode")
else:
et.write(outstream)
@@ -902,7 +904,7 @@
self.document.reporter.warning(
'Style "%s" is not a style used by odtwriter.' % (
rststyle, ))
- if sys.version_info >= (3,0):
+ if sys.version_info >= (3, 0):
self.format_map[rststyle] = format
else:
self.format_map[rststyle] = format.decode('utf-8')
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/setup.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -13,7 +13,7 @@
from distutils.core import setup, Command
from distutils.command.build import build
from distutils.command.build_py import build_py
- if sys.version_info >= (3,0):
+ if sys.version_info >= (3, 0):
from distutils.command.build_py import build_py_2to3
from distutils.util import copydir_run_2to3
from distutils.command.install_data import install_data
@@ -27,7 +27,7 @@
sys.exit(1)
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
# copy-convert auxiliary python sources
class copy_build_py_2to3(build_py_2to3):
"""Copy/convert Python source files in given directories recursively.
@@ -97,7 +97,7 @@
kwargs['cmdclass'] = {'build_data': build_data,
'install_data': smart_install_data}
# Auto-convert source code for Python 3
- if sys.version_info >= (3,0):
+ if sys.version_info >= (3, 0):
kwargs['cmdclass']['build_py'] = copy_build_py_2to3
else:
kwargs['cmdclass']['build_py'] = build_py
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/test/DocutilsTestSupport.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -51,7 +51,7 @@
testroot = os.path.abspath(os.path.dirname(__file__) or os.curdir)
os.chdir(testroot)
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
sys.path.insert(0, os.path.normpath(os.path.join(testroot,
'..', 'build', 'lib')))
sys.path.append(os.path.normpath(os.path.join(testroot, '..',
@@ -89,7 +89,7 @@
import pdb
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
@@ -202,7 +202,7 @@
"""`input`, `output`, and `expected` should all be strings."""
if isinstance(input, unicode):
input = input.encode('raw_unicode_escape')
- if sys.version_info > (3,0):
+ if sys.version_info > (3, 0):
# API difference: Python 3's node.__str__ doesn't escape
#assert expected is None or isinstance(expected, unicode)
if isinstance(expected, bytes):
Modified: trunk/docutils/test/test__init__.py
===================================================================
--- trunk/docutils/test/test__init__.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/test/test__init__.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -16,7 +16,7 @@
import docutils.utils
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
Modified: trunk/docutils/test/test_command_line.py
===================================================================
--- trunk/docutils/test/test_command_line.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/test/test_command_line.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -33,7 +33,7 @@
if argv_encoding == 'ascii': # cannot test
return
sys.argv.append('--source-url=test.txt') # pure ASCII argument
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
sys.argv.append(u'--title=Dornröschen'.encode(argv_encoding))
else:
sys.argv.append(u'--title=Dornröschen')
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/test/test_error_reporting.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -26,9 +26,9 @@
"""
from __future__ import print_function
-import unittest
import os
import sys
+import unittest
from io import StringIO, BytesIO
import DocutilsTestSupport # must be imported before docutils
@@ -35,8 +35,9 @@
from docutils import core, parsers, frontend, utils
from docutils.utils.error_reporting import SafeString, ErrorString, ErrorOutput
+
oldlocale = None
-if sys.version_info < (3,0): # problems solved in py3k
+if sys.version_info < (3, 0): # problems solved in py3k
try:
import locale # module missing in Jython
oldlocale = locale.getlocale()
@@ -44,7 +45,7 @@
print('cannot test error reporting with problematic locales,\n'
'`import locale` failed.')
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
Modified: trunk/docutils/test/test_functional.py
===================================================================
--- trunk/docutils/test/test_functional.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/test/test_functional.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -162,7 +162,7 @@
output = docutils.core.publish_file(**params)
# ensure output is unicode
output_encoding = params.get('output_encoding', 'utf-8')
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
try:
output = output.decode(output_encoding)
except UnicodeDecodeError:
@@ -174,7 +174,7 @@
no_expected = self.no_expected_template % {
'exp': expected_path, 'out': params['destination_path']}
self.assertTrue(os.access(expected_path, os.R_OK), no_expected)
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
f = open(expected_path, 'r')
else: # samples are UTF8 encoded. 'rb' leads to errors with Python 3!
f = open(expected_path, 'r', encoding='utf-8')
@@ -181,7 +181,7 @@
# Normalize line endings:
expected = '\n'.join(f.read().splitlines())
f.close()
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
try:
expected = expected.decode(output_encoding)
except UnicodeDecodeError:
@@ -195,7 +195,7 @@
diff = ''.join(difflib.unified_diff(
expected.splitlines(True), output.splitlines(True),
expected_path, params['destination_path']))
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
diff = diff.encode(sys.stderr.encoding or 'ascii', 'replace')
print('\n%s:' % (self,), file=sys.stderr)
print(diff, file=sys.stderr)
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/test/test_io.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -103,7 +103,7 @@
# if no encoding is given, try decoding with utf8:
input = io.FileInput(source_path='functional/input/cyrillic.txt')
data = input.read()
- if sys.version_info < (3,0):
+ if sys.version_info < (3, 0):
# in Py3k, the locale encoding is used without --input-encoding
# skipping the heuristic
self.assertEqual(input.successful_encoding, 'utf-8')
@@ -111,7 +111,7 @@
def test_heuristics_no_utf8(self):
# if no encoding is given and decoding with utf8 fails,
# use either the locale encoding (if specified) or latin-1:
- if sys.version_info >= (3,0) and locale_encoding != "utf8":
+ if sys.version_info >= (3, 0) and locale_encoding != "utf8":
# in Py3k, the locale encoding is used without --input-encoding
# skipping the heuristic unless decoding fails.
return
@@ -172,7 +172,7 @@
self.assertEqual(self.udrain.getvalue(), self.udata)
def test_write_utf8(self):
- if sys.version_info >= (3,0):
+ if sys.version_info >= (3, 0):
fo = io.FileOutput(destination=self.udrain, encoding='utf8',
autoclose=False)
fo.write(self.udata)
@@ -192,7 +192,7 @@
self.assertEqual(self.bdrain.getvalue(), self.bdata)
# Test for Python 3 features:
- if sys.version_info >= (3,0):
+ if sys.version_info >= (3, 0):
def test_write_bytes_to_stdout(self):
# try writing data to `destination.buffer`, if data is
# instance of `bytes` and writing to `destination` fails:
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/test/test_language.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -26,7 +26,7 @@
reference_language = 'en'
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2019-08-27 12:09:19 UTC (rev 8366)
+++ trunk/docutils/test/test_nodes.py 2019-08-27 12:09:56 UTC (rev 8367)
@@ -17,7 +17,7 @@
debug = False
-if sys.version_info >= (3,0):
+if sys.version_info >= (3, 0):
unicode = str # noqa
@@ -36,7 +36,7 @@
self.assertEqual(self.text.shortrepr(),
...
[truncated message content] |
|
From: <mi...@us...> - 2019-08-27 12:10:15
|
Revision: 8368
http://sourceforge.net/p/docutils/code/8368
Author: milde
Date: 2019-08-27 12:10:14 +0000 (Tue, 27 Aug 2019)
Log Message:
-----------
py3: Handle 'StringIO' to 'io' transition.
This isn't so much a rename as a migration, since things don't do the
same thing.
Based on patch by: Stephen Finucane <st...@th...>
Modified Paths:
--------------
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/test/test_utils.py
trunk/docutils/test/test_writers/test_docutils_xml.py
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2019-08-27 12:09:56 UTC (rev 8367)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2019-08-27 12:10:14 UTC (rev 8368)
@@ -12,12 +12,17 @@
import sys
import xml.sax.saxutils
-from StringIO import StringIO
import docutils
from docutils import frontend, writers, nodes
if sys.version_info >= (3, 0):
+ from io import StringIO # noqa
+else:
+ from StringIO import StringIO # noqa
+
+
+if sys.version_info >= (3, 0):
unicode = str # noqa
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2019-08-27 12:09:56 UTC (rev 8367)
+++ trunk/docutils/test/test_utils.py 2019-08-27 12:10:14 UTC (rev 8368)
@@ -9,13 +9,18 @@
Test module for utils/__init__.py.
"""
-from io import StringIO
import os
+import sys
import unittest
from DocutilsTestSupport import docutils, utils, nodes
+if sys.version_info >= (3, 0):
+ from io import StringIO
+else:
+ from StringIO import StringIO
+
class ReporterTests(unittest.TestCase):
stream = StringIO()
Modified: trunk/docutils/test/test_writers/test_docutils_xml.py
===================================================================
--- trunk/docutils/test/test_writers/test_docutils_xml.py 2019-08-27 12:09:56 UTC (rev 8367)
+++ trunk/docutils/test/test_writers/test_docutils_xml.py 2019-08-27 12:10:14 UTC (rev 8368)
@@ -15,12 +15,17 @@
"""
from __future__ import absolute_import
-from StringIO import StringIO
+import sys
from . import DocutilsTestSupport # must be imported before docutils
import docutils
import docutils.core
+if sys.version_info >= (3, 0):
+ from io import StringIO
+else:
+ from StringIO import StringIO
+
# sample strings
# --------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|