6b24f153d7
All of those patches are picked from upstream. xbps-src check python3-docutils works fine now!
236 lines
9.6 KiB
Diff
236 lines
9.6 KiB
Diff
From 46d71ef146d5fe74b0186693f91a5f47585b1d79 Mon Sep 17 00:00:00 2001
|
|
From: Stephen Finucane <stephen@that.guru>
|
|
Date: Mon, 26 Aug 2019 16:44:51 +0000
|
|
Subject: [PATCH 10/26] py3: Use 'sorted(foo)' instead of 'foo.sort()'
|
|
|
|
This works with iterators also (like 'dict.keys()' in Python 3)
|
|
|
|
Signed-off-by: Stephen Finucane <stephen@that.guru>
|
|
|
|
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@8357 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
|
|
Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com>
|
|
---
|
|
docutils/nodes.py | 6 ++----
|
|
docutils/parsers/rst/tableparser.py | 3 +--
|
|
docutils/transforms/__init__.py | 3 +--
|
|
docutils/utils/math/math2html.py | 3 +--
|
|
docutils/writers/_html_base.py | 3 +--
|
|
docutils/writers/latex2e/__init__.py | 3 +--
|
|
test/DocutilsTestSupport.py | 3 +--
|
|
test/test_dependencies.py | 9 +++------
|
|
test/test_language.py | 6 ++----
|
|
tools/dev/generate_punctuation_chars.py | 3 +--
|
|
tools/dev/unicode2rstsubs.py | 6 ++----
|
|
11 files changed, 16 insertions(+), 32 deletions(-)
|
|
|
|
diff --git a/docutils/nodes.py b/docutils/nodes.py
|
|
index a8c0478..e29b887 100644
|
|
--- a/docutils/nodes.py
|
|
+++ b/docutils/nodes.py
|
|
@@ -649,8 +649,7 @@ class Element(Node):
|
|
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 @@ class pending(Special, Invisible, Element):
|
|
' .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))
|
|
diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py
|
|
index 2760ea0..937aec8 100644
|
|
--- a/docutils/parsers/rst/tableparser.py
|
|
+++ b/docutils/parsers/rst/tableparser.py
|
|
@@ -286,8 +286,7 @@ class GridTableParser(TableParser):
|
|
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
|
|
diff --git a/docutils/transforms/__init__.py b/docutils/transforms/__init__.py
|
|
index 9271133..d444fce 100644
|
|
--- a/docutils/transforms/__init__.py
|
|
+++ b/docutils/transforms/__init__.py
|
|
@@ -153,8 +153,7 @@ class Transformer(TransformSpec):
|
|
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):
|
|
diff --git a/docutils/utils/math/math2html.py b/docutils/utils/math/math2html.py
|
|
index 4a7209d..adcb1cc 100644
|
|
--- a/docutils/utils/math/math2html.py
|
|
+++ b/docutils/utils/math/math2html.py
|
|
@@ -2193,9 +2193,8 @@ class Container(object):
|
|
|
|
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])
|
|
diff --git a/docutils/writers/_html_base.py b/docutils/writers/_html_base.py
|
|
index a7f3b53..a957311 100644
|
|
--- a/docutils/writers/_html_base.py
|
|
+++ b/docutils/writers/_html_base.py
|
|
@@ -366,8 +366,7 @@ class HTMLTranslator(nodes.NodeVisitor):
|
|
# 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
|
|
diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py
|
|
index e21c74b..249ec4a 100644
|
|
--- a/docutils/writers/latex2e/__init__.py
|
|
+++ b/docutils/writers/latex2e/__init__.py
|
|
@@ -457,8 +457,7 @@ class SortableDict(dict):
|
|
"""
|
|
def sortedkeys(self):
|
|
"""Return sorted list of keys"""
|
|
- keys = self.keys()
|
|
- keys.sort()
|
|
+ keys = sorted(self.keys())
|
|
return keys
|
|
|
|
def sortedvalues(self):
|
|
diff --git a/test/DocutilsTestSupport.py b/test/DocutilsTestSupport.py
|
|
index a1fec25..21ea982 100644
|
|
--- a/test/DocutilsTestSupport.py
|
|
+++ b/test/DocutilsTestSupport.py
|
|
@@ -815,8 +815,7 @@ class HtmlWriterPublishPartsTestCase(WriterPublishTestCase):
|
|
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'''"
|
|
diff --git a/test/test_dependencies.py b/test/test_dependencies.py
|
|
index 298e8a4..0939b6d 100755
|
|
--- a/test/test_dependencies.py
|
|
+++ b/test/test_dependencies.py
|
|
@@ -54,9 +54,8 @@ class RecordDependenciesTests(unittest.TestCase):
|
|
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 @@ class RecordDependenciesTests(unittest.TestCase):
|
|
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 @@ class RecordDependenciesTests(unittest.TestCase):
|
|
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)
|
|
|
|
diff --git a/test/test_language.py b/test/test_language.py
|
|
index 30af81a..31ac613 100755
|
|
--- a/test/test_language.py
|
|
+++ b/test/test_language.py
|
|
@@ -150,8 +150,7 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase):
|
|
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 @@ class LanguageTestCase(DocutilsTestSupport.CustomTestCase):
|
|
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:
|
|
diff --git a/tools/dev/generate_punctuation_chars.py b/tools/dev/generate_punctuation_chars.py
|
|
index a30c5ca..b718f78 100644
|
|
--- a/tools/dev/generate_punctuation_chars.py
|
|
+++ b/tools/dev/generate_punctuation_chars.py
|
|
@@ -269,8 +269,7 @@ def mark_intervals(s):
|
|
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:
|
|
diff --git a/tools/dev/unicode2rstsubs.py b/tools/dev/unicode2rstsubs.py
|
|
index b51eec4..ac38bf4 100755
|
|
--- a/tools/dev/unicode2rstsubs.py
|
|
+++ b/tools/dev/unicode2rstsubs.py
|
|
@@ -163,8 +163,7 @@ class CharacterEntitySetExtractor(object):
|
|
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 @@ class CharacterEntitySetExtractor(object):
|
|
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))
|
|
--
|
|
2.24.0.375.geb5ae68d41
|
|
|