Opened 13 years ago

Closed 13 years ago

#2134 defect closed fixed (fixed)

lore --output latex fails on span indexes

Reported by: DavidBlewett Owned by:
Priority: highest Milestone:
Component: lore Keywords:
Cc: Jean-Paul Calderone, ralphm Branch:
Author:

Description (last modified by Jean-Paul Calderone)

First, I'm on gentoo, using Twisted 2.4.0 and lore 0.2.0.

Lore's latex output fails on <span class="index" ... lines.

I was trying to generate a latex version of "How to Think Like a Computer Scientist", and got the traceback at the bottom of this description. It looks like the visitNOde_span_index function is missing a spitter object creation line. I checked over the whole file, and I don't see a IndexLatexSpitter, similar to FootnoteLatexSpitter. I'm not sure of the lore format, but I hacked together a bit from the chap01.lore file that illustrates the problem.

Traceback (most recent call last):       ] (chap01)
  File "/usr/bin/lore", line 21, in ?
    run()
  File "/usr/lib/python2.4/site-packages/twisted/lore/scripts/lore.py", line 150, in run
    result = runGivenOptions(opt)
  File "/usr/lib/python2.4/site-packages/twisted/lore/scripts/lore.py", line 132, in runGivenOptions
    walker.generate()
  File "/usr/lib/python2.4/site-packages/twisted/lore/process.py", line 53, in generate
    self.df(fullpath, linkrel)
  File "/usr/lib/python2.4/site-packages/twisted/lore/default.py", line 43, in <lambda>
    df = lambda file, linkrel: latex.convertFile(file, spitter)
  File "/usr/lib/python2.4/site-packages/twisted/lore/latex.py", line 453, in convertFile
    processFile(spitter, fin)
  File "/usr/lib/python2.4/site-packages/twisted/lore/latex.py", line 446, in processFile
    spitter.visitNode(dom)
  File "/usr/lib/python2.4/site-packages/twisted/lore/latex.py", line 70, in visitNode
    getattr(self, 'visitNode_'+node.tagName, self.visitNodeDefault)(node)
  File "/usr/lib/python2.4/site-packages/twisted/lore/latex.py", line 75, in visitNodeDefault
    self.visitNode(child)
  File "/usr/lib/python2.4/site-packages/twisted/lore/latex.py", line 70, in visitNode
    getattr(self, 'visitNode_'+node.tagName, self.visitNodeDefault)(node)
  File "/usr/lib/python2.4/site-packages/twisted/lore/latex.py", line 75, in visitNodeDefault
    self.visitNode(child)
  File "/usr/lib/python2.4/site-packages/twisted/lore/latex.py", line 70, in visitNode
    getattr(self, 'visitNode_'+node.tagName, self.visitNodeDefault)(node)
  File "/usr/lib/python2.4/site-packages/twisted/lore/latex.py", line 92, in visitNode_span
    self.visitNode(node)
  File "/usr/lib/python2.4/site-packages/twisted/lore/latex.py", line 70, in visitNode
    getattr(self, 'visitNode_'+node.tagName, self.visitNodeDefault)(node)
  File "/usr/lib/python2.4/site-packages/twisted/lore/latex.py", line 287, in visitNode_span_index
    spitter.visitNodeDefault(node)
NameError: global name 'spitter' is not defined

Attachments (1)

test.lore (1.3 KB) - added by DavidBlewett 13 years ago.
Small test file that illustrates the span index error.

Download all attachments as: .zip

Change History (11)

Changed 13 years ago by DavidBlewett

Attachment: test.lore added

Small test file that illustrates the span index error.

comment:1 Changed 13 years ago by Jean-Paul Calderone

Description: modified (diff)

comment:2 Changed 13 years ago by DavidBlewett

Link to suspect file:

source:/trunk/twisted/lore/latex.py@latest#L285

comment:3 Changed 13 years ago by DavidBlewett

comment:4 Changed 13 years ago by Jean-Paul Calderone

Cc: Jean-Paul Calderone added
Keywords: review added
Priority: normalhighest

Thanks for the example, it made tracking down the failure and writing the unit test very easy.

Fixed and ready for review in lore-latex-index-2134.

comment:5 Changed 13 years ago by Jean-Paul Calderone

Owner: spiv deleted

comment:6 Changed 13 years ago by ralphm

Cc: ralphm added
Keywords: review removed
Owner: set to Jean-Paul Calderone

trial yields the following errors for me:

twisted.lore.test.test_lore
  LatexSpitterTestCase
    test_indexedSpan ...                                                   [OK]
  TestFactory
    testProcessingFunctionFactory ...                                      [OK]
    testProcessingFunctionFactoryWithFilenameGenerator ...                 [OK]
    test_book ...                                                          [OK]
    test_doFile ...                                                     [ERROR]
    test_doFile_withFilenameGenerator ...                               [ERROR]
    test_getProcessor ...                                                  [OK]
    test_getProcessorWithFilenameGenerator ...                             [OK]
    test_indexAnchorsAdded ...                                          [ERROR]
    test_indexEntriesAdded ...                                             [OK]
    test_makeSureDirectoryExists ...                                       [OK]
    test_munge ...                                                      [ERROR]
    test_outputdirGenerator ...                                            [OK]
    test_outputdirGeneratorBadInput ...                                    [OK]
    test_runningLore ...                                                   [OK]
    test_runningLoreMultipleFiles ...                                      [OK]

===============================================================================
[ERROR]: twisted.lore.test.test_lore.TestFactory.test_doFile

Traceback (most recent call last):
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/test/test_lore.py", line 120, in test_doFile
    tree.doFile(self.file, self.linkrel, d['ext'], d['baseurl'], templ, d)
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/tree.py", line 363, in doFile
    url, options, outfileGenerator)
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/tree.py", line 334, in munge
    "body")[0]
exceptions.IndexError: list index out of range
===============================================================================
[ERROR]: twisted.lore.test.test_lore.TestFactory.test_doFile_withFilenameGenerator

Traceback (most recent call last):
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/test/test_lore.py", line 126, in test_doFile_withFilenameGenerator
    tree.doFile(self.file, self.linkrel, d['ext'], d['baseurl'], templ, d, filenameGenerator)
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/tree.py", line 363, in doFile
    url, options, outfileGenerator)
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/tree.py", line 334, in munge
    "body")[0]
exceptions.IndexError: list index out of range
===============================================================================
[ERROR]: twisted.lore.test.test_lore.TestFactory.test_indexAnchorsAdded

Traceback (most recent call last):
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/test/test_lore.py", line 186, in test_indexAnchorsAdded
    self.linkrel, '.html', d['baseurl'], templ, d)
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/tree.py", line 363, in doFile
    url, options, outfileGenerator)
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/tree.py", line 334, in munge
    "body")[0]
exceptions.IndexError: list index out of range
===============================================================================
[ERROR]: twisted.lore.test.test_lore.TestFactory.test_munge

Traceback (most recent call last):
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/test/test_lore.py", line 137, in test_munge
    d['ext'], d['baseurl'], d)
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/tree.py", line 303, in munge
    removeH1(document)
  File "/home/rmeijer/work/Twisted/branches/lore-latex-index-2134/twisted/lore/tree.py", line 148, in removeH1
    node.parentNode.replaceChild(empty, node)
  File "/usr/lib/python2.4/site-packages/_xmlplus/dom/minidom.py", line 134, in replaceChild
    if newChild.nodeType == self.DOCUMENT_FRAGMENT_NODE:
exceptions.AttributeError: 'Element' object has no attribute 'nodeType'
-------------------------------------------------------------------------------
Ran 16 tests in 0.496s

FAILED (errors=4, successes=12)

This might be related to your introduction of minidom. For example, for the last error, I see that the first argument to replaceChild (as a method of a minidom node) is a microdom node.

comment:7 Changed 13 years ago by Jean-Paul Calderone

Keywords: review added
Owner: Jean-Paul Calderone deleted

Reverted to microdom. Ugg. I'll try minidom in another five years, I guess. Tests all pass for me now.

comment:8 Changed 13 years ago by ralphm

Keywords: review removed
Owner: set to Jean-Paul Calderone

Tests pass for me, too, now. Glad you removed the * imports. Please merge.

comment:9 Changed 13 years ago by Jean-Paul Calderone

Resolution: fixed
Status: newclosed

(In [18416]) Merge lore-latex-index-2134

Author: exarkun Reviewer: ralphm Fixes #2134

Add test coverage for emitting latex for a span with an index class and fix that feature as well.

comment:10 Changed 8 years ago by <automation>

Owner: Jean-Paul Calderone deleted
Note: See TracTickets for help on using tickets.