|
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)
+ print(comparison, file=sys.stderr)
except AttributeError: # expected or output not a string
# alternative output for non-strings:
- print >>sys.stderr, 'expected: %r' % expected
- print >>sys.stderr, 'output: %r' % output
+ print('expected: %r' % expected, file=sys.stderr)
+ print('output: %r' % output, file=sys.stderr)
raise error
@@ -375,20 +376,20 @@
def test_transforms_verbosely(self):
if self.run_in_debugger:
pdb.set_trace()
- print '\n', self.id
- print '-' * 70
- print self.input
+ print('\n', self.id)
+ print('-' * 70)
+ print(self.input)
settings = self.settings.copy()
settings.__dict__.update(self.suite_settings)
document = utils.new_document('test data', settings)
self.parser.parse(self.input, document)
- print '-' * 70
- print document.pformat()
+ print('-' * 70)
+ print(document.pformat())
for transformClass in self.transforms:
transformClass(document).apply()
output = document.pformat()
- print '-' * 70
- print output
+ print('-' * 70)
+ print(output)
self.compare_output(self.input, output, self.expected)
Modified: trunk/docutils/test/alltests.py
===================================================================
--- trunk/docutils/test/alltests.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/alltests.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -1,12 +1,12 @@
#!/bin/sh
''''exec python -u "$0" "$@" #'''
+from __future__ import print_function
# $Id$
# Author: David Goodger <go...@py...>
# Copyright: This module has been placed in the public domain.
-__doc__ = \
-"""
+__doc__ = """\
All modules named 'test_*.py' in the current directory, and recursively in
subdirectories (packages) called 'test_*', are loaded and test suites within
are run.
@@ -15,7 +15,7 @@
import time
# Start point for actual elapsed time, including imports
# and setup outside of unittest.
-start = time.time()
+start = time.time() # noqa
import sys
import atexit
@@ -66,12 +66,13 @@
if line[-1:] == '[':
indent += step
else:
- if line [-5:] == ']>]>,':
+ if line[-5:] == ']>]>,':
indent -= step * 2
elif line[-3:] == ']>,':
indent -= step
return '\n'.join(output)
+
def suite():
path, script = os.path.split(sys.argv[0])
suite = package_unittest.loadTestModules(DocutilsTestSupport.testroot,
@@ -79,26 +80,25 @@
sys.stdout.flush()
return suite
+
# must redirect stderr *before* first import of unittest
sys.stdout = sys.stderr = Tee('alltests.out')
-import package_unittest
+import package_unittest # noqa
if __name__ == '__main__':
suite = suite()
- print ('Testing Docutils %s with Python %s on %s at %s'
- % (docutils.__version__, sys.version.split()[0],
- time.strftime('%Y-%m-%d'), time.strftime('%H:%M:%S')))
- print ('OS: %s %s %s (%s, %s)'
- % (platform.system(), platform.release(), platform.version(),
- sys.platform, platform.platform()))
- print 'Working directory: %s' % os.getcwd()
- print 'Docutils package: %s' % os.path.dirname(docutils.__file__)
+ print('Testing Docutils %s with Python %s on %s at %s' % (
+ docutils.__version__, sys.version.split()[0],
+ time.strftime('%Y-%m-%d'), time.strftime('%H:%M:%S')))
+ print('OS: %s %s %s (%s, %s)' % (
+ platform.system(), platform.release(), platform.version(),
+ sys.platform, platform.platform()))
+ print('Working directory: %s' % os.getcwd())
+ print('Docutils package: %s' % os.path.dirname(docutils.__file__))
sys.stdout.flush()
result = package_unittest.main(suite)
- #if package_unittest.verbosity > 1:
- # print >>sys.stderr, pformat(suite) # check the test suite
finish = time.time()
- print 'Elapsed time: %.3f seconds' % (finish - start)
+ print('Elapsed time: %.3f seconds' % (finish - start))
sys.exit(not result.wasSuccessful())
Modified: trunk/docutils/test/package_unittest.py
===================================================================
--- trunk/docutils/test/package_unittest.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/package_unittest.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -9,6 +9,7 @@
test modules from a directory. Optionally, test packages are also loaded,
recursively.
"""
+from __future__ import print_function
import sys
import os
@@ -37,8 +38,8 @@
def usageExit(msg=None):
"""Print usage and exit."""
if msg:
- print msg
- print USAGE
+ print(msg)
+ print(USAGE)
sys.exit(2)
def parseArgs(argv=sys.argv):
@@ -96,11 +97,11 @@
sys.path.insert(0, path)
for mod in testModules:
if debug:
- print >>sys.stderr, "importing %s" % mod
+ print("importing %s" % mod, file=sys.stderr)
try:
module = import_module(mod)
except ImportError:
- print >>sys.stderr, "ERROR: Can't import %s, skipping its tests:" % mod
+ print("ERROR: Can't import %s, skipping its tests:" % mod, file=sys.stderr)
sys.excepthook(*sys.exc_info())
else:
# if there's a suite defined, incorporate its contents
@@ -148,7 +149,7 @@
suite = unittest.defaultTestLoader.loadTestsFromModule(
__import__('__main__'))
if debug:
- print >>sys.stderr, "Debug: Suite=%s" % suite
+ 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([]):
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_error_reporting.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -20,13 +20,15 @@
try:
something
except IOError, error:
- print 'Found %s' % error
+ print('Found %s' % error)
unless the minimal required Python version has this problem fixed.
"""
+from __future__ import print_function
import unittest
-import sys, os
+import os
+import sys
from io import StringIO, BytesIO
import DocutilsTestSupport # must be imported before docutils
@@ -39,8 +41,8 @@
import locale # module missing in Jython
oldlocale = locale.getlocale()
except ImportError:
- print ('cannot test error reporting with problematic locales,\n'
- '`import locale` failed.')
+ print('cannot test error reporting with problematic locales,\n'
+ '`import locale` failed.')
# locales confirmed to use non-ASCII chars in the IOError message
Modified: trunk/docutils/test/test_functional.py
===================================================================
--- trunk/docutils/test/test_functional.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_functional.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -9,6 +9,7 @@
Read README.txt for details on how this is done.
"""
+from __future__ import print_function
import sys
import os
@@ -196,8 +197,8 @@
expected_path, params['destination_path']))
if sys.version_info < (3,0):
diff = diff.encode(sys.stderr.encoding or 'ascii', 'replace')
- print >>sys.stderr, '\n%s:' % (self,)
- print >>sys.stderr, diff
+ print('\n%s:' % (self,), file=sys.stderr)
+ print(diff, file=sys.stderr)
raise
# Execute optional function containing extra tests:
if '_test_more' in namespace:
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_io.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -69,7 +69,7 @@
input = io.StringInput(source=b"""\
#! python
# -*- coding: ascii -*-
-print "hello world"
+print("hello world")
""")
data = input.read()
self.assertEqual(input.successful_encoding, 'ascii')
@@ -77,7 +77,7 @@
#! python
# extraneous comment; prevents coding slug from being read
# -*- coding: ascii -*-
-print "hello world"
+print("hello world")
""")
data = input.read()
self.assertNotEqual(input.successful_encoding, 'ascii')
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 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -98,7 +98,7 @@
.. code:: python
:class: testclass
- print 'hello world' # to stdout
+ print('hello world') # to stdout
""",
"""\
<document source="test data">
@@ -106,9 +106,12 @@
\n\
<inline classes="keyword">
print
- \n\
+ <inline classes="punctuation">
+ (
<inline classes="literal string single">
'hello world'
+ <inline classes="punctuation">
+ )
\n\
<inline classes="comment single">
# to stdout
@@ -124,7 +127,7 @@
'''
# and now for something completely different
- print 8/2
+ print(8/2)
""",
"""\
<document source="test data">
@@ -163,7 +166,8 @@
\n\
<inline classes="keyword">
print
- \n\
+ <inline classes="punctuation">
+ (
<inline classes="literal number integer">
8
<inline classes="operator">
@@ -170,6 +174,8 @@
/
<inline classes="literal number integer">
2
+ <inline classes="punctuation">
+ )
"""],
["""\
.. code:: latex
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 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -29,7 +29,7 @@
'''
# and now for something completely different
- print 8/2
+ print(8/2)
""",
"""\
<document source="test data">
@@ -68,7 +68,8 @@
\n\
<inline classes="keyword">
print
- \n\
+ <inline classes="punctuation">
+ (
<inline classes="literal number integer">
8
<inline classes="operator">
@@ -75,6 +76,8 @@
/
<inline classes="literal number integer">
2
+ <inline classes="punctuation">
+ )
"""],
["""\
.. code:: latex
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 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -37,7 +37,7 @@
'''
# and now for something completely different
- print 8/2
+ print(8/2)
""",
"""\
<document source="test data">
@@ -59,7 +59,7 @@
# and now for something completely different
<inline classes="ln">
12 \n\
- print 8/2
+ print(8/2)
"""],
["""\
.. code:: latex
Modified: trunk/docutils/test/test_parsers/test_rst/test_doctest_blocks.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_doctest_blocks.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_parsers/test_rst/test_doctest_blocks.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -21,7 +21,7 @@
["""\
Paragraph.
->>> print "Doctest block."
+>>> print("Doctest block.")
Doctest block.
Paragraph.
@@ -31,7 +31,7 @@
<paragraph>
Paragraph.
<doctest_block xml:space="preserve">
- >>> print "Doctest block."
+ >>> print("Doctest block.")
Doctest block.
<paragraph>
Paragraph.
@@ -39,7 +39,7 @@
["""\
Paragraph.
->>> print " Indented output."
+>>> print(" Indented output.")
Indented output.
""",
"""\
@@ -47,13 +47,13 @@
<paragraph>
Paragraph.
<doctest_block xml:space="preserve">
- >>> print " Indented output."
+ >>> print(" Indented output.")
Indented output.
"""],
["""\
Paragraph.
- >>> print " Indented block & output."
+ >>> print(" Indented block & output.")
Indented block & output.
""",
"""\
@@ -62,7 +62,7 @@
Paragraph.
<block_quote>
<doctest_block xml:space="preserve">
- >>> print " Indented block & output."
+ >>> print(" Indented block & output.")
Indented block & output.
"""],
]
Modified: trunk/docutils/test/test_settings.py
===================================================================
--- trunk/docutils/test/test_settings.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_settings.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -8,6 +8,7 @@
"""
Tests of runtime settings.
"""
+from __future__ import print_function
import sys
import os
@@ -111,10 +112,10 @@
try:
self.assertEqual(result, expected)
except AssertionError:
- print >>sys.stderr, '\n%s\n' % (self,)
- print >>sys.stderr, '-: expected\n+: result'
- print >>sys.stderr, ''.join(self.compare(expected.splitlines(1),
- result.splitlines(1)))
+ print('\n%s\n' % (self,), file=sys.stderr)
+ print('-: expected\n+: result', file=sys.stderr)
+ print(''.join(self.compare(expected.splitlines(1),
+ result.splitlines(1))), file=sys.stderr)
raise
def test_nofiles(self):
Modified: trunk/docutils/test/test_statemachine.py
===================================================================
--- trunk/docutils/test/test_statemachine.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_statemachine.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -7,6 +7,7 @@
"""
Test module for statemachine.py.
"""
+from __future__ import print_function
import unittest
import sys
@@ -56,47 +57,47 @@
def bof(self, context):
self.levelholder[0] += 1
self.level = self.levelholder[0]
- if self.debug: print >>sys.stderr, 'StateMachine%s' % self.level
+ if self.debug: print('StateMachine%s' % self.level, file=sys.stderr)
return [], ['StateMachine%s' % self.level]
def blank(self, match, context, next_state):
result = ['blank%s' % self.level]
- if self.debug: print >>sys.stderr, 'blank%s' % self.level
+ if self.debug: print('blank%s' % self.level, file=sys.stderr)
if context and context[-1] and context[-1][-2:] == '::':
result.extend(self.literalblock())
return [], None, result
def indent(self, match, context, next_state):
- if self.debug: print >>sys.stderr, 'indent%s' % self.level
+ if self.debug: print('indent%s' % self.level, file=sys.stderr)
context, next_state, result = statemachine.StateWS.indent(
self, match, context, next_state)
return context, next_state, ['indent%s' % self.level] + result
def known_indent(self, match, context, next_state):
- if self.debug: print >>sys.stderr, 'known_indent%s' % self.level
+ if self.debug: print('known_indent%s' % self.level, file=sys.stderr)
context, next_state, result = statemachine.StateWS.known_indent(
self, match, context, next_state)
return context, next_state, ['known_indent%s' % self.level] + result
def bullet(self, match, context, next_state):
- if self.debug: print >>sys.stderr, 'bullet%s' % self.level
+ if self.debug: print('bullet%s' % self.level, file=sys.stderr)
context, next_state, result \
= self.known_indent(match, context, next_state)
return [], next_state, ['bullet%s' % self.level] + result
def text(self, match, context, next_state):
- if self.debug: print >>sys.stderr, 'text%s' % self.level
+ if self.debug: print('text%s' % self.level, file=sys.stderr)
return [match.string], next_state, ['text%s' % self.level]
def literalblock(self):
indented, indent, offset, good = self.state_machine.get_indented()
- if self.debug: print >>sys.stderr, 'literalblock%s(%s)' % (self.level,
- indent)
+ if self.debug: print('literalblock%s(%s)' % (self.level,
+ indent), file=sys.stderr)
return ['literalblock%s(%s)' % (self.level, indent)]
def eof(self, context):
self.levelholder[0] -= 1
- if self.debug: print >>sys.stderr, 'finished%s' % self.level
+ if self.debug: print('finished%s' % self.level, file=sys.stderr)
return ['finished%s' % self.level]
@@ -169,10 +170,10 @@
self.assertTrue(good)
self.sm.previous_line(3)
if self.sm.debug:
- print '\ntest_get_indented: self.sm.line:\n', self.sm.line
+ print('\ntest_get_indented: self.sm.line:\n', self.sm.line)
indented, indent, offset, good = self.sm.get_indented()
if self.sm.debug:
- print '\ntest_get_indented: indented:\n', indented
+ print('\ntest_get_indented: indented:\n', indented)
self.assertEqual(indent, lbindent)
self.assertEqual(indented, literalblock)
self.assertEqual(offset, (len(para1) + len(item1) + len(item2)
Modified: trunk/docutils/test/test_transforms/test_smartquotes.py
===================================================================
--- trunk/docutils/test/test_transforms/test_smartquotes.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_transforms/test_smartquotes.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -18,7 +18,7 @@
"""
-from __init__ import DocutilsTestSupport # must be imported before docutils
+from __init__ import DocutilsTestSupport # must be imported before docutils
from docutils.transforms.universal import SmartQuotes
from docutils.parsers.rst import Parser
@@ -72,13 +72,13 @@
.. role:: python(code)
:class: python
-Keep quotes straight in code and math:
+Keep quotes straight in code and math:
:code:`print "hello"` :python:`print("hello")` :math:`1' 12"`.
.. code::
- print "hello"
-
+ print("hello")
+
.. math::
f'(x) = df(x)/dx
@@ -105,7 +105,7 @@
1' 12"
.
<literal_block classes="code" xml:space="preserve">
- print "hello"
+ print("hello")
<math_block xml:space="preserve">
f'(x) = df(x)/dx
"""],
Modified: trunk/docutils/test/test_transforms/test_strip_elements_with_class.py
===================================================================
--- trunk/docutils/test/test_transforms/test_strip_elements_with_class.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_transforms/test_strip_elements_with_class.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -37,7 +37,7 @@
.. code::
:class: spam
- print "spam"
+ print("spam")
.. image:: spam.jpg
:class: spam
Modified: trunk/docutils/test/test_viewlist.py
===================================================================
--- trunk/docutils/test/test_viewlist.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/test/test_viewlist.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -9,8 +9,6 @@
"""
import unittest
-import sys
-import re
from DocutilsTestSupport import statemachine
@@ -76,7 +74,6 @@
self.assertEqual(a, a_list)
self.assertEqual(a.items, [('a', i+1) for (i, v) in enumerate(a_list)])
self.assertEqual(a.parent, self.a)
- # a.pprint()
def test_set_slice(self):
a = statemachine.ViewList(self.a[:])
@@ -84,8 +81,6 @@
s[2:2] = self.b
s_list = self.a_list[2:-2]
s_list[2:2] = self.b_list
- # s.pprint()
- # s[1:4].pprint()
self.assertEqual(s, s_list)
self.assertEqual(s, a[2:-2])
self.assertEqual(s.items, a[2:-2].items)
@@ -119,7 +114,6 @@
a = statemachine.ViewList(self.a)
a.append('Q', 'runtime')
a.append(self.b)
- # a.pprint()
self.assertEqual(a, a_list)
self.assertEqual(a.info(len(self.a)), ('runtime', 0))
self.assertEqual(a.info(-2), ('b', len(self.b) - 2))
@@ -131,7 +125,6 @@
a.extend(self.b)
self.assertEqual(a, a_list)
self.assertEqual(a.info(len(self.a) + 1), ('b', 1))
- # a.pprint()
def test_view(self):
a = statemachine.ViewList(self.a[:])
@@ -176,17 +169,10 @@
def test_sort(self):
c = self.c[:]
c.reverse()
- # c.pprint()
c.sort()
self.assertEqual(self.c, c)
-# print
-# print a
-# print s
-# print a.items
-# print s.items
-
class StringList(unittest.TestCase):
text = """\
Modified: trunk/docutils/tools/dev/create_unimap.py
===================================================================
--- trunk/docutils/tools/dev/create_unimap.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/tools/dev/create_unimap.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -9,6 +9,7 @@
# Get unicode.xml from
# <http://www.w3.org/2003/entities/xml/unicode.xml>.
+from __future__ import print_function
from xml.dom import minidom
import sys
import pprint
Modified: trunk/docutils/tools/dev/generate_punctuation_chars.py
===================================================================
--- trunk/docutils/tools/dev/generate_punctuation_chars.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/tools/dev/generate_punctuation_chars.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -33,14 +33,13 @@
# .. _inline markup recognition rules:
# ../../docs/ref/rst/restructuredtext.html#inline-markup
+from __future__ import print_function
-# Setup::
-
-import sys, re
+import sys
import unicodedata
if sys.version_info >= (3,):
- unichr = chr # unichr not available in Py3k
+ unichr = chr # unichr not available in Py3k
else:
import codecs
sys.stdout = codecs.getwriter('UTF-8')(sys.stdout)
@@ -421,44 +420,3 @@
}
print(module_template % substitutions)
-
-
-# test prints
-# ~~~~~~~~~~~
-#
-# For interactive use in development you may uncomment the following
-# definitions::
-
- # print "wide" Unicode characters:
- # ucharlists = unicode_charlists(unicode_punctuation_categories)
- # for key in ucharlists:
- # if key.endswith('wide'):
- # print key, ucharlists[key]
-
- # print 'openers = ', repr(openers)
- # print 'closers = ', repr(closers)
- # print 'delimiters = ', repr(delimiters)
- # print 'closing_delimiters = ', repr(closing_delimiters)
-
- # ucharlists = unicode_charlists(unicode_punctuation_categories)
- # for cat, chars in ucharlists.items():
- # # print cat, chars
- # # compact output (visible with a comprehensive font):
- # print (u":%s: %s" % (cat, u''.join(chars))).encode('utf8')
-
-# verbose print
-#
-# ::
-
- # print 'openers:'
- # for ch in openers:
- # print ch.encode('utf8'), unicodedata.name(ch)
- # print 'closers:'
- # for ch in closers:
- # print ch.encode('utf8'), unicodedata.name(ch)
- # print 'delimiters:'
- # for ch in delimiters:
- # print ch.encode('utf8'), unicodedata.name(ch)
- # print 'closing_delimiters:'
- # for ch in closing_delimiters:
- # print ch.encode('utf8'), unicodedata.name(ch)
Modified: trunk/docutils/tools/dev/profile_docutils.py
===================================================================
--- trunk/docutils/tools/dev/profile_docutils.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/tools/dev/profile_docutils.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -4,6 +4,7 @@
# Author: Lea Wiemann <LeW...@gm...>
# Copyright: This script has been placed in the public domain.
+from __future__ import print_function
import os.path
import docutils.core
import hotshot.stats
Modified: trunk/docutils/tools/dev/unicode2rstsubs.py
===================================================================
--- trunk/docutils/tools/dev/unicode2rstsubs.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/tools/dev/unicode2rstsubs.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -19,6 +19,7 @@
Recommentation XML source, and is available from
<http://www.w3.org/2003/entities/xml/>.
"""
+from __future__ import print_function
import sys
import os
Modified: trunk/docutils/tools/quicktest.py
===================================================================
--- trunk/docutils/tools/quicktest.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/tools/quicktest.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -5,6 +5,7 @@
# David Goodger <go...@py...>
# Copyright: This module has been placed in the public domain.
+from __future__ import print_function
try:
import locale
locale.setlocale(locale.LC_ALL, '')
Modified: trunk/docutils/tools/rst2odt_prepstyles.py
===================================================================
--- trunk/docutils/tools/rst2odt_prepstyles.py 2019-08-26 12:10:59 UTC (rev 8345)
+++ trunk/docutils/tools/rst2odt_prepstyles.py 2019-08-26 12:11:32 UTC (rev 8346)
@@ -9,9 +9,10 @@
specifications from styles.xml in STYLE_FILE.odt.
"""
-#
# Author: Michael Schutte <mi...@ui...>
+from __future__ import print_function
+
from lxml import etree
import sys
import zipfile
@@ -24,28 +25,29 @@
"fo": "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0"
}
+
def prepstyle(filename):
-
+
zin = zipfile.ZipFile(filename)
styles = zin.read("styles.xml")
-
+
root = etree.fromstring(styles)
- for el in root.xpath("//style:page-layout-properties",
- namespaces=NAMESPACES):
+ for el in root.xpath("//style:page-layout-properties",
+ namespaces=NAMESPACES):
for attr in el.attrib:
if attr.startswith("{%s}" % NAMESPACES["fo"]):
del el.attrib[attr]
-
+
tempname = mkstemp()
zout = zipfile.ZipFile(os.fdopen(tempname[0], "w"), "w",
- zipfile.ZIP_DEFLATED)
-
+ zipfile.ZIP_DEFLATED)
+
for item in zin.infolist():
if item.filename == "styles.xml":
zout.writestr(item, etree.tostring(root))
else:
zout.writestr(item, zin.read(item.filename))
-
+
zout.close()
zin.close()
shutil.move(tempname[1], filename)
@@ -54,14 +56,12 @@
def main():
args = sys.argv[1:]
if len(args) != 1:
- print >> sys.stderr, __doc__
- print >> sys.stderr, "Usage: %s STYLE_FILE.odt\n" % sys.argv[0]
+ print(__doc__, file=sys.stderr)
+ print("Usage: %s STYLE_FILE.odt\n" % sys.argv[0], file=sys.stderr)
sys.exit(1)
filename = args[0]
prepstyle(filename)
+
if __name__ == '__main__':
main()
-
-
-# vim:tw=78:sw=4:sts=4:et:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|