Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#1 stylesheet link w/ None

closed-fixed
David Goodger
None
5
2002-09-05
2002-09-04
Skip Montanaro
No

I'm trying to perform a straightforward conversion of the Python
Misc/NEWS file to ReST format. After clearing a couple errors, I
get this traceback when running the html.py script:

Traceback (most recent call last):
File "/home/skip/src/docutils-0.2/tools/html.py", line 22, in ?
publish(writer_name='html', description=description)
File "/usr/local/lib/python2.3/site-packages/docutils/core.py", line
160, in publish
pub.publish(argv, usage, description, option_spec)
File "/usr/local/lib/python2.3/site-packages/docutils/core.py", line
135, in publish
output = self.writer.write(document, self.destination)
File
"/usr/local/lib/python2.3/site-packages/docutils/writers/__init__.py",
line 58, in write
self.translate()
File
"/usr/local/lib/python2.3/site-packages/docutils/writers/html4css1.py",
line 47, in translate
visitor = self.translator_class(self.document)
File
"/usr/local/lib/python2.3/site-packages/docutils/writers/html4css1.py",
line 120, in __init__
options.stylesheet)]
File "/usr/local/lib/python2.3/site-packages/docutils/utils.py", line
359, in relative_uri
source_parts = os.path.abspath(source).split(os.sep)
File "/usr/local/lib/python2.3/posixpath.py", line 386, in abspath
if not isabs(path):
File "/usr/local/lib/python2.3/posixpath.py", line 37, in isabs
return s[:1] == '/'
TypeError: unsubscriptable object

I tracked it down to the setting of the stylesheet link in
html4css1.py/HTMLTranslator/__init__. If options._destination is
None, the relative_uri() call fails. I wormed around this by
checking that variable before assigning to self.head_prefix:

if options._destination is not None:
stylesheet_link % utils.relative_uri(options._destination,
options.stylesheet)
else:
stylesheet_link = ""
self.head_prefix = [
self.xml_declaration % options.output_encoding,
self.doctype,
self.html_head % options.language_code,
self.content_type % options.output_encoding,
self.generator,
stylesheet_link]

I was invoking html.py as

python html.py -v NEWS.rst

Discussion

  • David Goodger
    David Goodger
    2002-09-05

    • assigned_to: nobody --> goodger
    • status: open --> closed-fixed
     
  • David Goodger
    David Goodger
    2002-09-05

    Logged In: YES
    user_id=7733

    I hadn't recently tried a front end with STDOUT output
    (no second argument). Could it be that on Windows,
    where I probably tried it last, ``os.path.abspath(None)``
    works? Must check it out.

    The bug has been fixed at the source
    (docutils.utils.relative_uri). Thanks again!