From c35ae8993ec86dae49607536e0a7b5424a7ceeb4 Mon Sep 17 00:00:00 2001
From: milde
Date: Thu, 19 Jan 2012 22:33:02 +0000
Subject: [PATCH] Cleanup: Use True/False for boolean values
git-svn-id: https://docutils.svn.sourceforge.net/svnroot/docutils/trunk/docutils@7320 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
---
docutils/core.py | 18 +++++-----
docutils/examples.py | 5 +--
docutils/nodes.py | 41 ++++++++++-----------
docutils/parsers/rst/__init__.py | 16 ++++-----
docutils/parsers/rst/directives/html.py | 2 +-
docutils/parsers/rst/directives/misc.py | 14 ++++----
docutils/parsers/rst/states.py | 56 ++++++++++++++---------------
docutils/parsers/rst/tableparser.py | 2 +-
docutils/readers/pep.py | 2 +-
docutils/statemachine.py | 39 ++++++++++----------
docutils/transforms/references.py | 9 +++--
docutils/transforms/writer_aux.py | 4 +--
docutils/utils/__init__.py | 8 ++---
docutils/writers/html4css1/__init__.py | 55 ++++++++++++++--------------
docutils/writers/latex2e/__init__.py | 15 ++++----
docutils/writers/pseudoxml.py | 2 +-
docutils/writers/s5_html/__init__.py | 4 +--
test/DocutilsTestSupport.py | 36 +++++++++----------
test/functional/tests/_default.py | 2 +-
test/functional/tests/dangerous.py | 4 +--
test/functional/tests/field_name_limit.py | 2 +-
test/functional/tests/misc_rst_html4css1.py | 2 +-
test/package_unittest.py | 2 +-
test/test_nodes.py | 20 +++++------
test/test_statemachine.py | 2 +-
test/test_writers/test_html4css1_misc.py | 9 ++---
26 files changed, 185 insertions(+), 186 deletions(-)
diff --git a/docutils/core.py b/docutils/core.py
index cf856549a..48ef1a347 100644
--- a/docutils/core.py
+++ b/docutils/core.py
@@ -111,7 +111,7 @@ class Publisher:
#@@@ Add self.source & self.destination to components in future?
option_parser = OptionParser(
components=(self.parser, self.reader, self.writer, settings_spec),
- defaults=defaults, read_config_files=1,
+ defaults=defaults, read_config_files=True,
usage=usage, description=description)
return option_parser
@@ -193,7 +193,7 @@ class Publisher:
def publish(self, argv=None, usage=None, description=None,
settings_spec=None, settings_overrides=None,
- config_section=None, enable_exit_status=None):
+ config_section=None, enable_exit_status=False):
"""
Process command line options and arguments (if `self.settings` not
already set), run `self.reader` and then `self.writer`. Return
@@ -316,7 +316,7 @@ def publish_cmdline(reader=None, reader_name='standalone',
writer=None, writer_name='pseudoxml',
settings=None, settings_spec=None,
settings_overrides=None, config_section=None,
- enable_exit_status=1, argv=None,
+ enable_exit_status=True, argv=None,
usage=default_usage, description=default_description):
"""
Set up & run a `Publisher` for command-line-based file I/O (input and
@@ -344,7 +344,7 @@ def publish_file(source=None, source_path=None,
parser=None, parser_name='restructuredtext',
writer=None, writer_name='pseudoxml',
settings=None, settings_spec=None, settings_overrides=None,
- config_section=None, enable_exit_status=None):
+ config_section=None, enable_exit_status=False):
"""
Set up & run a `Publisher` for programmatic use with file-like I/O.
Return the encoded string output also.
@@ -370,7 +370,7 @@ def publish_string(source, source_path=None, destination_path=None,
writer=None, writer_name='pseudoxml',
settings=None, settings_spec=None,
settings_overrides=None, config_section=None,
- enable_exit_status=None):
+ enable_exit_status=False):
"""
Set up & run a `Publisher` for programmatic use with string I/O. Return
the encoded string or Unicode string output.
@@ -407,7 +407,7 @@ def publish_parts(source, source_path=None, source_class=io.StringInput,
writer=None, writer_name='pseudoxml',
settings=None, settings_spec=None,
settings_overrides=None, config_section=None,
- enable_exit_status=None):
+ enable_exit_status=False):
"""
Set up & run a `Publisher`, and return a dictionary of document parts.
Dictionary keys are the names of parts, and values are Unicode strings;
@@ -440,7 +440,7 @@ def publish_doctree(source, source_path=None,
parser=None, parser_name='restructuredtext',
settings=None, settings_spec=None,
settings_overrides=None, config_section=None,
- enable_exit_status=None):
+ enable_exit_status=False):
"""
Set up & run a `Publisher` for programmatic use with string I/O.
Return the document tree.
@@ -469,7 +469,7 @@ def publish_from_doctree(document, destination_path=None,
writer=None, writer_name='pseudoxml',
settings=None, settings_spec=None,
settings_overrides=None, config_section=None,
- enable_exit_status=None):
+ enable_exit_status=False):
"""
Set up & run a `Publisher` to render from an existing document
tree data structure, for programmatic use with string I/O. Return
@@ -509,7 +509,7 @@ def publish_cmdline_to_binary(reader=None, reader_name='standalone',
writer=None, writer_name='pseudoxml',
settings=None, settings_spec=None,
settings_overrides=None, config_section=None,
- enable_exit_status=1, argv=None,
+ enable_exit_status=True, argv=None,
usage=default_usage, description=default_description,
destination=None, destination_class=io.BinaryFileOutput
):
diff --git a/docutils/examples.py b/docutils/examples.py
index 3826aff3d..9e304ea39 100644
--- a/docutils/examples.py
+++ b/docutils/examples.py
@@ -15,7 +15,8 @@ from docutils import core, io
def html_parts(input_string, source_path=None, destination_path=None,
- input_encoding='unicode', doctitle=1, initial_header_level=1):
+ input_encoding='unicode', doctitle=True,
+ initial_header_level=1):
"""
Given an input string, returns a dictionary of HTML document parts.
@@ -50,7 +51,7 @@ def html_parts(input_string, source_path=None, destination_path=None,
def html_body(input_string, source_path=None, destination_path=None,
input_encoding='unicode', output_encoding='unicode',
- doctitle=1, initial_header_level=1):
+ doctitle=True, initial_header_level=1):
"""
Given an input string, returns an HTML fragment as a string.
diff --git a/docutils/nodes.py b/docutils/nodes.py
index 469ecefbd..559253ff8 100644
--- a/docutils/nodes.py
+++ b/docutils/nodes.py
@@ -120,7 +120,7 @@ class Node(object):
Return true if we should stop the traversal.
"""
- stop = 0
+ stop = False
visitor.document.reporter.debug(
'docutils.nodes.Node.walk calling dispatch_visit for %s'
% self.__class__.__name__)
@@ -135,12 +135,12 @@ class Node(object):
try:
for child in children[:]:
if child.walk(visitor):
- stop = 1
+ stop = True
break
except SkipSiblings:
pass
except StopTraversal:
- stop = 1
+ stop = True
return stop
def walkabout(self, visitor):
@@ -155,8 +155,8 @@ class Node(object):
Return true if we should stop the traversal.
"""
- call_depart = 1
- stop = 0
+ call_depart = True
+ stop = False
visitor.document.reporter.debug(
'docutils.nodes.Node.walkabout calling dispatch_visit for %s'
% self.__class__.__name__)
@@ -166,19 +166,19 @@ class Node(object):
except SkipNode:
return stop
except SkipDeparture:
- call_depart = 0
+ call_depart = False
children = self.children
try:
for child in children[:]:
if child.walkabout(visitor):
- stop = 1
+ stop = True
break
except SkipSiblings:
pass
except SkipChildren:
pass
except StopTraversal:
- stop = 1
+ stop = True
if call_depart:
visitor.document.reporter.debug(
'docutils.nodes.Node.walkabout calling dispatch_departure '
@@ -203,8 +203,8 @@ class Node(object):
result.extend(child._all_traverse())
return result
- def traverse(self, condition=None,
- include_self=1, descend=1, siblings=0, ascend=0):
+ def traverse(self, condition=None, include_self=True, descend=True,
+ siblings=False, ascend=False):
"""
Return an iterable containing
@@ -236,12 +236,12 @@ class Node(object):
[, , <#text: Foo>, <#text: Bar>]
- and list(strong.traverse(ascend=1)) equals ::
+ and list(strong.traverse(ascend=True)) equals ::
[, <#text: Foo>, <#text: Bar>, , <#text: Baz>]
"""
if ascend:
- siblings=1
+ siblings=True
# Check for special argument combinations that allow using an
# optimized version of traverse()
if include_self and descend and not siblings:
@@ -260,16 +260,17 @@ class Node(object):
r.append(self)
if descend and len(self.children):
for child in self:
- r.extend(child.traverse(
- include_self=1, descend=1, siblings=0, ascend=0,
- condition=condition))
+ r.extend(child.traverse(include_self=True, descend=True,
+ siblings=False, ascend=False,
+ condition=condition))
if siblings or ascend:
node = self
while node.parent:
index = node.parent.index(node)
for sibling in node.parent[index+1:]:
- r.extend(sibling.traverse(include_self=1, descend=descend,
- siblings=0, ascend=0,
+ r.extend(sibling.traverse(include_self=True,
+ descend=descend,
+ siblings=False, ascend=False,
condition=condition))
if not ascend:
break
@@ -277,8 +278,8 @@ class Node(object):
node = node.parent
return r
- def next_node(self, condition=None,
- include_self=0, descend=1, siblings=0, ascend=0):
+ def next_node(self, condition=None, include_self=False, descend=True,
+ siblings=False, ascend=False):
"""
Return the first node in the iterable returned by traverse(),
or None if the iterable is empty.
@@ -1112,7 +1113,7 @@ class document(Root, Structural, Element):
def note_explicit_target(self, target, msgnode=None):
id = self.set_id(target, msgnode)
- self.set_name_id_map(target, id, msgnode, explicit=1)
+ self.set_name_id_map(target, id, msgnode, explicit=True)
def note_refname(self, node):
self.refnames.setdefault(node['refname'], []).append(node)
diff --git a/docutils/parsers/rst/__init__.py b/docutils/parsers/rst/__init__.py
index 0e064677d..4caf75f76 100644
--- a/docutils/parsers/rst/__init__.py
+++ b/docutils/parsers/rst/__init__.py
@@ -49,12 +49,12 @@ Anything that isn't already customizable is that way simply because that type
of customizability hasn't been implemented yet. Patches welcome!
When instantiating an object of the `Parser` class, two parameters may be
-passed: ``rfc2822`` and ``inliner``. Pass ``rfc2822=1`` to enable an initial
-RFC-2822 style header block, parsed as a "field_list" element (with "class"
-attribute set to "rfc2822"). Currently this is the only body-level element
-which is customizable without subclassing. (Tip: subclass `Parser` and change
-its "state_classes" and "initial_state" attributes to refer to new classes.
-Contact the author if you need more details.)
+passed: ``rfc2822`` and ``inliner``. Pass ``rfc2822=True`` to enable an
+initial RFC-2822 style header block, parsed as a "field_list" element (with
+"class" attribute set to "rfc2822"). Currently this is the only body-level
+element which is customizable without subclassing. (Tip: subclass `Parser`
+and change its "state_classes" and "initial_state" attributes to refer to new
+classes. Contact the author if you need more details.)
The ``inliner`` parameter takes an instance of `states.Inliner` or a subclass.
It handles inline markup recognition. A common extension is the addition of
@@ -141,7 +141,7 @@ class Parser(docutils.parsers.Parser):
config_section = 'restructuredtext parser'
config_section_dependencies = ('parsers',)
- def __init__(self, rfc2822=None, inliner=None):
+ def __init__(self, rfc2822=False, inliner=None):
if rfc2822:
self.initial_state = 'RFC2822Body'
else:
@@ -158,7 +158,7 @@ class Parser(docutils.parsers.Parser):
debug=document.reporter.debug_flag)
inputlines = docutils.statemachine.string2lines(
inputstring, tab_width=document.settings.tab_width,
- convert_whitespace=1)
+ convert_whitespace=True)
self.statemachine.run(inputlines, document, inliner=self.inliner)
self.finish_parse()
diff --git a/docutils/parsers/rst/directives/html.py b/docutils/parsers/rst/directives/html.py
index 3aca72fdb..3df4c95cd 100644
--- a/docutils/parsers/rst/directives/html.py
+++ b/docutils/parsers/rst/directives/html.py
@@ -74,7 +74,7 @@ class Meta(Directive):
node = nodes.Element()
new_line_offset, blank_finish = self.state.nested_list_parse(
self.content, self.content_offset, node,
- initial_state='MetaBody', blank_finish=1,
+ initial_state='MetaBody', blank_finish=True,
state_machine_kwargs=self.SMkwargs)
if (new_line_offset - self.content_offset) != len(self.content):
# incomplete parse of block?
diff --git a/docutils/parsers/rst/directives/misc.py b/docutils/parsers/rst/directives/misc.py
index cc5a81f6c..63775bb7c 100644
--- a/docutils/parsers/rst/directives/misc.py
+++ b/docutils/parsers/rst/directives/misc.py
@@ -105,16 +105,16 @@ class Include(Directive):
raise self.severe('Problem with "end-before" option of "%s" '
'directive:\nText not found.' % self.name)
rawtext = rawtext[:before_index]
-
- include_lines = statemachine.string2lines(rawtext, tab_width,
- convert_whitespace=1)
+
+ include_lines = statemachine.string2lines(rawtext, tab_width,
+ convert_whitespace=True)
if 'literal' in self.options:
# Convert tabs to spaces, if `tab_width` is positive.
if tab_width >= 0:
text = rawtext.expandtabs(tab_width)
else:
text = rawtext
- literal_block = nodes.literal_block(rawtext, source=path,
+ literal_block = nodes.literal_block(rawtext, source=path,
classes=self.options.get('class', []))
literal_block.line = 1
self.add_name(literal_block)
@@ -130,7 +130,7 @@ class Include(Directive):
tokens = NumberLines([([], text)], startline, endline)
for classes, value in tokens:
if classes:
- literal_block += nodes.inline(value, value,
+ literal_block += nodes.inline(value, value,
classes=classes)
else:
literal_block += nodes.Text(value, value)
@@ -139,7 +139,7 @@ class Include(Directive):
return [literal_block]
if 'code' in self.options:
self.options['source'] = path
- codeblock = CodeBlock(self.name,
+ codeblock = CodeBlock(self.name,
[self.options.pop('code')], # arguments
self.options,
include_lines, # content
@@ -240,7 +240,7 @@ class Raw(Directive):
# This will always fail because there is no content.
self.assert_has_content()
raw_node = nodes.raw('', text, **attributes)
- (raw_node.source,
+ (raw_node.source,
raw_node.line) = self.state_machine.get_source_and_line(self.lineno)
return [raw_node]
diff --git a/docutils/parsers/rst/states.py b/docutils/parsers/rst/states.py
index f2955a32d..d208b2041 100644
--- a/docutils/parsers/rst/states.py
+++ b/docutils/parsers/rst/states.py
@@ -145,7 +145,7 @@ class RSTStateMachine(StateMachineWS):
The entry point to reStructuredText parsing is the `run()` method.
"""
- def run(self, input_lines, document, input_offset=0, match_titles=1,
+ def run(self, input_lines, document, input_offset=0, match_titles=True,
inliner=None):
"""
Parse `input_lines` and modify the `document` node in place.
@@ -164,7 +164,7 @@ class RSTStateMachine(StateMachineWS):
language=self.language,
title_styles=[],
section_level=0,
- section_bubble_up_kludge=0,
+ section_bubble_up_kludge=False,
inliner=inliner)
self.document = document
self.attach_observer(document.note_source)
@@ -183,7 +183,7 @@ class NestedStateMachine(StateMachineWS):
document structures.
"""
- def run(self, input_lines, input_offset, memo, node, match_titles=1):
+ def run(self, input_lines, input_offset, memo, node, match_titles=True):
"""
Parse `input_lines` and populate a `docutils.nodes.document` instance.
@@ -213,7 +213,7 @@ class RSTState(StateWS):
nested_sm = NestedStateMachine
nested_sm_cache = []
- def __init__(self, state_machine, debug=0):
+ def __init__(self, state_machine, debug=False):
self.nested_sm_kwargs = {'state_classes': state_classes,
'initial_state': 'Body'}
StateWS.__init__(self, state_machine, debug)
@@ -258,7 +258,7 @@ class RSTState(StateWS):
"""Called at beginning of file."""
return [], []
- def nested_parse(self, block, input_offset, node, match_titles=0,
+ def nested_parse(self, block, input_offset, node, match_titles=False,
state_machine_class=None, state_machine_kwargs=None):
"""
Create a new StateMachine rooted at `node` and run it over the input
@@ -299,7 +299,7 @@ class RSTState(StateWS):
blank_finish,
blank_finish_state=None,
extra_settings={},
- match_titles=0,
+ match_titles=False,
state_machine_class=None,
state_machine_kwargs=None):
"""
@@ -361,7 +361,7 @@ class RSTState(StateWS):
if level <= mylevel: # sibling or supersection
memo.section_level = level # bubble up to parent section
if len(style) == 2:
- memo.section_bubble_up_kludge = 1
+ memo.section_bubble_up_kludge = True
# back up 2 lines for underline title, 3 for overline title
self.state_machine.previous_line(len(style) + 1)
raise EOFError # let parent section re-evaluate
@@ -396,7 +396,7 @@ class RSTState(StateWS):
absoffset = self.state_machine.abs_line_offset() + 1
newabsoffset = self.nested_parse(
self.state_machine.input_lines[offset:], input_offset=absoffset,
- node=section_node, match_titles=1)
+ node=section_node, match_titles=True)
self.goto_line(newabsoffset)
if memo.section_level <= mylevel: # can't handle next section?
raise EOFError # bubble up to supersection
@@ -438,7 +438,7 @@ class RSTState(StateWS):
line=lineno)
-def build_regexp(definition, compile=1):
+def build_regexp(definition, compile=True):
"""
Build, compile and return a regular expression based on `definition`.
@@ -695,7 +695,7 @@ class Inliner:
return punctuation_chars.match_chars(prestart, poststart)
def inline_obj(self, match, lineno, end_pattern, nodeclass,
- restore_backslashes=0):
+ restore_backslashes=False):
string = match.string
matchstart = match.start('start')
matchend = match.end('start')
@@ -844,7 +844,7 @@ class Inliner:
def literal(self, match, lineno):
before, inlines, remaining, sysmessages, endstring = self.inline_obj(
match, lineno, self.patterns.literal, nodes.literal,
- restore_backslashes=1)
+ restore_backslashes=True)
return before, inlines, remaining, sysmessages
def inline_internal_target(self, match, lineno):
@@ -914,7 +914,7 @@ class Inliner:
before = before.rstrip()
return (before, [refnode], remaining, [])
- def reference(self, match, lineno, anonymous=None):
+ def reference(self, match, lineno, anonymous=False):
referencename = match.group('refname')
refname = normalize_name(referencename)
referencenode = nodes.reference(
@@ -1558,8 +1558,8 @@ class Body(RSTState):
def line_block_line(self, match, lineno):
"""Return one line element of a line_block."""
indented, indent, line_offset, blank_finish = \
- self.state_machine.get_first_known_indented(match.end(),
- until_blank=1)
+ self.state_machine.get_first_known_indented(match.end(),
+ until_blank=True)
text = u'\n'.join(indented)
text_nodes, messages = self.inline_text(text, lineno)
line = nodes.line(text, '', *text_nodes)
@@ -1638,7 +1638,7 @@ class Body(RSTState):
messages = []
blank_finish = 1
try:
- block = self.state_machine.get_text_block(flush_left=1)
+ block = self.state_machine.get_text_block(flush_left=True)
except statemachine.UnexpectedIndentationError, err:
block, src, srcline = err.args
messages.append(self.reporter.error('Unexpected indentation.',
@@ -1868,12 +1868,12 @@ class Body(RSTState):
lineno = self.state_machine.abs_line_number()
block, indent, offset, blank_finish = \
self.state_machine.get_first_known_indented(
- match.end(), until_blank=1, strip_indent=0)
+ match.end(), until_blank=True, strip_indent=False)
blocktext = match.string[:match.end()] + '\n'.join(block)
block = [escape2null(line) for line in block]
escaped = block[0]
blockindex = 0
- while 1:
+ while True:
targetmatch = pattern.match(escaped)
if targetmatch:
break
@@ -1951,12 +1951,12 @@ class Body(RSTState):
src, srcline = self.state_machine.get_source_and_line()
block, indent, offset, blank_finish = \
self.state_machine.get_first_known_indented(match.end(),
- strip_indent=0)
+ strip_indent=False)
blocktext = (match.string[:match.end()] + '\n'.join(block))
block.disconnect()
escaped = escape2null(block[0].rstrip())
blockindex = 0
- while 1:
+ while True:
subdefmatch = pattern.match(escaped)
if subdefmatch:
break
@@ -2192,7 +2192,7 @@ class Body(RSTState):
node = nodes.field_list()
newline_offset, blank_finish = self.nested_list_parse(
datalines, 0, node, initial_state='ExtensionOptions',
- blank_finish=1)
+ blank_finish=True)
if newline_offset != len(datalines): # incomplete parse of block
return 0, 'invalid option block'
try:
@@ -2211,7 +2211,7 @@ class Body(RSTState):
def unknown_directive(self, type_name):
lineno = self.state_machine.abs_line_number()
indented, indent, offset, blank_finish = \
- self.state_machine.get_first_known_indented(0, strip_indent=0)
+ self.state_machine.get_first_known_indented(0, strip_indent=False)
text = '\n'.join(indented)
error = self.reporter.error(
'Unknown directive type "%s".' % type_name,
@@ -2322,8 +2322,8 @@ class Body(RSTState):
def anonymous_target(self, match):
lineno = self.state_machine.abs_line_number()
block, indent, offset, blank_finish \
- = self.state_machine.get_first_known_indented(match.end(),
- until_blank=1)
+ = self.state_machine.get_first_known_indented(match.end(),
+ until_blank=True)
blocktext = match.string[:match.end()] + '\n'.join(block)
block = [escape2null(line) for line in block]
target = self.make_target(block, blocktext, lineno, '')
@@ -2391,7 +2391,7 @@ class RFC2822Body(Body):
name = match.string[:match.string.find(':')]
indented, indent, line_offset, blank_finish = \
self.state_machine.get_first_known_indented(match.end(),
- until_blank=1)
+ until_blank=True)
fieldnode = nodes.field()
fieldnode += nodes.field_name(name, name)
fieldbody = nodes.field_body('\n'.join(indented))
@@ -2710,7 +2710,7 @@ class Text(RSTState):
startline = self.state_machine.abs_line_number() - 1
msg = None
try:
- block = self.state_machine.get_text_block(flush_left=1)
+ block = self.state_machine.get_text_block(flush_left=True)
except statemachine.UnexpectedIndentationError, err:
block, src, srcline = err.args
msg = self.reporter.error('Unexpected indentation.',
@@ -2749,7 +2749,7 @@ class Text(RSTState):
parent_node = nodes.Element()
new_abs_offset = self.nested_parse(
self.state_machine.input_lines[offset:],
- input_offset=abs_line_offset, node=parent_node, match_titles=0,
+ input_offset=abs_line_offset, node=parent_node, match_titles=False,
state_machine_kwargs={'state_classes': (QuotedLiteralBlock,),
'initial_state': 'QuotedLiteralBlock'})
self.goto_line(new_abs_offset)
@@ -2853,7 +2853,7 @@ class Line(SpecializedText):
"""Transition marker at end of section or document."""
marker = context[0].strip()
if self.memo.section_bubble_up_kludge:
- self.memo.section_bubble_up_kludge = 0
+ self.memo.section_bubble_up_kludge = False
elif len(marker) < 4:
self.state_correction(context)
if self.eofcheck: # ignore EOFError with sections
@@ -2979,7 +2979,7 @@ class QuotedLiteralBlock(RSTState):
'text': r''}
initial_transitions = ('initial_quoted', 'text')
- def __init__(self, state_machine, debug=0):
+ def __init__(self, state_machine, debug=False):
RSTState.__init__(self, state_machine, debug)
self.messages = []
self.initial_lineno = None
diff --git a/docutils/parsers/rst/tableparser.py b/docutils/parsers/rst/tableparser.py
index 63a6caf92..793939ff8 100644
--- a/docutils/parsers/rst/tableparser.py
+++ b/docutils/parsers/rst/tableparser.py
@@ -427,7 +427,7 @@ class SimpleTableParser(TableParser):
"""
cols = []
end = 0
- while 1:
+ while True:
begin = line.find('-', end)
end = line.find(' ', begin)
if begin < 0:
diff --git a/docutils/readers/pep.py b/docutils/readers/pep.py
index f11cc58df..b8f6c8138 100644
--- a/docutils/readers/pep.py
+++ b/docutils/readers/pep.py
@@ -44,5 +44,5 @@ class Reader(standalone.Reader):
def __init__(self, parser=None, parser_name=None):
"""`parser` should be ``None``."""
if parser is None:
- parser = rst.Parser(rfc2822=1, inliner=self.inliner_class())
+ parser = rst.Parser(rfc2822=True, inliner=self.inliner_class())
standalone.Reader.__init__(self, parser, '')
diff --git a/docutils/statemachine.py b/docutils/statemachine.py
index 4c33102ea..8431a1293 100644
--- a/docutils/statemachine.py
+++ b/docutils/statemachine.py
@@ -128,7 +128,7 @@ class StateMachine:
results of processing in a list.
"""
- def __init__(self, state_classes, initial_state, debug=0):
+ def __init__(self, state_classes, initial_state, debug=False):
"""
Initialize a `StateMachine` object; add state objects.
@@ -224,7 +224,7 @@ class StateMachine:
print >>self._stderr, '\nStateMachine.run: bof transition'
context, result = state.bof(context)
results.extend(result)
- while 1:
+ while True:
try:
try:
self.next_line()
@@ -403,7 +403,7 @@ class StateMachine:
self.input_lines.insert(self.line_offset + 2,
StringList(input_lines, source))
- def get_text_block(self, flush_left=0):
+ def get_text_block(self, flush_left=False):
"""
Return a contiguous block of text.
@@ -595,14 +595,14 @@ class State:
defaults.
"""
- def __init__(self, state_machine, debug=0):
+ def __init__(self, state_machine, debug=False):
"""
Initialize a `State` object; make & add initial transitions.
Parameters:
- `statemachine`: the controlling `StateMachine` object.
- - `debug`: a boolean; produce verbose output if true (nonzero).
+ - `debug`: a boolean; produce verbose output if true.
"""
self.transition_order = []
@@ -803,17 +803,15 @@ class StateMachineWS(StateMachine):
known.
"""
- def get_indented(self, until_blank=0, strip_indent=1):
+ def get_indented(self, until_blank=False, strip_indent=True):
"""
Return a block of indented lines of text, and info.
Extract an indented block where the indent is unknown for all lines.
:Parameters:
- - `until_blank`: Stop collecting at the first blank line if true
- (1).
- - `strip_indent`: Strip common leading indent if true (1,
- default).
+ - `until_blank`: Stop collecting at the first blank line if true.
+ - `strip_indent`: Strip common leading indent if true (default).
:Return:
- the indented block (a list of lines of text),
@@ -831,7 +829,7 @@ class StateMachineWS(StateMachine):
offset += 1
return indented, indent, offset, blank_finish
- def get_known_indented(self, indent, until_blank=0, strip_indent=1):
+ def get_known_indented(self, indent, until_blank=False, strip_indent=True):
"""
Return an indented block and info.
@@ -842,10 +840,9 @@ class StateMachineWS(StateMachine):
:Parameters:
- `indent`: The number of indent columns/characters.
- - `until_blank`: Stop collecting at the first blank line if true
- (1).
+ - `until_blank`: Stop collecting at the first blank line if true.
- `strip_indent`: Strip `indent` characters of indentation if true
- (1, default).
+ (default).
:Return:
- the indented block,
@@ -862,8 +859,8 @@ class StateMachineWS(StateMachine):
offset += 1
return indented, offset, blank_finish
- def get_first_known_indented(self, indent, until_blank=0, strip_indent=1,
- strip_top=1):
+ def get_first_known_indented(self, indent, until_blank=False,
+ strip_indent=True, strip_top=True):
"""
Return an indented block and info.
@@ -957,7 +954,7 @@ class StateWS(State):
"""Default initial whitespace transitions, added before those listed in
`State.initial_transitions`. May be overridden in subclasses."""
- def __init__(self, state_machine, debug=0):
+ def __init__(self, state_machine, debug=False):
"""
Initialize a `StateSM` object; extends `State.__init__()`.
@@ -1348,7 +1345,7 @@ class StringList(ViewList):
self.data[start:end] = [line[length:]
for line in self.data[start:end]]
- def get_text_block(self, start, flush_left=0):
+ def get_text_block(self, start, flush_left=False):
"""
Return a contiguous block of text.
@@ -1369,7 +1366,7 @@ class StringList(ViewList):
end += 1
return self[start:end]
- def get_indented(self, start=0, until_blank=0, strip_indent=1,
+ def get_indented(self, start=0, until_blank=False, strip_indent=True,
block_indent=None, first_indent=None):
"""
Extract and return a StringList of indented lines of text.
@@ -1429,7 +1426,7 @@ class StringList(ViewList):
block.trim_left(indent, start=(first_indent is not None))
return block, indent or 0, blank_finish
- def get_2D_block(self, top, left, bottom, right, strip_indent=1):
+ def get_2D_block(self, top, left, bottom, right, strip_indent=True):
block = self[top:bottom]
indent = right
for i in range(len(block.data)):
@@ -1504,7 +1501,7 @@ class StateCorrection(Exception):
"""
-def string2lines(astring, tab_width=8, convert_whitespace=0,
+def string2lines(astring, tab_width=8, convert_whitespace=False,
whitespace=re.compile('[\v\f]')):
"""
Return a list of one-line strings with tabs expanded, no newlines, and
diff --git a/docutils/transforms/references.py b/docutils/transforms/references.py
index 755fd4646..05296ea1e 100644
--- a/docutils/transforms/references.py
+++ b/docutils/transforms/references.py
@@ -47,7 +47,7 @@ class PropagateTargets(Transform):
target.hasattr('refname'))):
continue
assert len(target) == 0, 'error: block-level target has children'
- next_node = target.next_node(ascend=1)
+ next_node = target.next_node(ascend=True)
# Do not move names and ids into Invisibles (we'd lose the
# attributes) or different Targetables (e.g. footnotes).
if (next_node is not None and
@@ -136,7 +136,7 @@ class AnonymousHyperlinks(Transform):
return
for ref, target in zip(anonymous_refs, anonymous_targets):
target.referenced = 1
- while 1:
+ while True:
if target.hasattr('refuri'):
ref['refuri'] = target['refuri']
ref.resolved = 1
@@ -502,7 +502,7 @@ class Footnotes(Transform):
corresponding footnote references.
"""
for footnote in self.document.autofootnotes:
- while 1:
+ while True:
label = str(startnum)
startnum += 1
if label not in self.document.nameids:
@@ -808,8 +808,7 @@ class TargetNotes(Transform):
for ref in refs:
if isinstance(ref, nodes.target):
continue
- refnode = nodes.footnote_reference(
- refname=footnote_name, auto=1)
+ refnode = nodes.footnote_reference(refname=footnote_name, auto=1)
refnode['classes'] += self.classes
self.document.note_autofootnote_ref(refnode)
self.document.note_footnote_ref(refnode)
diff --git a/docutils/transforms/writer_aux.py b/docutils/transforms/writer_aux.py
index fa9178e78..9e9a65f93 100644
--- a/docutils/transforms/writer_aux.py
+++ b/docutils/transforms/writer_aux.py
@@ -39,11 +39,11 @@ class Compound(Transform):
def apply(self):
for compound in self.document.traverse(nodes.compound):
- first_child = 1
+ first_child = True
for child in compound:
if first_child:
if not isinstance(child, nodes.Invisible):
- first_child = 0
+ first_child = False
else:
child['classes'].append('continued')
# Substitute children for compound.
diff --git a/docutils/utils/__init__.py b/docutils/utils/__init__.py
index c0113e30d..aaed6dd0c 100644
--- a/docutils/utils/__init__.py
+++ b/docutils/utils/__init__.py
@@ -72,7 +72,7 @@ class Reporter:
SEVERE_LEVEL) = range(5)
def __init__(self, source, report_level, halt_level, stream=None,
- debug=0, encoding=None, error_handler='backslashreplace'):
+ debug=False, encoding=None, error_handler='backslashreplace'):
"""
:Parameters:
- `source`: The path to or description of the source data.
@@ -123,7 +123,7 @@ class Reporter:
"""The highest level system message generated so far."""
def set_conditions(self, category, report_level, halt_level,
- stream=None, debug=0):
+ stream=None, debug=False):
warnings.warn('docutils.utils.Reporter.set_conditions deprecated; '
'set attributes via configuration settings or directly',
DeprecationWarning, stacklevel=2)
@@ -547,7 +547,7 @@ def escape2null(text):
"""Return a string with escape-backslashes converted to nulls."""
parts = []
start = 0
- while 1:
+ while True:
found = text.find('\\', start)
if found == -1:
parts.append(text[start:])
@@ -556,7 +556,7 @@ def escape2null(text):
parts.append('\x00' + text[found+1:found+2])
start = found + 2 # skip character after escape
-def unescape(text, restore_backslashes=0):
+def unescape(text, restore_backslashes=False):
"""
Return a string with nulls removed or restored to backslashes.
Backslash-escaped spaces are also removed.
diff --git a/docutils/writers/html4css1/__init__.py b/docutils/writers/html4css1/__init__.py
index 6d94f944f..761b9f601 100644
--- a/docutils/writers/html4css1/__init__.py
+++ b/docutils/writers/html4css1/__init__.py
@@ -307,10 +307,10 @@ class HTMLTranslator(nodes.NodeVisitor):
self.topic_classes = []
self.colspecs = []
self.compact_p = 1
- self.compact_simple = None
- self.compact_field_list = None
- self.in_docinfo = None
- self.in_sidebar = None
+ self.compact_simple = False
+ self.compact_field_list = False
+ self.in_docinfo = False
+ self.in_sidebar = False
self.title = []
self.subtitle = []
self.header = []
@@ -319,9 +319,9 @@ class HTMLTranslator(nodes.NodeVisitor):
self.html_title = []
self.html_subtitle = []
self.html_body = []
- self.in_document_title = 0
- self.in_mailto = 0
- self.author_in_authors = None
+ self.in_document_title = 0 # len(self.body) or 0
+ self.in_mailto = False
+ self.author_in_authors = False
self.math_header = ''
def astext(self):
@@ -388,7 +388,7 @@ class HTMLTranslator(nodes.NodeVisitor):
path = utils.relative_path(self.settings._destination, path)
return self.stylesheet_link % self.encode(path)
- def starttag(self, node, tagname, suffix='\n', empty=0, **attributes):
+ def starttag(self, node, tagname, suffix='\n', empty=False, **attributes):
"""
Construct and return a start tag given a node (id & class attributes
are extracted), tag name, and optional attributes.
@@ -454,7 +454,7 @@ class HTMLTranslator(nodes.NodeVisitor):
def emptytag(self, node, tagname, suffix='\n', **attributes):
"""Construct and return an XML-compatible empty tag."""
- return self.starttag(node, tagname, suffix, empty=1, **attributes)
+ return self.starttag(node, tagname, suffix, empty=True, **attributes)
def set_class_on_child(self, node, class_, index=0):
"""
@@ -497,7 +497,7 @@ class HTMLTranslator(nodes.NodeVisitor):
self.body.append('')
def visit_address(self, node):
- self.visit_docinfo_item(node, 'address', meta=None)
+ self.visit_docinfo_item(node, 'address', meta=False)
self.body.append(self.starttag(node, 'pre', CLASS='address'))
def depart_address(self, node):
@@ -534,17 +534,16 @@ class HTMLTranslator(nodes.NodeVisitor):
def depart_author(self, node):
if isinstance(node.parent, nodes.authors):
- self.author_in_authors += 1
+ self.author_in_authors = True
else:
self.depart_docinfo_item()
def visit_authors(self, node):
self.visit_docinfo_item(node, 'authors')
- self.author_in_authors = 0 # initialize counter
+ self.author_in_authors = False # initialize
def depart_authors(self, node):
self.depart_docinfo_item()
- self.author_in_authors = None
def visit_block_quote(self, node):
self.body.append(self.starttag(node, 'blockquote'))
@@ -661,7 +660,7 @@ class HTMLTranslator(nodes.NodeVisitor):
self.body.append('\n')
def visit_contact(self, node):
- self.visit_docinfo_item(node, 'contact', meta=None)
+ self.visit_docinfo_item(node, 'contact', meta=False)
def depart_contact(self, node):
self.depart_docinfo_item()
@@ -719,16 +718,16 @@ class HTMLTranslator(nodes.NodeVisitor):
self.body.append('\n'
'\n'
'\n')
- self.in_docinfo = 1
+ self.in_docinfo = True
def depart_docinfo(self, node):
self.body.append('\n\n')
- self.in_docinfo = None
+ self.in_docinfo = False
start = self.context.pop()
self.docinfo = self.body[start:]
self.body = []
- def visit_docinfo_item(self, node, name, meta=1):
+ def visit_docinfo_item(self, node, name, meta=True):
if meta:
meta_tag = '\n' \
% (name, self.attval(node.astext()))
@@ -858,10 +857,10 @@ class HTMLTranslator(nodes.NodeVisitor):
self.context.append((self.compact_field_list, self.compact_p))
self.compact_p = None
if 'compact' in node['classes']:
- self.compact_field_list = 1
+ self.compact_field_list = True
elif (self.settings.compact_field_lists
and 'open' not in node['classes']):
- self.compact_field_list = 1
+ self.compact_field_list = True
if self.compact_field_list:
for field in node:
field_body = field[-1]
@@ -872,7 +871,7 @@ class HTMLTranslator(nodes.NodeVisitor):
len(children) == 1 and
isinstance(children[0],
(nodes.paragraph, nodes.line_block))):
- self.compact_field_list = 0
+ self.compact_field_list = False
break
self.body.append(self.starttag(node, 'table', frame='void',
rules='none',
@@ -1369,7 +1368,7 @@ class HTMLTranslator(nodes.NodeVisitor):
if ( self.settings.cloak_email_addresses
and atts['href'].startswith('mailto:')):
atts['href'] = self.cloak_mailto(atts['href'])
- self.in_mailto = 1
+ self.in_mailto = True
atts['class'] += ' external'
else:
assert 'refid' in node, \
@@ -1385,10 +1384,10 @@ class HTMLTranslator(nodes.NodeVisitor):
self.body.append('')
if not isinstance(node.parent, nodes.TextElement):
self.body.append('\n')
- self.in_mailto = 0
+ self.in_mailto = False
def visit_revision(self, node):
- self.visit_docinfo_item(node, 'revision', meta=None)
+ self.visit_docinfo_item(node, 'revision', meta=False)
def depart_revision(self, node):
self.depart_docinfo_item()
@@ -1419,14 +1418,14 @@ class HTMLTranslator(nodes.NodeVisitor):
self.body.append(
self.starttag(node, 'div', CLASS='sidebar'))
self.set_first_last(node)
- self.in_sidebar = 1
+ self.in_sidebar = True
def depart_sidebar(self, node):
self.body.append('\n')
- self.in_sidebar = None
+ self.in_sidebar = False
def visit_status(self, node):
- self.visit_docinfo_item(node, 'status', meta=None)
+ self.visit_docinfo_item(node, 'status', meta=False)
def depart_status(self, node):
self.depart_docinfo_item()
@@ -1569,7 +1568,7 @@ class HTMLTranslator(nodes.NodeVisitor):
def visit_title(self, node):
"""Only 6 section levels are supported by HTML."""
- check_id = 0
+ check_id = 0 # TODO: is this a bool (False) or a counter?
close_tag = '
\n'
if isinstance(node.parent, nodes.topic):
self.body.append(
@@ -1638,7 +1637,7 @@ class HTMLTranslator(nodes.NodeVisitor):
pass
def visit_version(self, node):
- self.visit_docinfo_item(node, 'version', meta=None)
+ self.visit_docinfo_item(node, 'version', meta=False)
def depart_version(self, node):
self.depart_docinfo_item()
diff --git a/docutils/writers/latex2e/__init__.py b/docutils/writers/latex2e/__init__.py
index d64edc7fb..f0a59402d 100644
--- a/docutils/writers/latex2e/__init__.py
+++ b/docutils/writers/latex2e/__init__.py
@@ -720,7 +720,7 @@ class Table(object):
self._translator = translator
self._latex_type = latex_type
self._table_style = table_style
- self._open = 0
+ self._open = False
# miscellaneous attributes
self._attrs = {}
self._col_width = []
@@ -850,6 +850,7 @@ class Table(object):
elif self._table_style == 'booktabs':
return ['\\toprule\n']
return []
+
def depart_thead(self):
a = []
#if self._table_style == 'standard':
@@ -885,7 +886,7 @@ class Table(object):
cline = ''
rowspans.reverse()
# TODO merge clines
- while 1:
+ while True:
try:
c_start = rowspans.pop()
except:
@@ -928,10 +929,10 @@ class LaTeXTranslator(nodes.NodeVisitor):
## use_optionlist_for_docinfo = False # TODO: NOT YET IN USE
# Use compound enumerations (1.A.1.)
- compound_enumerators = 0
+ compound_enumerators = False
# If using compound enumerations, include section information.
- section_prefix_for_enumerators = 0
+ section_prefix_for_enumerators = False
# This is the character that separates the section ("." subsection ...)
# prefix from the regular list enumerator.
@@ -1106,7 +1107,7 @@ class LaTeXTranslator(nodes.NodeVisitor):
# Stylesheets
# (the name `self.stylesheet` is singular because only one
# stylesheet was supported before Docutils 0.6).
- self.stylesheet = [self.stylesheet_call(path)
+ self.stylesheet = [self.stylesheet_call(path)
for path in utils.get_stylesheet_list(settings)]
# PDF setup
@@ -1678,8 +1679,8 @@ class LaTeXTranslator(nodes.NodeVisitor):
if self._use_latex_citations:
followup_citation = False
# check for a following citation separated by a space or newline
- next_siblings = node.traverse(descend=0, siblings=1,
- include_self=0)
+ next_siblings = node.traverse(descend=False, siblings=True,
+ include_self=False)
if len(next_siblings) > 1:
next = next_siblings[0]
if (isinstance(next, nodes.Text) and
diff --git a/docutils/writers/pseudoxml.py b/docutils/writers/pseudoxml.py
index 466fde300..93975b2b0 100644
--- a/docutils/writers/pseudoxml.py
+++ b/docutils/writers/pseudoxml.py
@@ -28,4 +28,4 @@ class Writer(writers.Writer):
def supports(self, format):
"""This writer supports all format-specific elements."""
- return 1
+ return True
diff --git a/docutils/writers/s5_html/__init__.py b/docutils/writers/s5_html/__init__.py
index 08897491a..37bfa0d90 100644
--- a/docutils/writers/s5_html/__init__.py
+++ b/docutils/writers/s5_html/__init__.py
@@ -202,7 +202,7 @@ class S5HTMLTranslator(html4css1.HTMLTranslator):
else:
# no destination, so we can't copy the theme
return
- default = 0
+ default = False
while path:
for f in os.listdir(path): # copy all files from each theme
if f == self.base_theme_file:
@@ -233,7 +233,7 @@ class S5HTMLTranslator(html4css1.HTMLTranslator):
if not path:
path = find_theme(self.default_theme)
theme_paths.append(path)
- default = 1
+ default = True
if len(required_files_copied) != len(self.required_theme_files):
# Some required files weren't found & couldn't be copied.
required = list(self.required_theme_files)
diff --git a/test/DocutilsTestSupport.py b/test/DocutilsTestSupport.py
index f85a8f0f7..1d1276cca 100644
--- a/test/DocutilsTestSupport.py
+++ b/test/DocutilsTestSupport.py
@@ -143,8 +143,8 @@ class CustomTestCase(StandardTestCase):
compare = difflib.Differ().compare
"""Comparison method shared by all subclasses."""
- def __init__(self, method_name, input, expected, id, run_in_debugger=0,
- suite_settings=None):
+ def __init__(self, method_name, input, expected, id,
+ run_in_debugger=True, suite_settings=None):
"""
Initialise the CustomTestCase.
@@ -274,7 +274,7 @@ class CustomTestSuite(unittest.TestSuite):
self.id = id
def addTestCase(self, test_case_class, method_name, input, expected,
- id=None, run_in_debugger=0, **kwargs):
+ id=None, run_in_debugger=False, **kwargs):
"""
Create a CustomTestCase in the CustomTestSuite.
Also return it, just in case.
@@ -405,7 +405,7 @@ class TransformTestSuite(CustomTestSuite):
for name, (transforms, cases) in dict.items():
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = 0
+ run_in_debugger = False
if len(case)==3:
# TODO: (maybe) change the 3rd argument to a dict, so it
# can handle more cases by keyword ('disable', 'debug',
@@ -413,7 +413,7 @@ class TransformTestSuite(CustomTestSuite):
# But there's also the method that
# HtmlPublishPartsTestSuite uses
if case[2]:
- run_in_debugger = 1
+ run_in_debugger = True
else:
continue
self.addTestCase(
@@ -479,10 +479,10 @@ class ParserTestSuite(CustomTestSuite):
for name, cases in dict.items():
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = 0
+ run_in_debugger = False
if len(case)==3:
if case[2]:
- run_in_debugger = 1
+ run_in_debugger = True
else:
continue
self.addTestCase(
@@ -496,7 +496,7 @@ class PEPParserTestCase(ParserTestCase):
"""PEP-specific parser test case."""
- parser = rst.Parser(rfc2822=1, inliner=rst.states.Inliner())
+ parser = rst.Parser(rfc2822=True, inliner=rst.states.Inliner())
"""Parser shared by all PEPParserTestCases."""
option_parser = frontend.OptionParser(components=(rst.Parser, pep.Reader))
@@ -564,10 +564,10 @@ class GridTableParserTestSuite(CustomTestSuite):
for name, cases in dict.items():
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = 0
+ run_in_debugger = False
if len(case) == 4:
if case[-1]:
- run_in_debugger = 1
+ run_in_debugger = True
else:
continue
self.addTestCase(self.test_case_class, 'test_parse_table',
@@ -607,10 +607,10 @@ class SimpleTableParserTestSuite(CustomTestSuite):
for name, cases in dict.items():
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = 0
+ run_in_debugger = False
if len(case) == 3:
if case[-1]:
- run_in_debugger = 1
+ run_in_debugger = True
else:
continue
self.addTestCase(self.test_case_class, 'test_parse',
@@ -668,10 +668,10 @@ class PythonModuleParserTestSuite(CustomTestSuite):
for name, cases in dict.items():
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = 0
+ run_in_debugger = False
if len(case)==3:
if case[2]:
- run_in_debugger = 1
+ run_in_debugger = True
else:
continue
self.addTestCase(
@@ -724,10 +724,10 @@ class PublishTestSuite(CustomTestSuite):
for name, cases in dict.items():
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = 0
+ run_in_debugger = False
if len(case)==3:
if case[2]:
- run_in_debugger = 1
+ run_in_debugger = True
else:
continue
self.addTestCase(
@@ -747,10 +747,10 @@ class HtmlPublishPartsTestSuite(CustomTestSuite):
settings.update(settings_overrides)
for casenum in range(len(cases)):
case = cases[casenum]
- run_in_debugger = 0
+ run_in_debugger = False
if len(case)==3:
if case[2]:
- run_in_debugger = 1
+ run_in_debugger = True
else:
continue
self.addTestCase(
diff --git a/test/functional/tests/_default.py b/test/functional/tests/_default.py
index 2835c5b2e..288b109df 100644
--- a/test/functional/tests/_default.py
+++ b/test/functional/tests/_default.py
@@ -4,4 +4,4 @@ settings_overrides['report_level'] = 2
settings_overrides['halt_level'] = 5
settings_overrides['warning_stream'] = ''
settings_overrides['input_encoding'] = 'utf-8'
-settings_overrides['embed_stylesheet'] = 0
+settings_overrides['embed_stylesheet'] = False
diff --git a/test/functional/tests/dangerous.py b/test/functional/tests/dangerous.py
index 620a927ba..a17ef95d5 100644
--- a/test/functional/tests/dangerous.py
+++ b/test/functional/tests/dangerous.py
@@ -8,5 +8,5 @@ parser_name = "rst"
writer_name = "html"
# Settings
-settings_overrides['file_insertion_enabled'] = 0
-settings_overrides['raw_enabled'] = 0
+settings_overrides['file_insertion_enabled'] = False
+settings_overrides['raw_enabled'] = False
diff --git a/test/functional/tests/field_name_limit.py b/test/functional/tests/field_name_limit.py
index db79d4c67..c7e515d05 100644
--- a/test/functional/tests/field_name_limit.py
+++ b/test/functional/tests/field_name_limit.py
@@ -9,4 +9,4 @@ writer_name = "html"
# Settings
settings_overrides['field_name_limit'] = 0 # no limit
-settings_overrides['docinfo_xform'] = 0
+settings_overrides['docinfo_xform'] = False
diff --git a/test/functional/tests/misc_rst_html4css1.py b/test/functional/tests/misc_rst_html4css1.py
index 8851e6041..7ee1921f6 100644
--- a/test/functional/tests/misc_rst_html4css1.py
+++ b/test/functional/tests/misc_rst_html4css1.py
@@ -11,4 +11,4 @@ writer_name = "html4css1"
# test for encoded attribute value:
settings_overrides['stylesheet'] = 'foo&bar.css'
settings_overrides['stylesheet_path'] = ''
-settings_overrides['embed_stylesheet'] = 0
+settings_overrides['embed_stylesheet'] = False
diff --git a/test/package_unittest.py b/test/package_unittest.py
index 64d4da5de..995547c19 100644
--- a/test/package_unittest.py
+++ b/test/package_unittest.py
@@ -21,7 +21,7 @@ import re
# So that individual test modules can share a bit of state,
# `package_unittest` acts as an intermediary for the following
# variables:
-debug = 0
+debug = False
verbosity = 1
USAGE = """\
diff --git a/test/test_nodes.py b/test/test_nodes.py
index 39023fb4e..d0ef994d5 100755
--- a/test/test_nodes.py
+++ b/test/test_nodes.py
@@ -16,7 +16,7 @@ import DocutilsTestSupport # must be imported before docutils
from DocutilsTestSupport import nodes, utils
from docutils._compat import b
-debug = 0
+debug = False
class TextTests(unittest.TestCase):
@@ -399,21 +399,21 @@ class MiscTests(unittest.TestCase):
e += nodes.Element()
self.assertEquals(list(e.traverse()),
[e, e[0], e[0][0], e[0][1], e[0][1][0], e[1], e[2]])
- self.assertEquals(list(e.traverse(include_self=0)),
+ self.assertEquals(list(e.traverse(include_self=False)),
[e[0], e[0][0], e[0][1], e[0][1][0], e[1], e[2]])
- self.assertEquals(list(e.traverse(descend=0)),
+ self.assertEquals(list(e.traverse(descend=False)),
[e])
- self.assertEquals(list(e[0].traverse(descend=0, ascend=1)),
+ self.assertEquals(list(e[0].traverse(descend=False, ascend=True)),
[e[0], e[1], e[2]])
- self.assertEquals(list(e[0][0].traverse(descend=0, ascend=1)),
+ self.assertEquals(list(e[0][0].traverse(descend=False, ascend=True)),
[e[0][0], e[0][1], e[1], e[2]])
- self.assertEquals(list(e[0][0].traverse(descend=0, siblings=1)),
+ self.assertEquals(list(e[0][0].traverse(descend=False, siblings=True)),
[e[0][0], e[0][1]])
self.testlist = e[0:2]
self.assertEquals(list(e.traverse(condition=self.not_in_testlist)),
[e, e[0][0], e[0][1], e[0][1][0], e[2]])
- # Return siblings despite siblings=0 because ascend is true.
- self.assertEquals(list(e[1].traverse(ascend=1, siblings=0)),
+ # Return siblings despite siblings=False because ascend is true.
+ self.assertEquals(list(e[1].traverse(ascend=True, siblings=False)),
[e[1], e[2]])
self.assertEquals(list(e[0].traverse()),
[e[0], e[0][0], e[0][1], e[0][1][0]])
@@ -442,9 +442,9 @@ class MiscTests(unittest.TestCase):
(e[1], e[2]),
(e[2], None)]
for node, next_node in compare:
- self.assertEquals(node.next_node(self.not_in_testlist, ascend=1),
+ self.assertEquals(node.next_node(self.not_in_testlist, ascend=True),
next_node)
- self.assertEquals(e[0][0].next_node(ascend=1), e[0][1])
+ self.assertEquals(e[0][0].next_node(ascend=True), e[0][1])
self.assertEquals(e[2].next_node(), None)
def not_in_testlist(self, x):
diff --git a/test/test_statemachine.py b/test/test_statemachine.py
index 6146fb753..78c2471d5 100755
--- a/test/test_statemachine.py
+++ b/test/test_statemachine.py
@@ -14,7 +14,7 @@ import re
from DocutilsTestSupport import statemachine
-debug = 0
+debug = False
testtext = statemachine.string2lines("""\
First paragraph.
diff --git a/test/test_writers/test_html4css1_misc.py b/test/test_writers/test_html4css1_misc.py
index f363321e0..e171e52ac 100755
--- a/test/test_writers/test_html4css1_misc.py
+++ b/test/test_writers/test_html4css1_misc.py
@@ -1,7 +1,8 @@
#! /usr/bin/env python
# $Id$
-# Author: Lea Wiemann
+# Author: Lea Wiemann
+# Maintainer: docutils-develop@lists.sourceforge.net
# Copyright: This module has been placed in the public domain.
"""
@@ -21,13 +22,13 @@ class EncodingTestCase(DocutilsTestSupport.StandardTestCase):
settings_overrides={
'output_encoding': 'latin1',
'stylesheet': '',
- '_disable_config': 1,}
+ '_disable_config': True,}
result = core.publish_string(
- b('EUR = \xe2\x82\xac'), writer_name='html4css1',
+ u'EUR = \u20ac', writer_name='html4css1',
settings_overrides=settings_overrides)
# Encoding a euro sign with latin1 doesn't work, so the
# xmlcharrefreplace handler is used.
- self.assert_(result.find(b('EUR = €')) != -1)
+ self.assertNotEqual(result.find(b('EUR = €')), -1)
if __name__ == '__main__':
--
2.11.4.GIT