|
From: <mi...@us...> - 2022-01-26 19:02:31
|
Revision: 8969
http://sourceforge.net/p/docutils/code/8969
Author: milde
Date: 2022-01-26 19:02:28 +0000 (Wed, 26 Jan 2022)
Log Message:
-----------
Code modernisation. Use literals.
Merger of 2 patches by Adam Turner.
Modified Paths:
--------------
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/xetex/__init__.py
trunk/docutils/test/local-parser.py
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2022-01-26 19:02:15 UTC (rev 8968)
+++ trunk/docutils/docutils/transforms/universal.py 2022-01-26 19:02:28 UTC (rev 8969)
@@ -198,8 +198,8 @@
def apply(self):
if self.document.settings.strip_elements_with_classes:
- self.strip_elements = set(
- self.document.settings.strip_elements_with_classes)
+ self.strip_elements = {*self.document.settings
+ .strip_elements_with_classes}
# Iterate over a tuple as removing the current node
# corrupts the iterator returned by `iter`:
for node in tuple(self.document.findall(self.check_classes)):
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2022-01-26 19:02:15 UTC (rev 8968)
+++ trunk/docutils/docutils/utils/math/math2html.py 2022-01-26 19:02:28 UTC (rev 8969)
@@ -625,7 +625,7 @@
simplemath = False
showlines = True
- branches = dict()
+ branches = {}
def parseoptions(self, args):
"Parse command line options"
@@ -734,7 +734,7 @@
def __init__(self):
self.begin = 0
- self.parameters = dict()
+ self.parameters = {}
def parseheader(self, reader):
"Parse the header"
@@ -2042,7 +2042,7 @@
def __init__(self):
"Initialize the map of instances."
- self.instances = dict()
+ self.instances = {}
def detecttype(self, type, pos):
"Detect a bit of a given type."
@@ -2933,7 +2933,7 @@
def readparams(self, readtemplate, pos):
"Read the params according to the template."
- self.params = dict()
+ self.params = {}
for paramdef in self.paramdefs(readtemplate):
paramdef.read(pos, self)
self.params['$' + paramdef.name] = paramdef
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-01-26 19:02:15 UTC (rev 8968)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-01-26 19:02:28 UTC (rev 8969)
@@ -155,7 +155,7 @@
# <figcaption> is closed in depart_figure(), as legend may follow.
# use HTML block-level tags if matching class value found
- supported_block_tags = set(('ins', 'del'))
+ supported_block_tags = {'ins', 'del'}
def visit_container(self, node):
# If there is exactly one of the "supported block tags" in
# the list of class values, use it as tag name:
@@ -301,9 +301,9 @@
pass
# use HTML text-level tags if matching class value found
- supported_inline_tags = set(('code', 'kbd', 'dfn', 'samp', 'var',
- 'bdi', 'del', 'ins', 'mark', 'small',
- 'b', 'i', 'q', 's', 'u'))
+ supported_inline_tags = {'code', 'kbd', 'dfn', 'samp', 'var',
+ 'bdi', 'del', 'ins', 'mark', 'small',
+ 'b', 'i', 'q', 's', 'u'}
def visit_inline(self, node):
# Use `supported_inline_tags` if found in class values
classes = node['classes']
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-01-26 19:02:15 UTC (rev 8968)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-01-26 19:02:28 UTC (rev 8969)
@@ -388,7 +388,7 @@
# zh-Latn: Chinese Pinyin
}
# normalize (downcase) keys
- language_codes = dict([(k.lower(), v) for (k, v) in language_codes.items()])
+ language_codes = {k.lower(): v for k, v in language_codes.items()}
warn_msg = 'Language "%s" not supported by LaTeX (babel)'
Modified: trunk/docutils/docutils/writers/xetex/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/xetex/__init__.py 2022-01-26 19:02:15 UTC (rev 8968)
+++ trunk/docutils/docutils/writers/xetex/__init__.py 2022-01-26 19:02:28 UTC (rev 8969)
@@ -96,7 +96,7 @@
# zh-Latn: ??? # Chinese Pinyin
})
# normalize (downcase) keys
- language_codes = dict([(k.lower(), v) for (k, v) in language_codes.items()])
+ language_codes = {k.lower(): v for k, v in language_codes.items()}
# Languages without Polyglossia support:
for key in ('af', # 'afrikaans',
Modified: trunk/docutils/test/local-parser.py
===================================================================
--- trunk/docutils/test/local-parser.py 2022-01-26 19:02:15 UTC (rev 8968)
+++ trunk/docutils/test/local-parser.py 2022-01-26 19:02:28 UTC (rev 8969)
@@ -16,5 +16,4 @@
def parser(self, inputstring, document):
self.setup_parse(inputstring, document)
- document = dict()
self.finish_parse()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|