From: <fel...@us...> - 2005-09-11 21:53:57
|
Author: felixwiemann Date: 2005-09-11 23:53:49 +0200 (Sun, 11 Sep 2005) New Revision: 3870 Modified: trunk/docutils/docutils/transforms/components.py trunk/docutils/docutils/transforms/misc.py trunk/docutils/docutils/transforms/parts.py trunk/docutils/docutils/transforms/peps.py trunk/docutils/docutils/transforms/references.py trunk/docutils/test/functional/expected/standalone_rst_html4css1.html trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt trunk/docutils/test/test_transforms/test_footnotes.py trunk/docutils/test/test_transforms/test_hyperlinks.py Log: replaced node.parent.replace(node, new) constructs with node.substitute(new) Modified: trunk/docutils/docutils/transforms/components.py =================================================================== --- trunk/docutils/docutils/transforms/components.py 2005-09-11 21:53:02 UTC (rev 3869) +++ trunk/docutils/docutils/transforms/components.py 2005-09-11 21:53:49 UTC (rev 3870) @@ -49,6 +49,6 @@ format = pending.details['format'] component = self.document.transformer.components[component_type] if component.supports(format): - pending.parent.replace(pending, pending.details['nodes']) + pending.substitute(pending.details['nodes']) else: pending.parent.remove(pending) Modified: trunk/docutils/docutils/transforms/misc.py =================================================================== --- trunk/docutils/docutils/transforms/misc.py 2005-09-11 21:53:02 UTC (rev 3869) +++ trunk/docutils/docutils/transforms/misc.py 2005-09-11 21:53:49 UTC (rev 3870) @@ -66,7 +66,7 @@ % pending.details['directive'], nodes.literal_block(pending.rawsource, pending.rawsource), line=pending.line) - pending.parent.replace(pending, error) + pending.substitute(error) class Transitions(Transform): Modified: trunk/docutils/docutils/transforms/parts.py =================================================================== --- trunk/docutils/docutils/transforms/parts.py 2005-09-11 21:53:02 UTC (rev 3869) +++ trunk/docutils/docutils/transforms/parts.py 2005-09-11 21:53:49 UTC (rev 3870) @@ -97,7 +97,7 @@ self.backlinks = self.document.settings.toc_backlinks contents = self.build_contents(startnode) if len(contents): - self.startnode.parent.replace(self.startnode, contents) + self.startnode.substitute(contents) else: self.startnode.parent.parent.remove(self.startnode.parent) Modified: trunk/docutils/docutils/transforms/peps.py =================================================================== --- trunk/docutils/docutils/transforms/peps.py 2005-09-11 21:53:02 UTC (rev 3869) +++ trunk/docutils/docutils/transforms/peps.py 2005-09-11 21:53:49 UTC (rev 3870) @@ -107,11 +107,11 @@ if name == 'author': for node in para: if isinstance(node, nodes.reference): - node.parent.replace(node, mask_email(node)) + node.substitute(mask_email(node)) elif name == 'discussions-to': for node in para: if isinstance(node, nodes.reference): - node.parent.replace(node, mask_email(node, pep)) + node.substitute(mask_email(node, pep)) elif name in ('replaces', 'replaced-by', 'requires'): newbody = [] space = nodes.Text(' ') @@ -241,7 +241,7 @@ pass def visit_reference(self, node): - node.parent.replace(node, mask_email(node)) + node.substitute(mask_email(node)) def visit_field_list(self, node): if 'rfc2822' in node['classes']: Modified: trunk/docutils/docutils/transforms/references.py =================================================================== --- trunk/docutils/docutils/transforms/references.py 2005-09-11 21:53:02 UTC (rev 3869) +++ trunk/docutils/docutils/transforms/references.py 2005-09-11 21:53:49 UTC (rev 3870) @@ -127,7 +127,7 @@ ref.rawsource, ref.rawsource, refid=msgid) prbid = self.document.set_id(prb) msg.add_backref(prbid) - ref.parent.replace(ref, prb) + ref.substitute(prb) return for ref, target in zip(self.document.anonymous_refs, self.document.anonymous_targets): @@ -281,7 +281,7 @@ ref.rawsource, ref.rawsource, refid=msgid) prbid = self.document.set_id(prb) msg.add_backref(prbid) - ref.parent.replace(ref, prb) + ref.substitute(prb) target.resolved = 1 def resolve_indirect_references(self, target): @@ -540,7 +540,7 @@ ref.rawsource, ref.rawsource, refid=msgid) prbid = self.document.set_id(prb) msg.add_backref(prbid) - ref.parent.replace(ref, prb) + ref.substitute(prb) break ref += nodes.Text(label) id = self.document.nameids[label] @@ -580,7 +580,7 @@ ref.rawsource, ref.rawsource, refid=msgid) prbid = self.document.set_id(prb) msg.add_backref(prbid) - ref.parent.replace(ref, prb) + ref.substitute(prb) break footnote = self.document.symbol_footnotes[i] assert len(footnote['ids']) == 1 @@ -674,7 +674,7 @@ ref.rawsource, ref.rawsource, refid=msgid) prbid = self.document.set_id(prb) msg.add_backref(prbid) - ref.parent.replace(ref, prb) + ref.substitute(prb) else: subdef = defs[key] parent = ref.parent @@ -691,7 +691,7 @@ and isinstance(parent[index + 1], nodes.Text)): parent.replace(parent[index + 1], parent[index + 1].lstrip()) - parent.replace(ref, subdef.children) + ref.substitute(subdef.children) self.document.substitution_refs = None # release replaced references @@ -732,7 +732,7 @@ if not notes.has_key(target['refuri']): notes[target['refuri']] = footnote nodelist.append(footnote) - self.startnode.parent.replace(self.startnode, nodelist) + self.startnode.substitute(nodelist) def make_target_footnote(self, target, refs, notes): refuri = target['refuri'] @@ -838,7 +838,7 @@ node.rawsource, node.rawsource, refid=msgid) prbid = self.document.set_id(prb) msg.add_backref(prbid) - node.parent.replace(node, prb) + node.substitute(prb) else: del node['refname'] node['refid'] = id Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html =================================================================== --- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2005-09-11 21:53:02 UTC (rev 3869) +++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2005-09-11 21:53:49 UTC (rev 3870) @@ -479,7 +479,7 @@ <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> <tr><td class="label"><a name="id13">[4]</a></td><td>Here's an unreferenced footnote, with a reference to a -nonexistent footnote: <a href="#id25" name="id26"><span class="problematic" id="id26">[5]_</span></a>.</td></tr> +nonexistent footnote: <a href="#id25" name="id26"><span class="problematic" id="id26"><span id="id14"></span>[5]_</span></a>.</td></tr> </tbody> </table> </div> @@ -492,7 +492,7 @@ rendered separately and differently from footnotes.</td></tr> </tbody> </table> -<p>Here's a reference to the above, <a class="citation-reference" href="#cit2002" id="id15" name="id15">[CIT2002]</a>, and a <a href="#id27" name="id28"><span class="problematic" id="id28">[nonexistent]_</span></a> +<p>Here's a reference to the above, <a class="citation-reference" href="#cit2002" id="id15" name="id15">[CIT2002]</a>, and a <a href="#id27" name="id28"><span class="problematic" id="id28"><span id="id16"></span>[nonexistent]_</span></a> citation.</p> </div> <div class="section"> Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt =================================================================== --- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2005-09-11 21:53:02 UTC (rev 3869) +++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2005-09-11 21:53:49 UTC (rev 3870) @@ -948,7 +948,7 @@ <paragraph> Here's an unreferenced footnote, with a reference to a nonexistent footnote: - <problematic ids="id26" refid="id25"> + <problematic ids="id26 id14" refid="id25"> [5]_ . <section ids="citations" names="citations"> @@ -967,7 +967,7 @@ <citation_reference ids="id15" refid="cit2002"> CIT2002 , and a - <problematic ids="id28" refid="id27"> + <problematic ids="id28 id16" refid="id27"> [nonexistent]_ citation. Modified: trunk/docutils/test/test_transforms/test_footnotes.py =================================================================== --- trunk/docutils/test/test_transforms/test_footnotes.py 2005-09-11 21:53:02 UTC (rev 3869) +++ trunk/docutils/test/test_transforms/test_footnotes.py 2005-09-11 21:53:49 UTC (rev 3870) @@ -182,7 +182,7 @@ <footnote_reference auto="1" ids="id3" refid="id8"> 3 should be 3, \n\ - <problematic ids="id11" refid="id10"> + <problematic ids="id11 id4" refid="id10"> [#]_ is one too many, <footnote_reference auto="1" ids="id5" refid="two"> @@ -327,7 +327,7 @@ <footnote_reference auto="1" ids="id5" refid="id12"> 6 should be 6, \n\ - <problematic ids="id15" refid="id14"> + <problematic ids="id15 id6" refid="id14"> [#]_ is one too many, <footnote_reference auto="1" ids="id7" refname="five"> Modified: trunk/docutils/test/test_transforms/test_hyperlinks.py =================================================================== --- trunk/docutils/test/test_transforms/test_hyperlinks.py 2005-09-11 21:53:02 UTC (rev 3869) +++ trunk/docutils/test/test_transforms/test_hyperlinks.py 2005-09-11 21:53:49 UTC (rev 3870) @@ -145,7 +145,7 @@ circular_ indirect reference <target ids="circular" names="circular" refid="circular"> - <problematic ids="id3" refid="id1"> + <problematic ids="id3 indirect" names="indirect" refid="id1"> .. _indirect: circular_ <system_message backrefs="id2 id3" ids="id1" level="3" line="3" source="test data" type="ERROR"> <paragraph> @@ -787,7 +787,7 @@ <document source="test data"> <paragraph> Duplicate manual footnote labels, with reference ( - <problematic ids="id5" refid="id4"> + <problematic ids="id5 id1" refid="id4"> [1]_ ): <footnote dupnames="1" ids="id2"> |