summaryrefslogtreecommitdiff
path: root/sandbox/pobrien
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/pobrien')
-rw-r--r--sandbox/pobrien/LinuxFormat/LXFwriter.py984
-rw-r--r--sandbox/pobrien/LinuxFormat/__init__.py1
-rwxr-xr-xsandbox/pobrien/LinuxFormat/rest2lxf.py26
-rw-r--r--sandbox/pobrien/OpenOffice/OOdirectives.py77
-rw-r--r--sandbox/pobrien/OpenOffice/OOtext.py708
-rw-r--r--sandbox/pobrien/OpenOffice/OOwriter.py599
-rw-r--r--sandbox/pobrien/OpenOffice/__init__.py1
-rwxr-xr-xsandbox/pobrien/OpenOffice/rest2oo.py63
-rwxr-xr-xsandbox/pobrien/OpenOffice/rest2oopseudo.py24
-rwxr-xr-xsandbox/pobrien/OpenOffice/rest2ooxml.py27
-rw-r--r--sandbox/pobrien/WriterTemplate.py1081
-rw-r--r--sandbox/pobrien/dwArticle/__init__.py1
12 files changed, 0 insertions, 3592 deletions
diff --git a/sandbox/pobrien/LinuxFormat/LXFwriter.py b/sandbox/pobrien/LinuxFormat/LXFwriter.py
deleted file mode 100644
index 13e39d3d8..000000000
--- a/sandbox/pobrien/LinuxFormat/LXFwriter.py
+++ /dev/null
@@ -1,984 +0,0 @@
-"""Linux Format writer."""
-
-__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
-__cvsid__ = "$Id$"
-__revision__ = "$Revision$"[11:-2]
-
-
-__docformat__ = 'reStructuredText'
-
-
-import sys
-import os
-import time
-import re
-from types import ListType
-
-import docutils
-from docutils import nodes, utils, writers, languages
-
-
-class Writer(writers.Writer):
-
- supported = ('lxf', 'LinuxFormat')
- """Formats this writer supports."""
-
- output = None
- """Final translated form of `document`."""
-
- def __init__(self):
- writers.Writer.__init__(self)
- self.translator_class = Translator
-
- def translate(self):
- visitor = self.translator_class(self.document)
- self.document.walkabout(visitor)
- self.output = visitor.astext()
-
-
-class Translator(nodes.NodeVisitor):
- """Produces Linux Format Magazine output."""
-
- words_and_spaces = re.compile(r'\S+| +|\n')
-
- def __init__(self, document):
- nodes.NodeVisitor.__init__(self, document)
- self.settings = settings = document.settings
- lcode = settings.language_code
- self.language = languages.get_language(lcode)
- self.head = []
- self.body = []
- self.foot = []
- self.part = self.body
- self.section_level = 0
- self.context = []
- self.topic_class = ''
- self.colspecs = []
- self.compact_p = 1
- self.compact_simple = None
- self.in_bullet_list = False
- self.in_docinfo = False
- self.in_sidebar = False
- self.sidebar_start = False
- self.filterNewlines = True
-
- def astext(self):
- """Return the final formatted document as a string."""
- return ''.join(self.head + ['\n///BODY COPY START///'] +
- self.body + ['///END BODY COPY///\n'] + self.foot)
-
- def encode(self, text):
- if self.filterNewlines:
- text = text.replace('\n', ' ')
- return text
-
- def visit_Text(self, node):
- self.part.append(self.encode(node.astext()))
-
- def depart_Text(self, node):
- pass
-
- def visit_address(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'address', meta=None)
-
- def depart_address(self, node):
- self.depart_docinfo_item()
-
- def visit_admonition(self, node, name):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'div', CLASS=name))
- self.part.append('<p class="admonition-title">'
- + self.language.labels[name] + '</p>\n')
-
- def depart_admonition(self):
- raise NotImplementedError, node.astext()
- self.part.append('</div>\n')
-
- def visit_attention(self, node):
- self.visit_admonition(node, 'attention')
-
- def depart_attention(self, node):
- self.depart_admonition()
-
- def visit_author(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'author')
-
- def depart_author(self, node):
- self.depart_docinfo_item()
-
- def visit_authors(self, node):
- pass
-
- def depart_authors(self, node):
- pass
-
- def visit_block_quote(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'blockquote'))
-
- def depart_block_quote(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</blockquote>\n')
-
- def check_simple_list(self, node):
- raise NotImplementedError, node.astext()
- """Check for a simple list that can be rendered compactly."""
- visitor = SimpleListChecker(self.document)
- try:
- node.walk(visitor)
- except nodes.NodeFound:
- return None
- else:
- return 1
-
- def visit_bullet_list(self, node):
- self.in_bullet_list = True
-
- def depart_bullet_list(self, node):
- self.in_bullet_list = False
-
- def visit_caption(self, node):
- self.part.append('\n///CAPTION///')
- self.visit_paragraph(node)
-
- def depart_caption(self, node):
- self.depart_paragraph(node)
-
- def visit_caution(self, node):
- self.visit_admonition(node, 'caution')
-
- def depart_caution(self, node):
- self.depart_admonition()
-
- def visit_citation(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'table', CLASS='citation',
- frame="void", rules="none"))
- self.part.append('<colgroup><col class="label" /><col /></colgroup>\n'
- '<col />\n'
- '<tbody valign="top">\n'
- '<tr>')
- self.footnote_backrefs(node)
-
- def depart_citation(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</td></tr>\n'
- '</tbody>\n</table>\n')
-
- def visit_citation_reference(self, node):
- raise NotImplementedError, node.astext()
- href = ''
- if node.has_key('refid'):
- href = '#' + node['refid']
- elif node.has_key('refname'):
- href = '#' + self.document.nameids[node['refname']]
- self.part.append(self.starttag(node, 'a', '[', href=href,
- CLASS='citation-reference'))
-
- def depart_citation_reference(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(']</a>')
-
- def visit_classifier(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(' <span class="classifier-delimiter">:</span> ')
- self.part.append(self.starttag(node, 'span', '', CLASS='classifier'))
-
- def depart_classifier(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</span>')
-
- def visit_colspec(self, node):
- self.colspecs.append(node)
-
- def depart_colspec(self, node):
- pass
-
- def write_colspecs(self):
- raise NotImplementedError, node.astext()
- width = 0
- for node in self.colspecs:
- width += node['colwidth']
- for node in self.colspecs:
- colwidth = int(node['colwidth'] * 100.0 / width + 0.5)
- self.part.append(self.emptytag(node, 'col',
- width='%i%%' % colwidth))
- self.colspecs = []
-
- def visit_comment(self, node):
- raise nodes.SkipNode
-
- def visit_contact(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'contact', meta=None)
-
- def depart_contact(self, node):
- self.depart_docinfo_item()
-
- def visit_copyright(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'copyright')
-
- def depart_copyright(self, node):
- self.depart_docinfo_item()
-
- def visit_danger(self, node):
- self.visit_admonition(node, 'danger')
-
- def depart_danger(self, node):
- self.depart_admonition()
-
- def visit_date(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'date')
-
- def depart_date(self, node):
- self.depart_docinfo_item()
-
- def visit_decoration(self, node):
- pass
-
- def depart_decoration(self, node):
- pass
-
- def visit_definition(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</dt>\n')
- self.part.append(self.starttag(node, 'dd', ''))
- if len(node):
- node[0].set_class('first')
- node[-1].set_class('last')
-
- def depart_definition(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</dd>\n')
-
- def visit_definition_list(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'dl'))
-
- def depart_definition_list(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</dl>\n')
-
- def visit_definition_list_item(self, node):
- pass
-
- def depart_definition_list_item(self, node):
- pass
-
- def visit_description(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'td', ''))
- if len(node):
- node[0].set_class('first')
- node[-1].set_class('last')
-
- def depart_description(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</td>')
-
- def visit_docinfo(self, node):
- self.in_docinfo = True
-
- def depart_docinfo(self, node):
- self.in_docinfo = False
-
- def visit_docinfo_item(self, node, name, meta=1):
- raise NotImplementedError, node.astext()
- if meta:
- self.head.append('<meta name="%s" content="%s" />\n'
- % (name, self.attval(node.astext())))
- self.part.append(self.starttag(node, 'tr', ''))
- self.part.append('<th class="docinfo-name">%s:</th>\n<td>'
- % self.language.labels[name])
- if len(node):
- if isinstance(node[0], nodes.Element):
- node[0].set_class('first')
- if isinstance(node[0], nodes.Element):
- node[-1].set_class('last')
-
- def depart_docinfo_item(self):
- raise NotImplementedError, node.astext()
- self.part.append('</td></tr>\n')
-
- def visit_doctest_block(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'pre', CLASS='doctest-block'))
-
- def depart_doctest_block(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('\n</pre>\n')
-
- def visit_document(self, node):
- pass
-
- def depart_document(self, node):
- pass
-
- def visit_emphasis(self, node):
- self.part.append('/')
-
- def depart_emphasis(self, node):
- self.part.append('/')
-
- def visit_entry(self, node):
- raise NotImplementedError, node.astext()
- if isinstance(node.parent.parent, nodes.thead):
- tagname = 'th'
- else:
- tagname = 'td'
- atts = {}
- if node.has_key('morerows'):
- atts['rowspan'] = node['morerows'] + 1
- if node.has_key('morecols'):
- atts['colspan'] = node['morecols'] + 1
- self.part.append(self.starttag(node, tagname, '', **atts))
- self.context.append('</%s>\n' % tagname.lower())
- if len(node) == 0: # empty cell
- self.part.append('&nbsp;')
- else:
- node[0].set_class('first')
- node[-1].set_class('last')
-
- def depart_entry(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.context.pop())
-
- def visit_enumerated_list(self, node):
- raise NotImplementedError, node.astext()
- """
- The 'start' attribute does not conform to HTML 4.01's strict.dtd, but
- CSS1 doesn't help. CSS2 isn't widely enough supported yet to be
- usable.
- """
- atts = {}
- if node.has_key('start'):
- atts['start'] = node['start']
- if node.has_key('enumtype'):
- atts['class'] = node['enumtype']
- # @@@ To do: prefix, suffix. How? Change prefix/suffix to a
- # single "format" attribute? Use CSS2?
- old_compact_simple = self.compact_simple
- self.context.append((self.compact_simple, self.compact_p))
- self.compact_p = None
- self.compact_simple = (self.settings.compact_lists and
- (self.compact_simple
- or self.topic_class == 'contents'
- or self.check_simple_list(node)))
- if self.compact_simple and not old_compact_simple:
- atts['class'] = (atts.get('class', '') + ' simple').strip()
- self.part.append(self.starttag(node, 'ol', **atts))
-
- def depart_enumerated_list(self, node):
- raise NotImplementedError, node.astext()
- self.compact_simple, self.compact_p = self.context.pop()
- self.part.append('</ol>\n')
-
- def visit_error(self, node):
- self.visit_admonition(node, 'error')
-
- def depart_error(self, node):
- self.depart_admonition()
-
- def visit_field(self, node):
- if self.in_docinfo:
- self.part = self.foot
-
- def depart_field(self, node):
- self.part = self.body
-
- def visit_field_body(self, node):
- pass
-
- def depart_field_body(self, node):
- pass
-
- def visit_field_list(self, node):
- raise NotImplementedError, node.astext()
-
- def depart_field_list(self, node):
- raise NotImplementedError, node.astext()
-
- def visit_field_name(self, node):
- if self.in_docinfo and node.astext() == 'Next':
- self.part.append('\n\n///NEXT MONTH///')
- raise nodes.SkipNode
- else:
- raise NotImplementedError, node.astext()
-
- def depart_field_name(self, node):
- pass
-
- def visit_figure(self, node):
- self.part = self.foot
- self.part.append('\n\n///PIC///\n')
-
- def depart_figure(self, node):
- self.part = self.body
-
- def visit_footer(self, node):
- raise NotImplementedError, node.astext()
- self.context.append(len(self.part))
-
- def depart_footer(self, node):
- raise NotImplementedError, node.astext()
- start = self.context.pop()
- footer = (['<hr class="footer"/>\n',
- self.starttag(node, 'div', CLASS='footer')]
- + self.part[start:] + ['</div>\n'])
- self.body_suffix[:0] = footer
- del self.part[start:]
-
- def visit_footnote(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'table', CLASS='footnote',
- frame="void", rules="none"))
- self.part.append('<colgroup><col class="label" /><col /></colgroup>\n'
- '<tbody valign="top">\n'
- '<tr>')
- self.footnote_backrefs(node)
-
- def footnote_backrefs(self, node):
- raise NotImplementedError, node.astext()
- if self.settings.footnote_backlinks and node.hasattr('backrefs'):
- backrefs = node['backrefs']
- if len(backrefs) == 1:
- self.context.append('')
- self.context.append('<a class="fn-backref" href="#%s" '
- 'name="%s">' % (backrefs[0], node['id']))
- else:
- i = 1
- backlinks = []
- for backref in backrefs:
- backlinks.append('<a class="fn-backref" href="#%s">%s</a>'
- % (backref, i))
- i += 1
- self.context.append('<em>(%s)</em> ' % ', '.join(backlinks))
- self.context.append('<a name="%s">' % node['id'])
- else:
- self.context.append('')
- self.context.append('<a name="%s">' % node['id'])
-
- def depart_footnote(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</td></tr>\n'
- '</tbody>\n</table>\n')
-
- def visit_footnote_reference(self, node):
- raise NotImplementedError, node.astext()
- href = ''
- if node.has_key('refid'):
- href = '#' + node['refid']
- elif node.has_key('refname'):
- href = '#' + self.document.nameids[node['refname']]
- format = self.settings.footnote_references
- if format == 'brackets':
- suffix = '['
- self.context.append(']')
- elif format == 'superscript':
- suffix = '<sup>'
- self.context.append('</sup>')
- else: # shouldn't happen
- suffix = '???'
- self.content.append('???')
- self.part.append(self.starttag(node, 'a', suffix, href=href,
- CLASS='footnote-reference'))
-
- def depart_footnote_reference(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.context.pop() + '</a>')
-
- def visit_generated(self, node):
- pass
-
- def depart_generated(self, node):
- pass
-
- def visit_header(self, node):
- raise NotImplementedError, node.astext()
- self.context.append(len(self.part))
-
- def depart_header(self, node):
- raise NotImplementedError, node.astext()
- start = self.context.pop()
- self.body_prefix.append(self.starttag(node, 'div', CLASS='header'))
- self.body_prefix.extend(self.part[start:])
- self.body_prefix.append('<hr />\n</div>\n')
- del self.part[start:]
-
- def visit_hint(self, node):
- self.visit_admonition(node, 'hint')
-
- def depart_hint(self, node):
- self.depart_admonition()
-
- def visit_image(self, node):
- name = str(node.attributes['uri'])
- self.part.append(name)
- pass
-
- def depart_image(self, node):
- pass
-
- def visit_important(self, node):
- self.visit_admonition(node, 'important')
-
- def depart_important(self, node):
- self.depart_admonition()
-
- def visit_label(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'td', '%s[' % self.context.pop(),
- CLASS='label'))
-
- def depart_label(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(']</a></td><td>%s' % self.context.pop())
-
- def visit_legend(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'div', CLASS='legend'))
-
- def depart_legend(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</div>\n')
-
- def visit_line_block(self, node):
- raise NotImplementedError, node.astext()
-
- def depart_line_block(self, node):
- raise NotImplementedError, node.astext()
-
- def visit_list_item(self, node):
- if self.in_bullet_list:
- self.part.append('\n* ')
-
- def depart_list_item(self, node):
- pass
-
- def visit_literal(self, node):
- self.part.append('///code///')
-
- def depart_literal(self, node):
- self.part.append('///code ends///')
-
- def visit_literal_block(self, node):
- self.part.append('\n///CODE///\n')
- self.filterNewlines = False
-
- def depart_literal_block(self, node):
- self.part.append('\n///END CODE///\n')
- self.filterNewlines = True
-
- def visit_meta(self, node):
- raise NotImplementedError, node.astext()
- self.head.append(self.emptytag(node, 'meta', **node.attributes))
-
- def depart_meta(self, node):
- pass
-
- def visit_note(self, node):
- self.visit_admonition(node, 'note')
-
- def depart_note(self, node):
- self.depart_admonition()
-
- def visit_option(self, node):
- raise NotImplementedError, node.astext()
- if self.context[-1]:
- self.part.append(', ')
-
- def depart_option(self, node):
- raise NotImplementedError, node.astext()
- self.context[-1] += 1
-
- def visit_option_argument(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(node.get('delimiter', ' '))
- self.part.append(self.starttag(node, 'var', ''))
-
- def depart_option_argument(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</var>')
-
- def visit_option_group(self, node):
- raise NotImplementedError, node.astext()
- atts = {}
- if len(node.astext()) > 14:
- atts['colspan'] = 2
- self.context.append('</tr>\n<tr><td>&nbsp;</td>')
- else:
- self.context.append('')
- self.part.append(self.starttag(node, 'td', **atts))
- self.part.append('<kbd>')
- self.context.append(0) # count number of options
-
- def depart_option_group(self, node):
- raise NotImplementedError, node.astext()
- self.context.pop()
- self.part.append('</kbd></td>\n')
- self.part.append(self.context.pop())
-
- def visit_option_list(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(
- self.starttag(node, 'table', CLASS='option-list',
- frame="void", rules="none"))
- self.part.append('<col class="option" />\n'
- '<col class="description" />\n'
- '<tbody valign="top">\n')
-
- def depart_option_list(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</tbody>\n</table>\n')
-
- def visit_option_list_item(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'tr', ''))
-
- def depart_option_list_item(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</tr>\n')
-
- def visit_option_string(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'span', '', CLASS='option'))
-
- def depart_option_string(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</span>')
-
- def visit_organization(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'organization')
-
- def depart_organization(self, node):
- raise NotImplementedError, node.astext()
- self.depart_docinfo_item()
-
- def visit_paragraph(self, node):
- if self.in_sidebar and self.sidebar_start:
- self.part.append('///BOX BODY///')
- self.sidebar_start = False
- if not self.in_bullet_list:
- self.part.append('\n')
-
- def depart_paragraph(self, node):
- self.part.append('\n')
-
- def visit_problematic(self, node):
- raise NotImplementedError, node.astext()
- if node.hasattr('refid'):
- self.part.append('<a href="#%s" name="%s">' % (node['refid'],
- node['id']))
- self.context.append('</a>')
- else:
- self.context.append('')
- self.part.append(self.starttag(node, 'span', '', CLASS='problematic'))
-
- def depart_problematic(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</span>')
- self.part.append(self.context.pop())
-
- def visit_raw(self, node):
- raise NotImplementedError, node.astext()
- if node.get('format') == 'html':
- self.part.append(node.astext())
- # Keep non-HTML raw text out of output:
- raise nodes.SkipNode
-
- def visit_reference(self, node):
- pass
-
- def depart_reference(self, node):
- pass
-
- def visit_revision(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'revision', meta=None)
-
- def depart_revision(self, node):
- self.depart_docinfo_item()
-
- def visit_row(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'tr', ''))
-
- def depart_row(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</tr>\n')
-
- def visit_section(self, node):
- self.section_level += 1
-
- def depart_section(self, node):
- self.section_level -= 1
-
- def visit_sidebar(self, node):
- self.part = self.foot
- self.in_sidebar = True
- self.sidebar_start = True
- self.part.append('\n\n///BOXOUT///\n')
-
- def depart_sidebar(self, node):
- self.part.append('///END BOX BODY///\n')
- self.in_sidebar = False
- self.part = self.body
-
- def visit_status(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'status', meta=None)
-
- def depart_status(self, node):
- self.depart_docinfo_item()
-
- def visit_strong(self, node):
- self.part.append('*')
-
- def depart_strong(self, node):
- self.part.append('*')
-
- def visit_substitution_definition(self, node):
- """Internal only."""
- raise nodes.SkipNode
-
- def visit_substitution_reference(self, node):
- self.unimplemented_visit(node)
-
- def visit_subtitle(self, node):
- if self.in_sidebar:
- self.part.append('///BOXOUT SUBHEAD///\n')
- else:
- self.part = self.head
- self.part.append('\n///DESCRIPTION///\n')
-
- def depart_subtitle(self, node):
- self.part.append('\n')
- if self.in_sidebar:
- pass
- else:
- self.part = self.body
-
- def visit_system_message(self, node):
- raise NotImplementedError, node.astext()
- if node['level'] < self.document.reporter['writer'].report_level:
- # Level is too low to display:
- raise nodes.SkipNode
- self.part.append(self.starttag(node, 'div', CLASS='system-message'))
- self.part.append('<p class="system-message-title">')
- attr = {}
- backref_text = ''
- if node.hasattr('id'):
- attr['name'] = node['id']
- if node.hasattr('backrefs'):
- backrefs = node['backrefs']
- if len(backrefs) == 1:
- backref_text = ('; <em><a href="#%s">backlink</a></em>'
- % backrefs[0])
- else:
- i = 1
- backlinks = []
- for backref in backrefs:
- backlinks.append('<a href="#%s">%s</a>' % (backref, i))
- i += 1
- backref_text = ('; <em>backlinks: %s</em>'
- % ', '.join(backlinks))
- if node.hasattr('line'):
- line = ', line %s' % node['line']
- else:
- line = ''
- if attr:
- a_start = self.starttag({}, 'a', '', **attr)
- a_end = '</a>'
- else:
- a_start = a_end = ''
- self.part.append('System Message: %s%s/%s%s (<tt>%s</tt>%s)%s</p>\n'
- % (a_start, node['type'], node['level'], a_end,
- node['source'], line, backref_text))
-
- def depart_system_message(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</div>\n')
-
- def visit_table(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(
- self.starttag(node, 'table', CLASS="table",
- frame='border', rules='all'))
-
- def depart_table(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</table>\n')
-
- def visit_target(self, node):
- raise NotImplementedError, node.astext()
- if not (node.has_key('refuri') or node.has_key('refid')
- or node.has_key('refname')):
- self.part.append(self.starttag(node, 'a', '', CLASS='target'))
- self.context.append('</a>')
- else:
- self.context.append('')
-
- def depart_target(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.context.pop())
-
- def visit_tbody(self, node):
- raise NotImplementedError, node.astext()
- self.write_colspecs()
- self.part.append(self.context.pop()) # '</colgroup>\n' or ''
- self.part.append(self.starttag(node, 'tbody', valign='top'))
-
- def depart_tbody(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</tbody>\n')
-
- def visit_term(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'dt', ''))
-
- def depart_term(self, node):
- """
- Leave the end tag to `self.visit_definition()`, in case there's a
- classifier.
- """
- raise NotImplementedError, node.astext()
- pass
-
- def visit_tgroup(self, node):
- raise NotImplementedError, node.astext()
- # Mozilla needs <colgroup>:
- self.part.append(self.starttag(node, 'colgroup'))
- # Appended by thead or tbody:
- self.context.append('</colgroup>\n')
-
- def depart_tgroup(self, node):
- pass
-
- def visit_thead(self, node):
- raise NotImplementedError, node.astext()
- self.write_colspecs()
- self.part.append(self.context.pop()) # '</colgroup>\n'
- # There may or may not be a <thead>; this is for <tbody> to use:
- self.context.append('')
- self.part.append(self.starttag(node, 'thead', valign='bottom'))
-
- def depart_thead(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</thead>\n')
-
- def visit_tip(self, node):
- self.visit_admonition(node, 'tip')
-
- def depart_tip(self, node):
- self.depart_admonition()
-
- def visit_title(self, node):
- """Only 2 section levels are supported."""
- if isinstance(node.parent, nodes.topic):
- if self.topic_class == 'abstract':
- self.part = self.head
- self.part.append('\n///STRAP///')
- raise nodes.SkipNode
- elif self.in_sidebar:
- # sidebar title
- self.part.append('///BOXOUT HEAD///\n')
- elif self.section_level == 0:
- # document title
- self.part = self.head
- self.part.append('///TITLE///\n')
- else:
- self.part.append('\n///CROSSHEAD///\n')
-
- def depart_title(self, node):
- self.part.append('\n')
- if not self.in_sidebar:
- self.part = self.body
-
- def visit_title_reference(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.starttag(node, 'cite', ''))
-
- def depart_title_reference(self, node):
- raise NotImplementedError, node.astext()
- self.part.append('</cite>')
-
- def visit_topic(self, node):
- self.topic_class = node.get('class')
-
- def depart_topic(self, node):
- self.topic_class = ''
- self.part = self.body
-
- def visit_transition(self, node):
- raise NotImplementedError, node.astext()
- self.part.append(self.emptytag(node, 'hr'))
-
- def depart_transition(self, node):
- pass
-
- def visit_version(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'version', meta=None)
-
- def depart_version(self, node):
- self.depart_docinfo_item()
-
- def visit_warning(self, node):
- self.visit_admonition(node, 'warning')
-
- def depart_warning(self, node):
- self.depart_admonition()
-
- def unimplemented_visit(self, node):
- raise NotImplementedError('visiting unimplemented node type: %s'
- % node.__class__.__name__)
-
-
-class SimpleListChecker(nodes.GenericNodeVisitor):
-
- """
- Raise `nodes.SkipNode` if non-simple list item is encountered.
-
- Here "simple" means a list item containing nothing other than a single
- paragraph, a simple list, or a paragraph followed by a simple list.
- """
-
- def default_visit(self, node):
- raise nodes.NodeFound
-
- def visit_bullet_list(self, node):
- pass
-
- def visit_enumerated_list(self, node):
- pass
-
- def visit_list_item(self, node):
- children = []
- for child in node.get_children():
- if not isinstance(child, nodes.Invisible):
- children.append(child)
- if (children and isinstance(children[0], nodes.paragraph)
- and (isinstance(children[-1], nodes.bullet_list)
- or isinstance(children[-1], nodes.enumerated_list))):
- children.pop()
- if len(children) <= 1:
- return
- else:
- raise nodes.NodeFound
-
- def visit_paragraph(self, node):
- raise nodes.SkipNode
-
- def invisible_visit(self, node):
- """Invisible nodes should be ignored."""
- pass
-
- visit_comment = invisible_visit
- visit_substitution_definition = invisible_visit
- visit_target = invisible_visit
- visit_pending = invisible_visit
diff --git a/sandbox/pobrien/LinuxFormat/__init__.py b/sandbox/pobrien/LinuxFormat/__init__.py
deleted file mode 100644
index db6003cf3..000000000
--- a/sandbox/pobrien/LinuxFormat/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# Orbtech python package. \ No newline at end of file
diff --git a/sandbox/pobrien/LinuxFormat/rest2lxf.py b/sandbox/pobrien/LinuxFormat/rest2lxf.py
deleted file mode 100755
index 720cc3a0a..000000000
--- a/sandbox/pobrien/LinuxFormat/rest2lxf.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python
-
-"""Generates Linux Format articles."""
-
-__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
-__cvsid__ = "$Id$"
-__revision__ = "$Revision$"[11:-2]
-
-import locale
-try:
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-from docutils.core import publish_cmdline, default_description
-
-from LXFwriter import Writer
-
-
-def main():
- description = ("Generates Linux Format articles. " + default_description)
- publish_cmdline(writer=Writer(), description=description)
-
-
-if __name__ == '__main__':
- main()
diff --git a/sandbox/pobrien/OpenOffice/OOdirectives.py b/sandbox/pobrien/OpenOffice/OOdirectives.py
deleted file mode 100644
index 5cf89b459..000000000
--- a/sandbox/pobrien/OpenOffice/OOdirectives.py
+++ /dev/null
@@ -1,77 +0,0 @@
-"""Custom directives"""
-
-__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
-__cvsid__ = "$Id$"
-__revision__ = "$Revision$"[11:-2]
-
-import sys
-import os
-
-from docutils import nodes
-from docutils.parsers.rst import directives
-from docutils.parsers.rst.languages import en
-
-registry = directives._directive_registry
-registry['index'] = ('OOdirectives', 'index_directive')
-registry['include-code'] = ('OOdirectives', 'include_code')
-registry['include-output'] = ('OOdirectives', 'include_output')
-
-en.directives['index'] = 'index'
-en.directives['include-code'] = 'include-code'
-en.directives['include-output'] = 'include-output'
-
-
-#class index_entry(nodes.General, nodes.Element): pass
-class index_entry(nodes.Inline, nodes.TextElement): pass
-
-
-def index_directive(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- #nodes = []
- #for entry in content:
- # nodes.append(index_entry(entry, entry))
- #return nodes
- entries = '\n'.join(content)
- return [index_entry(entries,entries)]
-
-index_directive.content = 1
-
-
-def include_code(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- #obj = state_machine.document.attributes
- #print >> sys.stderr, obj
- #print >> sys.stderr, dir(obj)
- document = state_machine.document
- dirname = getDocDir(document)
- fname = os.path.join(dirname, arguments[0])
- code = open(fname).read()
- return [nodes.literal_block(code, code)]
-
-include_code.arguments = (0, 1, 0)
-
-
-def include_output(name, arguments, options, content, lineno,
- content_offset, block_text, state, state_machine):
- document = state_machine.document
- dirname = getDocDir(document)
- fname = os.path.join(dirname, arguments[0])
- cmd = os.environ['PYTHON'] + ' ' + fname
- f_input, f_output = os.popen4(cmd)
- output = f_output.read()
- f_output.close()
- return [nodes.literal_block(output, output)]
-
-include_output.arguments = (0, 1, 0)
-
-
-def getDocDir(document):
- source = document.current_source
- if source is None:
- return os.getcwd()
- else:
- dirname = os.path.dirname(os.path.abspath(source))
- if dirname is None:
- return os.getcwd()
- else:
- return dirname
diff --git a/sandbox/pobrien/OpenOffice/OOtext.py b/sandbox/pobrien/OpenOffice/OOtext.py
deleted file mode 100644
index b5b20dbdf..000000000
--- a/sandbox/pobrien/OpenOffice/OOtext.py
+++ /dev/null
@@ -1,708 +0,0 @@
-"""Text used in the creation of the XML files."""
-
-__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
-__cvsid__ = "$Id$"
-__revision__ = "$Revision$"[11:-2]
-
-
-# Can't have blank line at beginning of XML
-
-manifest = '''<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE manifest:manifest PUBLIC "-//OpenOffice.org//DTD Manifest 1.0//EN" "Manifest.dtd">
-<manifest:manifest xmlns:manifest="http://openoffice.org/2001/manifest">
-<manifest:file-entry manifest:media-type="application/vnd.sun.xml.writer" manifest:full-path="/"/>
-%s
-%s
-</manifest:manifest>
-'''
-
-# The pictures list gets populated by OOwriter as it comes across
-# images in the document.
-pictures = []
-
-m_xml_format = '<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="%s"/>'
-
-m_tif_format = '<manifest:file-entry manifest:media-type="image/tif" manifest:full-path="Pictures/%s"/>'
-
-m_png_format = '<manifest:file-entry manifest:media-type="image/png" manifest:full-path="Pictures/%s"/>'
-
-content_header = '''<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE office:document-content PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "office.dtd">
-<office:document-content
-xmlns:office="http://openoffice.org/2000/office"
-xmlns:style="http://openoffice.org/2000/style"
-xmlns:text="http://openoffice.org/2000/text"
-xmlns:table="http://openoffice.org/2000/table"
-xmlns:draw="http://openoffice.org/2000/drawing"
-xmlns:fo="http://www.w3.org/1999/XSL/Format"
-xmlns:xlink="http://www.w3.org/1999/xlink"
-xmlns:number="http://openoffice.org/2000/datastyle"
-xmlns:svg="http://www.w3.org/2000/svg"
-xmlns:chart="http://openoffice.org/2000/chart"
-xmlns:dr3d="http://openoffice.org/2000/dr3d"
-xmlns:math="http://www.w3.org/1998/Math/MathML"
-xmlns:form="http://openoffice.org/2000/form"
-xmlns:script="http://openoffice.org/2000/script" office:class="text"
-office:version="1.0">
-<office:body>
-<text:sequence-decls>
-<text:sequence-decl text:display-outline-level="0" text:name="Illustration"/>
-<text:sequence-decl text:display-outline-level="0" text:name="Table"/>
-<text:sequence-decl text:display-outline-level="0" text:name="Text"/>
-<text:sequence-decl text:display-outline-level="0" text:name="Drawing"/>
-</text:sequence-decls>
-'''
-
-content_footer = '''
-</office:body>
-</office:document-content>
-'''
-
-styles = '''<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE office:document-styles PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "office.dtd">
-
-<office:document-styles
-xmlns:office="http://openoffice.org/2000/office"
-xmlns:style="http://openoffice.org/2000/style"
-xmlns:text="http://openoffice.org/2000/text"
-xmlns:table="http://openoffice.org/2000/table"
-xmlns:draw="http://openoffice.org/2000/drawing"
-xmlns:fo="http://www.w3.org/1999/XSL/Format"
-xmlns:xlink="http://www.w3.org/1999/xlink"
-xmlns:number="http://openoffice.org/2000/datastyle"
-xmlns:svg="http://www.w3.org/2000/svg"
-xmlns:chart="http://openoffice.org/2000/chart"
-xmlns:dr3d="http://openoffice.org/2000/dr3d"
-xmlns:math="http://www.w3.org/1998/Math/MathML"
-xmlns:form="http://openoffice.org/2000/form"
-xmlns:script="http://openoffice.org/2000/script"
-office:version="1.0">
-
-<office:font-decls>
-
-<style:font-decl style:name="Wingdings"
-fo:font-family="Wingdings"
-style:font-pitch="variable"
-style:font-charset="x-symbol"/>
-<style:font-decl style:name="Palatino"
-fo:font-family="Palatino"/>
-<style:font-decl style:name="Courier"
-fo:font-family="Courier"
-style:font-family-generic="modern"/>
-<style:font-decl style:name="Arial Unicode MS"
-fo:font-family="&apos;Arial Unicode MS&apos;"
-style:font-pitch="variable"/>
-<style:font-decl style:name="HG Mincho Light J"
-fo:font-family="&apos;HG Mincho Light J&apos;"
-style:font-pitch="variable"/>
-<style:font-decl style:name="AGaramond"
-fo:font-family="AGaramond"
-style:font-family-generic="roman"
-style:font-pitch="variable"/>
-<style:font-decl style:name="AGaramond Bold"
-fo:font-family="&apos;AGaramond Bold&apos;"
-style:font-family-generic="roman"
-style:font-pitch="variable"/>
-<style:font-decl style:name="Times"
-fo:font-family="Times"
-style:font-family-generic="roman"
-style:font-pitch="variable"/>
-<style:font-decl style:name="Times New Roman"
-fo:font-family="&apos;Times New Roman&apos;"
-style:font-family-generic="roman"
-style:font-pitch="variable"/>
-<style:font-decl style:name="Arial"
-fo:font-family="Arial"
-style:font-family-generic="swiss"
-style:font-pitch="variable"/>
-<style:font-decl style:name="Helvetica"
-fo:font-family="Helvetica"
-style:font-family-generic="swiss"
-style:font-pitch="variable"/>
-<style:font-decl style:name="Helvetica-Narrow"
-fo:font-family="Helvetica-Narrow"
-style:font-family-generic="swiss"
-style:font-pitch="variable"/>
-<style:font-decl style:name="Humanst521 Cn BT"
-fo:font-family="&apos;Humanst521 Cn BT&apos;"
-style:font-family-generic="swiss"
-style:font-pitch="variable"/>
-<style:font-decl style:name="Luxi Sans"
-fo:font-family="&apos;Luxi Sans&apos;"
-style:font-family-generic="swiss"
-style:font-pitch="variable"/>
-<style:font-decl style:name="Tahoma"
-fo:font-family="Tahoma"
-style:font-family-generic="swiss"
-style:font-pitch="variable"/>
-<style:font-decl style:name="Univers 45 Light"
-fo:font-family="&apos;Univers 45 Light&apos;"
-style:font-family-generic="swiss"
-style:font-pitch="variable"/>
-
-</office:font-decls>
-<office:styles>
-
-
-<style:default-style style:family="graphics">
-<style:properties draw:start-line-spacing-horizontal="0.1114inch"
-draw:start-line-spacing-vertical="0.1114inch"
-draw:end-line-spacing-horizontal="0.1114inch"
-draw:end-line-spacing-vertical="0.1114inch" fo:color="#000000"
-style:font-name="Palatino" fo:font-size="12pt" fo:language="en"
-fo:country="US" style:font-name-asian="HG Mincho Light J"
-style:font-size-asian="12pt" style:language-asian="none"
-style:country-asian="none" style:font-name-complex="Arial Unicode MS"
-style:font-size-complex="12pt" style:language-complex="none"
-style:country-complex="none" style:text-autospace="ideograph-alpha"
-style:punctuation-wrap="simple" style:line-break="strict">
-<style:tab-stops/></style:properties></style:default-style>
-
-<style:default-style style:family="paragraph">
-<style:properties fo:color="#000000" style:font-name="Palatino"
-fo:font-size="12pt" fo:language="en" fo:country="US"
-style:font-name-asian="HG Mincho Light J" style:font-size-asian="12pt"
-style:language-asian="none" style:country-asian="none"
-style:font-name-complex="Arial Unicode MS"
-style:font-size-complex="12pt" style:language-complex="none"
-style:country-complex="none" fo:hyphenate="false"
-fo:hyphenation-remain-char-count="2"
-fo:hyphenation-push-char-count="2"
-fo:hyphenation-ladder-count="no-limit"
-style:text-autospace="ideograph-alpha"
-style:punctuation-wrap="hanging" style:line-break="strict"
-style:tab-stop-distance="0.5inch"/></style:default-style>
-
-<style:style style:name="Standard"
-style:family="paragraph"
-style:class="text">
-<style:properties fo:color="#000000"
-style:font-name="Times New Roman" fo:font-size="10pt" fo:language="en"
-fo:country="US" style:font-name-asian="Times New Roman"
-style:font-size-asian="10pt" fo:orphans="2"
-fo:widows="2"/></style:style>
-
-<style:style style:name="Text body"
-style:family="paragraph"
-style:parent-style-name="Standard"
-style:class="text">
-<style:properties fo:margin-top="0inch"
-fo:margin-bottom="0.0835inch"/></style:style>
-
-<style:style style:name="Header"
-style:family="paragraph"
-style:parent-style-name="Standard"
-style:class="extra">
-<style:properties>
-<style:tab-stops>
-<style:tab-stop
-style:position="3inch" style:type="center"/>
-<style:tab-stop
-style:position="6inch"
-style:type="right"/></style:tab-stops></style:properties></style:style>
-
-<style:style style:name="Footer"
-style:family="paragraph"
-style:parent-style-name="Standard"
-style:class="extra">
-<style:properties fo:color="#000000"
-style:font-name="AGaramond">
-<style:tab-stops>
-<style:tab-stop
-style:position="3inch" style:type="center"/>
-<style:tab-stop
-style:position="6inch"
-style:type="right"/></style:tab-stops></style:properties></style:style>
-
-<style:style style:name="Table Contents"
-style:family="paragraph"
-style:parent-style-name="Text body"
-style:class="extra">
-<style:properties text:number-lines="false"
-text:line-number="0"/></style:style>
-
-<style:style style:name="Table
-Heading" style:family="paragraph"
-style:parent-style-name="Table Contents"
-style:class="extra">
-<style:properties fo:font-style="italic"
-fo:font-weight="bold" style:font-style-asian="italic"
-style:font-weight-asian="bold" style:font-style-complex="italic"
-style:font-weight-complex="bold" fo:text-align="center"
-style:justify-single-word="false" text:number-lines="false"
-text:line-number="0"/></style:style>
-
-<style:style style:name="Caption"
-style:family="paragraph"
-style:parent-style-name="Standard"
-style:class="extra">
-<style:properties fo:margin-top="0.0835inch"
-fo:margin-bottom="0.0835inch" style:font-name="Palatino"
-fo:font-size="10pt" fo:font-style="italic"
-style:font-size-asian="10pt" style:font-style-asian="italic"
-style:font-size-complex="10pt" style:font-style-complex="italic"
-text:number-lines="false"
-text:line-number="0"/></style:style>
-
-<style:style style:name="Frame contents"
-style:family="paragraph"
-style:parent-style-name="Text body"
-style:class="extra"/>
-<style:style style:name="Index"
-style:family="paragraph" style:parent-style-name="Standard"
-style:class="index">
-<style:properties style:font-name="Palatino"
-text:number-lines="false"
-text:line-number="0"/></style:style>
-
-<style:style style:name="code"
-style:family="text">
-<style:properties style:font-name="Courier"/></style:style>
-
-<style:style style:name=".body"
-style:family="paragraph">
-<style:properties fo:margin-left="0inch"
-fo:margin-right="0inch" fo:margin-top="0inch" fo:margin-bottom="0inch"
-fo:color="#000000" style:font-name="AGaramond" fo:font-size="11pt"
-fo:language="en" fo:country="US" style:font-name-asian="Times New
-Roman" style:font-size-asian="11pt" fo:line-height="0.1937inch"
-fo:text-align="justify" style:justify-single-word="false"
-fo:orphans="2" fo:widows="2" fo:text-indent="0.25inch"
-style:auto-text-indent="false">
-<style:tab-stops/></style:properties></style:style>
-
-<style:style style:name=".body1"
-style:family="paragraph"
-style:parent-style-name=".body"
-style:next-style-name=".body">
-<style:properties fo:margin-left="0inch"
-fo:margin-right="0inch" fo:font-size="11pt"
-style:font-size-asian="11pt" fo:text-indent="0inch"
-style:auto-text-indent="false"/></style:style>
-
-<style:style style:name=".bullet"
-style:family="paragraph"
-style:list-style-name="BulletList">
-<style:properties
-fo:margin-left="0.5inch"
-fo:margin-right="0inch"
-fo:margin-top="0.028inch"
-fo:margin-bottom="0.028inch"
-fo:color="#000000"
-style:font-name="AGaramond"
-fo:font-size="11pt"
-fo:language="en"
-fo:country="US"
-style:font-name-asian="Times New Roman"
-style:font-size-asian="11pt"
-fo:line-height="0.1937inch"
-fo:text-align="justify"
-style:justify-single-word="false"
-fo:orphans="0"
-fo:widows="0"
-fo:text-indent="0inch"
-style:auto-text-indent="false">
-<style:tab-stops>
-<style:tab-stop
-style:position="0inch"/>
-</style:tab-stops>
-</style:properties>
-</style:style>
-
-<text:list-style style:name="BulletList">
-<text:list-level-style-bullet text:level="1"
-text:style-name="Bullet"
-style:num-suffix="."
-text:bullet-char="*">
-<style:properties
-text:min-label-width="0.25inch"
-style:font-name="Wingdings"/>
-</text:list-level-style-bullet>
-</text:list-style>
-
-<style:style style:name="Bullet"
-style:family="text">
-<style:properties
-style:font-name="Wingdings"/>
-</style:style>
-
-<style:style style:name=".CALLOUT"
-style:family="paragraph"
-style:parent-style-name=".body">
-<style:properties
-fo:background-color="#e6e6e6"
-fo:margin-left="0.25inch" fo:margin-right="0.25inch"
-fo:margin-top="0.0835inch" fo:margin-bottom="0.0835inch"
-fo:text-indent="0inch"
-style:auto-text-indent="false"/></style:style>
-
-<style:style style:name=".cell body"
-style:family="paragraph">
-<style:properties
-fo:color="#000000" style:font-name="Univers 45 Light"
-fo:font-size="8pt" fo:language="en" fo:country="US"
-style:font-name-asian="Times New Roman" style:font-size-asian="8pt"
-style:line-height-at-least="0.139inch" fo:orphans="0"
-fo:widows="0"/></style:style>
-
-<style:style style:name=".cell head"
-style:family="paragraph">
-<style:properties fo:color="#000000"
-style:font-name="Univers 45 Light" fo:font-size="8pt" fo:language="en"
-fo:country="US" fo:font-weight="bold" style:font-name-asian="Times New
-Roman" style:font-size-asian="8pt" style:font-weight-asian="bold"
-style:line-height-at-least="0.139inch" fo:orphans="0"
-fo:widows="0"/></style:style>
-
-<style:style style:name=".ch title"
-style:family="paragraph">
-<style:properties
-fo:margin-top="0.5inch" fo:margin-bottom="0.25inch" fo:color="#000000"
-style:font-name="AGaramond" fo:font-size="29.5pt" fo:language="en"
-fo:country="US" fo:font-style="italic" style:font-name-asian="Times
-New Roman" style:font-size-asian="29.5pt"
-style:font-style-asian="italic"
-style:line-height-at-least="0.4161inch" fo:orphans="0"
-fo:widows="0"/></style:style>
-
-<style:style style:name=".code"
-style:family="paragraph">
-<style:properties fo:color="#000000"
-style:font-name="Courier" fo:font-size="10pt" fo:language="en"
-fo:country="US" style:font-name-asian="Times New Roman"
-style:font-size-asian="10pt" style:language-asian="en"
-style:country-asian="US" style:line-height-at-least="0.1665inch"
-fo:orphans="0" fo:widows="0"/></style:style>
-
-<style:style style:name=".code NOTATION"
-style:family="paragraph">
-<style:properties
-style:use-window-font-color="true" style:font-name="Helvetica-Narrow"
-fo:font-size="9pt" fo:font-weight="bold" style:font-name-asian="Times
-New Roman" style:font-size-asian="9pt" style:font-weight-asian="bold"
-fo:orphans="2" fo:widows="2"/></style:style>
-
-<style:style style:name=".figure"
-style:family="paragraph">
-<style:properties
-fo:margin-top="0inch" fo:margin-bottom="0inch" fo:color="#000000"
-style:font-name="Univers 45 Light" fo:font-size="8pt" fo:language="en"
-fo:country="US" fo:font-weight="bold" style:font-name-asian="Times New
-Roman" style:font-size-asian="8pt" style:font-weight-asian="bold"
-fo:line-height="0.139inch" fo:orphans="0"
-fo:widows="0"/></style:style>
-
-<style:style style:name=".head 1"
-style:family="paragraph">
-<style:properties
-fo:margin-top="0.278inch" fo:margin-bottom="0.1665inch"
-fo:color="#000000" style:font-name="AGaramond" fo:font-size="20pt"
-fo:language="en" fo:country="US" fo:font-style="italic"
-style:font-name-asian="Times New Roman" style:font-size-asian="20pt"
-style:font-style-asian="italic" fo:line-height="0.278inch"
-fo:orphans="0" fo:widows="0"
-fo:keep-with-next="true"/></style:style>
-
-<style:style style:name=".head 2"
-style:family="paragraph"
-style:parent-style-name=".head 1"
-style:next-style-name=".body1">
-<style:properties
-fo:margin-top="0.0972inch" fo:margin-bottom="0.0972inch"
-fo:font-size="16pt" style:font-size-asian="16pt"
-fo:line-height="0.222inch"/></style:style>
-
-<style:style style:name=".head 3alone"
-style:family="paragraph"
-style:next-style-name=".body">
-<style:properties
-fo:margin-top="0.0972inch" fo:margin-bottom="0.0555inch"
-style:use-window-font-color="true" style:font-name="AGaramond"
-fo:font-size="14pt" fo:font-style="italic"
-style:font-name-asian="Times New Roman" style:font-size-asian="14pt"
-style:font-style-asian="italic" fo:orphans="2"
-fo:widows="2"/></style:style>
-
-<style:style style:name=".numlist"
-style:family="paragraph"
-style:list-style-name="NumberedList">
-<style:properties
-fo:margin-top="0.028inch"
-fo:margin-bottom="0.028inch"
-fo:color="#000000"
-style:font-name="AGaramond"
-fo:font-size="11pt"
-fo:language="en"
-fo:country="US"
-style:font-name-asian="Times New Roman"
-style:font-size-asian="11pt"
-fo:line-height="0.1937inch"
-fo:text-align="justify"
-style:justify-single-word="false"
-fo:orphans="0" fo:widows="0">
-<style:tab-stops>
-<style:tab-stop style:position="0.5inch"/>
-</style:tab-stops>
-</style:properties></style:style>
-
-<text:list-style style:name="NumberedList">
-<text:list-level-style-number text:level="1"
-style:num-suffix="."
-style:num-format="1">
-<style:properties
-text:min-label-width="0.25inch"/>
-</text:list-level-style-number>
-</text:list-style>
-
-<style:style style:name=".numlist 1"
-style:family="paragraph"
-style:parent-style-name=".numlist"
-style:next-style-name=".numlist">
-<style:properties
-fo:margin-left="0inch" fo:margin-right="0inch" fo:text-indent="0inch"
-style:auto-text-indent="false"/></style:style>
-
-<style:style style:name=".table title"
-style:family="paragraph">
-<style:properties fo:color="#000000"
-style:font-name="Univers 45 Light" fo:font-size="8pt" fo:language="en"
-fo:country="US" fo:font-weight="bold" style:font-name-asian="Times New
-Roman" style:font-size-asian="8pt" style:font-weight-asian="bold"
-style:line-height-at-least="0.139inch" fo:text-align="justify"
-style:justify-single-word="false" fo:orphans="0"
-fo:widows="0"/></style:style>
-
-<style:style style:name="image"
-style:family="graphics">
-<style:properties style:wrap="none"
-style:vertical-pos="top"
-style:vertical-rel="char"
-style:horizontal-pos="from-left"
-style:horizontal-rel="paragraph-content"
-fo:background-color="transparent"
-fo:padding="0.0102inch"
-fo:border="none" style:mirror="none"
-fo:clip="rect(0inch 0inch 0inch 0inch)"
-draw:luminance="0%"
-draw:contrast="0%"
-draw:red="0%"
-draw:green="0%"
-draw:blue="0%"
-draw:gamma="100"
-draw:color-inversion="false"
-draw:transparency="-100%"
-draw:color-mode="standard">
-<style:background-image/>
-</style:properties>
-</style:style>
-
-<style:style style:name="Page Number"
-style:family="text"
-style:parent-style-name="WW-Default Paragraph Font"/>
-
-<style:style style:name="WW-Default Paragraph Font"
-style:family="text"/>
-
-<style:style style:name="Frame" style:family="graphics">
-<style:properties
-text:anchor-type="paragraph" svg:x="0inch" svg:y="0inch"
-style:wrap="parallel" style:number-wrapped-paragraphs="no-limit"
-style:wrap-contour="false" style:vertical-pos="top"
-style:vertical-rel="paragraph-content" style:horizontal-pos="center"
-style:horizontal-rel="paragraph-content"/></style:style>
-
-<style:style style:name="Graphics" style:family="graphics">
-<style:properties
-text:anchor-type="paragraph" svg:x="0inch" svg:y="0inch"
-style:wrap="none"
-style:vertical-pos="top"
-style:vertical-rel="char"
-style:horizontal-pos="from-left"
-style:horizontal-rel="paragraph-content"/></style:style>
-
-<style:style style:name="OLE" style:family="graphics">
-<style:properties
-text:anchor-type="paragraph" svg:x="0inch" svg:y="0inch"
-style:wrap="none" style:vertical-pos="top"
-style:vertical-rel="paragraph" style:horizontal-pos="center"
-style:horizontal-rel="paragraph"/></style:style>
-
-<text:footnotes-configuration
-style:num-format="1" text:start-value="0"
-text:footnotes-position="page"
-text:start-numbering-at="document"/>
-
-<text:endnotes-configuration
-style:num-format="i"
-text:start-value="0"/>
-
-<text:linenumbering-configuration
-text:number-lines="false" text:offset="0.1965inch"
-style:num-format="1" text:number-position="left"
-text:increment="5"/>
-
-</office:styles>
-
-
-<office:automatic-styles>
-
-<style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard">
-<style:properties
-fo:margin-left="0inch" fo:margin-right="0.25inch"
-style:font-name="AGaramond" fo:text-indent="0inch"
-style:auto-text-indent="false"/>
-</style:style>
-
-<style:style style:name="P2" style:family="paragraph" style:parent-style-name="Standard">
-<style:properties
-fo:margin-left="0inch" fo:margin-right="0.25inch"
-fo:text-indent="0.25inch"
-style:auto-text-indent="false"/>
-</style:style>
-
-<style:style style:name="P3" style:family="paragraph" style:parent-style-name="Standard">
-<style:properties>
-<style:tab-stops>
-<style:tab-stop
-style:position="0.0626inch"/>
-<style:tab-stop
-style:position="0.25inch"/>
-<style:tab-stop
-style:position="2.6252inch"/>
-<style:tab-stop
-style:position="6.3126inch"/>
-<style:tab-stop
-style:position="6.3752inch"/>
-</style:tab-stops></style:properties></style:style>
-
-<style:style style:name="P4" style:family="paragraph" style:parent-style-name="Standard">
-<style:properties
-fo:margin-left="0inch" fo:margin-right="0.25inch"
-fo:text-indent="0inch"
-style:auto-text-indent="false">
-<style:tab-stops>
-<style:tab-stop
-style:position="6.4402inch"
-style:type="right"/>
-</style:tab-stops></style:properties></style:style>
-
-<style:style style:name="P5" style:family="paragraph" style:parent-style-name="Standard">
-<style:properties
-fo:margin-left="0inch" fo:margin-right="0.25inch"
-fo:text-indent="0inch"
-style:auto-text-indent="false">
-<style:tab-stops>
-<style:tab-stop
-style:position="0inch"/>
-<style:tab-stop
-style:position="2.75inch"/>
-<style:tab-stop
-style:position="3.1874inch"/>
-<style:tab-stop
-style:position="6.1874inch"/>
-<style:tab-stop
-style:position="6.4402inch"
-style:type="right"/>
-</style:tab-stops></style:properties></style:style>
-
-<style:style style:name="T1" style:family="text" style:parent-style-name="Page Number">
-<style:properties
-style:font-name="AGaramond"/></style:style>
-
-<style:style style:name="fr1"
-style:family="graphics"
-style:parent-style-name="Graphics">
-<style:properties
-fo:background-color="transparent">
-<style:background-image/></style:properties></style:style>
-
-<style:page-master style:name="pm1" style:page-usage="mirrored">
-<style:properties
-fo:page-width="8.5inch" fo:page-height="11inch" style:num-format="1"
-style:print-orientation="portrait" fo:margin-top="0.4925inch"
-fo:margin-bottom="0.4925inch" fo:margin-left="1inch"
-fo:margin-right="1inch" style:layout-grid-color="#c0c0c0"
-style:layout-grid-lines="40"
-style:layout-grid-base-height="0.1945inch"
-style:layout-grid-ruby-height="0.0555inch"
-style:layout-grid-mode="none" style:layout-grid-ruby-below="false"
-style:layout-grid-print="false" style:layout-grid-display="false"
-style:footnote-max-height="0inch">
-<style:footnote-sep
-style:width="0.0071inch" style:distance-before-sep="0.0398inch"
-style:distance-after-sep="0.0398inch" style:adjustment="left"
-style:rel-width="25%"
-style:color="#000000"/>
-</style:properties>
-<style:header-style>
-<style:properties
-fo:min-height="0.5075inch"/>
-</style:header-style>
-<style:footer-style>
-<style:properties fo:min-height="0inch" fo:margin-top="0.0909inch"/>
-</style:footer-style>
-</style:page-master>
-</office:automatic-styles>
-
-
-<office:master-styles>
-<style:master-page style:name="Standard" style:page-master-name="pm1">
-
-<style:header>
-<text:p text:style-name="P1">
-<draw:text-box draw:style-name="fr1"
-draw:name="Frame1" text:anchor-type="paragraph" svg:y="0.0008inch"
-svg:width="0.2429inch" svg:height="0.0161inch" draw:z-index="2">
-<text:p text:style-name="Header">
-<text:span text:style-name="T1">
-<text:page-number text:select-page="current">10
-</text:page-number></text:span></text:p></draw:text-box></text:p>
-</style:header>
-
-<style:header-left>
-<text:p text:style-name="P2">
-<draw:text-box draw:style-name="fr1"
-draw:name="Frame2" text:anchor-type="paragraph" svg:y="0.0008inch"
-svg:width="0.2429inch" svg:height="0.0161inch" draw:z-index="3">
-<text:p text:style-name="Standard">
-<text:page-number text:select-page="current">10
-</text:page-number></text:p></draw:text-box></text:p>
-</style:header-left>
-
-<style:footer>
-<text:p text:style-name="P3">
-<text:tab-stop/></text:p>
-<text:p text:style-name="P3">
-Author Template
-<text:tab-stop/>
-Manning Publications Co.
-<text:tab-stop/>
-<text:span text:style-name="T1">
-<text:page-number text:select-page="current">10
-</text:page-number></text:span></text:p>
-</style:footer>
-
-<style:footer-left>
-<text:p text:style-name="P4"/>
-<text:p text:style-name="P5">
-Author Template
-<text:tab-stop/>
-Manning Publications Co.
-<text:tab-stop/>
-<text:tab-stop/>
-<text:span text:style-name="T1">
-<text:page-number text:select-page="current">10
-</text:page-number></text:span></text:p>
-</style:footer-left>
-
-</style:master-page>
-</office:master-styles>
-</office:document-styles>
-
-'''
-
-# Temporary style info:
-
-'''
-
-'''
diff --git a/sandbox/pobrien/OpenOffice/OOwriter.py b/sandbox/pobrien/OpenOffice/OOwriter.py
deleted file mode 100644
index 2a3fb8ddb..000000000
--- a/sandbox/pobrien/OpenOffice/OOwriter.py
+++ /dev/null
@@ -1,599 +0,0 @@
-"""OpenOffice writer
-
-The output is an OpenOffice.org 1.0-compatible document."""
-
-__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
-__cvsid__ = "$Id$"
-__revision__ = "$Revision$"[11:-2]
-
-# Based on work orginally created by:
-# Author: Aahz
-# Contact: aahz@pythoncraft.com
-
-__docformat__ = 'reStructuredText'
-
-import sys
-from warnings import warn
-import re
-
-import docutils
-from docutils import nodes, utils, writers, languages
-
-import OOtext
-
-import Image # from the Python Imaging Library
-
-section_styles = [
- '.ch title',
- '.head 1',
- '.head 2',
- '.head 3alone',
- ]
-
-
-class Writer(writers.Writer):
-
- supported = ('OpenOffice')
- """Formats this writer supports."""
-
- output = None
- """Final translated form of `document`."""
-
- def __init__(self):
- writers.Writer.__init__(self)
- self.translator_class = Translator
-
- def translate(self):
- visitor = self.translator_class(self.document)
- self.document.walkabout(visitor)
- self.output = visitor.astext()
-
-
-class Translator(nodes.NodeVisitor):
-
- header = [OOtext.content_header]
- footer = [OOtext.content_footer]
-
- start_para = '\n<text:p text:style-name="%s">\n'
- end_para = '\n</text:p>\n'
-
- start_charstyle = '<text:span text:style-name="%s">'
- end_charstyle = '</text:span>'
-
- line_break = '\n<text:line-break/>'
- re_spaces = re.compile(' +')
- spaces = '<text:s text:c="%d"/>'
-
- re_annotation = re.compile(r'#\d+(?:, #\d+)*$')
-
- def __init__(self, document):
- nodes.NodeVisitor.__init__(self, document)
- self.settings = document.settings
- self.body = []
- self.section_level = 0
- self.skip_para_tag = False
- self.para_styles = ['.body']
- self.compact_p = 1
- self.compact_simple = None
- self.context = []
- self.inBulletList = False
- self.inEnumList = False
- self.inTableHead = False
- self.inTableBody = False
- self.bodyOne = False
- self.colspecs = []
-
- def astext(self):
- """Return the final formatted document as a string."""
- return ''.join(self.header + self.body + self.footer)
-
- def encode(self, text):
- """Encode special characters in `text` & return."""
- # @@@ A codec to do these and all other HTML entities would be nice.
- text = text.replace("&", "&amp;")
- text = text.replace("<", "&lt;")
- text = text.replace('"', "&quot;")
- text = text.replace(">", "&gt;")
- return text
-
- def compress_spaces(self, line):
- while 1:
- match = self.re_spaces.search(line)
- if match:
- start, end = match.span()
- numspaces = end - start
- line = line[:start] + (self.spaces % numspaces) + line[end:]
- else:
- break
- return line
-
- def fix_annotation(self, line):
- match = self.re_annotation.search(line)
- if match:
- pos = match.start()
- line = line[:pos] + '|' + line[pos:]
- return line
-
- def visit_Text(self, node):
- self.body.append(self.encode(node.astext()))
-
- def depart_Text(self, node):
- pass
-
- def visit_admonition(self, node, name):
- self.skip_para_tag = False
- self.para_styles.append('.CALLOUT')
-
- def depart_admonition(self):
- self.para_styles.pop()
- self.bodyOne = True
-
- def visit_attention(self, node):
- self.visit_admonition(node, 'attention')
-
- def depart_attention(self, node):
- self.depart_admonition()
-
-## def visit_block_quote(self, node):
-## self.skip_para_tag = True
-## self.body.append(self.start_para % '.quotes')
-
-## def depart_block_quote(self, node):
-## self.body.append(self.end_para)
-## self.skip_para_tag = False
-## self.bodyOne = True
-
- def visit_bullet_list(self, node):
- self.inBulletList = True
- self.body.append('\n<text:unordered-list text:style-name="BulletList">\n')
-
- def depart_bullet_list(self, node):
- self.body.append('</text:unordered-list>\n')
- self.inBulletList = False
- self.bodyOne = True
-
- def visit_caption(self, node):
- pass
-
- def depart_caption(self, node):
- pass
-
- def visit_caution(self, node):
- self.visit_admonition(node, 'caution')
-
- def depart_caution(self, node):
- self.depart_admonition()
-
-## def visit_citation(self, node):
-## self.body.append(self.starttag(node, 'table', CLASS='citation',
-## frame="void", rules="none"))
-## self.footnote_backrefs(node)
-
-## def depart_citation(self, node):
-## self.body.append('</td></tr>\n'
-## '</tbody>\n</table>\n')
-
-## def visit_citation_reference(self, node):
-## href = ''
-## if node.has_key('refid'):
-## href = '#' + node['refid']
-## elif node.has_key('refname'):
-## href = '#' + self.document.nameids[node['refname']]
-## self.body.append(self.starttag(node, 'a', '[', href=href,
-## CLASS='citation-reference'))
-
-## def depart_citation_reference(self, node):
-## self.body.append(']</a>')
-
-## def visit_classifier(self, node):
-## self.body.append(' <span class="classifier-delimiter">:</span> ')
-## self.body.append(self.starttag(node, 'span', '', CLASS='classifier'))
-
-## def depart_classifier(self, node):
-## self.body.append('</span>')
-
- def visit_colspec(self, node):
- self.colspecs.append(node)
-
- def depart_colspec(self, node):
- pass
-
- def write_colspecs(self):
- width = 0
- for node in self.colspecs:
- width += node['colwidth']
- for node in self.colspecs:
- self.body.append('<table:table-column/>')
-
-## colwidth = int(node['colwidth'] * 100.0 / width + 0.5)
-## self.body.append(self.emptytag(node, 'col',
-## colwidth='%i%%' % colwidth))
- self.colspecs = []
-
- def visit_comment(self, node):
- raise nodes.SkipNode
-
- def visit_decoration(self, node):
- raise nodes.SkipNode
-
- def depart_decoration(self, node):
- pass
-
- def visit_definition(self, node):
- pass
-
- def depart_definition(self, node):
- pass
-
- def visit_definition_list(self, node):
- pass
-
- def depart_definition_list(self, node):
- pass
-
- def visit_definition_list_item(self, node):
- pass
-
- def depart_definition_list_item(self, node):
- pass
-
- def visit_docinfo(self, node):
- raise nodes.SkipNode
-
- def depart_docinfo(self, node):
- pass
-
- def visit_doctest_block(self, node):
- self.visit_literal_block(node)
-
- def visit_document(self, node):
- pass
-
- def depart_document(self, node):
- pass
-
- def visit_emphasis(self, node):
- self.body.append(self.start_charstyle % 'Emphasis')
-
- def depart_emphasis(self, node):
- self.body.append(self.end_charstyle)
-
- def visit_entry(self, node):
- self.body.append('<table:table-cell table:value-type="string">\n')
-
- def depart_entry(self, node):
- self.body.append('</table:table-cell>\n')
-
- def visit_enumerated_list(self, node):
- self.inEnumList = True
- self.body.append('\n<text:ordered-list text:style-name="NumberedList">\n')
-
- def depart_enumerated_list(self, node):
- self.body.append('</text:ordered-list>\n')
- self.inEnumList = False
- self.bodyOne = True
-
- def visit_error(self, node):
- self.visit_admonition(node, 'error')
-
- def depart_error(self, node):
- self.depart_admonition()
-
- def visit_figure(self, node):
- self.body.append(self.start_para % '.figure')
-
- def depart_figure(self, node):
- self.body.append(self.end_para)
- self.bodyOne = True
-
- def visit_footer(self, node):
- pass
-## self.context.append(len(self.body))
-
- def depart_footer(self, node):
- pass
-## start = self.context.pop()
-## footer = (['<hr class="footer" />\n',
-## self.starttag(node, 'div', CLASS='footer')]
-## + self.body[start:] + ['</div>\n'])
-## self.body_suffix[:0] = footer
-## del self.body[start:]
-
- def visit_footnote(self, node):
- raise nodes.SkipNode
-
-## def footnote_backrefs(self, node):
-## warn("footnote backrefs not available")
-
- def depart_footnote(self, node):
- pass
-
-## def visit_footnote_reference(self, node):
-## name = node['refid']
-## id = node['id']
-## number = node['auto']
-## for footnote in self.document.autofootnotes:
-## if name == footnote['name']:
-## break
-## self.body.append('<text:footnote text:id="%s">\n' % id)
-## self.body.append('<text:footnote-citation text:string-value="%s"/>\n' % number)
-## self.body.append('<text:footnote-body>\n')
-## self.body.append(self.start_para % '.body')
-## for child in footnote.children:
-## if isinstance(child, nodes.paragraph):
-## self.body.append(child.astext())
-## self.body.append(self.end_para)
-## self.body.append('</text:footnote-body>\n')
-## self.body.append('</text:footnote>')
-## raise nodes.SkipNode
-
-## def depart_footnote_reference(self, node):
-## pass
-
- def visit_generated(self, node):
- pass
-
- def depart_generated(self, node):
- pass
-
-## def visit_header(self, node):
-## self.context.append(len(self.body))
-
-## def depart_header(self, node):
-## start = self.context.pop()
-## self.body_prefix.append(self.starttag(node, 'div', CLASS='header'))
-## self.body_prefix.extend(self.body[start:])
-## self.body_prefix.append('<hr />\n</div>\n')
-## del self.body[start:]
-
- def visit_hint(self, node):
- self.visit_admonition(node, 'hint')
-
- def depart_hint(self, node):
- self.depart_admonition()
-
- def visit_image(self, node):
- name = str(node.attributes['uri'])
- image = Image.open(name)
- format = image.format
- dpi = 96.0
- width, height = image.size
- width /= dpi
- height /= dpi
- scale = None
- if 'scale' in node.attributes:
- scale = node.attributes['scale']
- if scale is not None:
- factor = scale / 100.0
- width *= factor
- height *= factor
- # Add to our list so that rest2oo.py can create the manifest.
- if format == 'PNG':
- OOtext.pictures.append((name, OOtext.m_png_format % name))
- elif format == 'TIFF':
- OOtext.pictures.append((name, OOtext.m_tif_format % name))
- else:
- print '*** Image type not recognized ***', repr(name)
- #self.body.append('<text:line-break/>\n')
- self.body.append('<draw:image draw:style-name="image"\n')
- self.body.append('draw:name="%s"\n' % name)
- self.body.append('text:anchor-type="char"\n')
- self.body.append('svg:width="%0.2finch"\n' % width)
- self.body.append('svg:height="%0.2finch"\n' % height)
- self.body.append('draw:z-index="0"\n')
- self.body.append('xlink:href="#Pictures/%s"\n' % name)
- self.body.append('xlink:type="simple"\n')
- self.body.append('xlink:show="embed"\n')
- self.body.append('xlink:actuate="onLoad"/>')
- self.body.append('Figure X.X\n')
-
- def depart_image(self, node):
- pass
-
- def visit_important(self, node):
- self.visit_admonition(node, 'important')
-
- def depart_important(self, node):
- self.depart_admonition()
-
- def visit_index_entry(self, node):
- index_format = '<text:alphabetical-index-mark text:string-value="%s"/>\n'
- self.body.append(self.start_para % '.body')
- entries = node.astext().split('\n')
- for entry in entries:
- self.body.append(index_format % self.encode(entry))
- self.body.append(self.end_para)
- raise nodes.SkipNode
-
-## def visit_line_block(self, node):
-## self.body.append(self.start_para % '.quotes')
-## lines = node.astext()
-## lines = lines.split('\n')
-## lines = self.line_break.join(lines)
-## self.body.append(lines)
-## self.body.append(self.end_para)
-## raise nodes.SkipNode
-
- def visit_list_item(self, node):
- self.body.append('<text:list-item>')
-## if len(node):
-## node[0].set_class('first')
-
- def depart_list_item(self, node):
- self.body.append('</text:list-item>\n')
-
- def visit_literal(self, node):
- self.body.append(self.start_charstyle % 'code')
-
- def depart_literal(self, node):
- self.body.append(self.end_charstyle)
-
- def visit_literal_block(self, node):
- self.body.append(self.start_para % '.code first')
- self.body.append(self.end_para)
- lines = self.encode(node.astext())
- lines = lines.split('\n')
- while lines[-1] == '':
- lines.pop()
- for line in lines:
- self.body.append(self.start_para % '.code')
- line = self.fix_annotation(line)
- line = self.compress_spaces(line)
- self.body.append(line)
- self.body.append(self.end_para)
- self.body.append(self.start_para % '.code last')
- self.body.append(self.end_para)
- self.bodyOne = True
- raise nodes.SkipNode
-
- def visit_note(self, node):
- self.visit_admonition(node, 'note')
-
- def depart_note(self, node):
- self.depart_admonition()
-
- def visit_paragraph(self, node):
- style = self.para_styles[-1]
- if self.inBulletList:
- style = '.bullet'
- elif self.inEnumList:
- style = '.numlist'
- elif self.inTableHead:
- style = '.cell head'
- elif self.inTableBody:
- style = '.cell body'
- elif node.astext().startswith('(annotation)'):
- style = '.code NOTATION'
- elif self.bodyOne or node.astext().startswith('#'):
- if style == '.body':
- style = '.body1'
- self.bodyOne = False
- if not self.skip_para_tag:
- self.body.append(self.start_para % style)
-
- def depart_paragraph(self, node):
- if not self.skip_para_tag:
- self.body.append(self.end_para)
-
- def visit_reference(self, node):
- pass
-
- def depart_reference(self, node):
- pass
-
- def visit_row(self, node):
- self.body.append('<table:table-row>\n')
-
- def depart_row(self, node):
- self.body.append('</table:table-row>\n')
-
- def visit_section(self, node):
- self.section_level += 1
- self.bodyOne = True
-
- def depart_section(self, node):
- self.section_level -= 1
-
-## XX Perhaps these should replace admonition:
-
-## def visit_sidebar(self, node):
-## self.body.append(self.starttag(node, 'div', CLASS='sidebar'))
-## self.in_sidebar = 1
-
-## def depart_sidebar(self, node):
-## self.body.append('</div>\n')
-## self.in_sidebar = None
-
- def visit_strong(self, node):
- self.body.append(self.start_charstyle % 'Strong Emphasis')
-
- def depart_strong(self, node):
- self.body.append(self.end_charstyle)
-
- def visit_table(self, node):
- self.body.append('<table:table>\n')
-
- def depart_table(self, node):
- self.body.append('</table:table>\n')
- self.bodyOne = True
-
- def visit_tbody(self, node):
- self.write_colspecs()
- self.inTableBody = True
-
- def depart_tbody(self, node):
- self.inTableBody = False
-
- def visit_term(self, node):
- self.bodyOne = True
- self.visit_paragraph(node)
- self.body.append(self.start_charstyle % 'Strong Emphasis')
-
- def depart_term(self, node):
- self.body.append(self.end_charstyle)
- self.depart_paragraph(node)
-
- def visit_tgroup(self, node):
- pass
-
- def depart_tgroup(self, node):
- pass
-
- def visit_thead(self, node):
- self.write_colspecs()
- self.inTableHead = True
-
- def depart_thead(self, node):
- self.inTableHead = False
-
- def visit_tip(self, node):
- self.visit_admonition(node, 'tip')
-
- def depart_tip(self, node):
- self.depart_admonition()
-
- def visit_title(self, node):
- """Only 4 section levels are supported by this writer."""
- title_tag = self.start_para % section_styles[self.section_level]
- self.body.append(title_tag)
-
- def depart_title(self, node):
- self.body.append(self.end_para)
-
- def visit_topic(self, node):
- if node.has_key('class') and node['class'] == 'contents':
- raise nodes.SkipNode
- else:
- pass
-
- def depart_topic(self, node):
- pass
-
- def visit_transition(self, node):
- self.visit_paragraph(node)
-
- def depart_transition(self, node):
- self.depart_paragraph(node)
-
- def visit_warning(self, node):
- self.visit_admonition(node, 'warning')
-
- def depart_warning(self, node):
- self.depart_admonition()
-
- def visit_system_message(self, node):
- print node.astext()
-
- def depart_system_message(self, node):
- pass
-
- def unknown_visit(self, node):
- print "=" * 70
- print "Failure due to unknown node type"
- print "-" * 70
- print "Failed node is: %r" % node
- print "Failed line is:", node.line
- print "Failed text is:", node.astext()
- print "=" * 70
- raise NotImplementedError('unimplemented node type: %s'
- % node.__class__.__name__)
diff --git a/sandbox/pobrien/OpenOffice/__init__.py b/sandbox/pobrien/OpenOffice/__init__.py
deleted file mode 100644
index db6003cf3..000000000
--- a/sandbox/pobrien/OpenOffice/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# Orbtech python package. \ No newline at end of file
diff --git a/sandbox/pobrien/OpenOffice/rest2oo.py b/sandbox/pobrien/OpenOffice/rest2oo.py
deleted file mode 100755
index e48e7d4ec..000000000
--- a/sandbox/pobrien/OpenOffice/rest2oo.py
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env python
-
-__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
-__cvsid__ = "$Id$"
-__revision__ = "$Revision$"[11:-2]
-
-import locale
-try:
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-import sys
-import zipfile
-
-from docutils import core
-
-import OOdirectives
-import OOtext
-import OOwriter
-
-
-def main():
-
-## pub = core.Publisher(writer=OOwriter.Writer())
-## pub.set_reader('standalone', None, 'restructuredtext')
-## settings = pub.get_settings()
-## pub.source = io.FileInput(settings, source_path=sys.argv[1])
-## pub.destination = io.StringOutput(settings)
-## content = pub.publish()
-
- source = file(sys.argv[1]).read()
- content = core.publish_string(source, writer=OOwriter.Writer())
-
- xml_manifest_list = [
- ('content.xml', content),
- ('styles.xml', OOtext.styles)
- ]
-
- xml_entries = []
- for docname, _ in xml_manifest_list:
- xml_entries.append(OOtext.m_xml_format % docname)
-
- image_manifest_list = OOtext.pictures
-
- image_entries = []
- for name, format in image_manifest_list:
- image_entries.append(format)
-
- manifest = OOtext.manifest % ('\n '.join(image_entries),
- '\n '.join(xml_entries))
- xml_manifest_list.append(('META-INF/manifest.xml', manifest))
-
- zip = zipfile.ZipFile(sys.argv[2], "w")
- for docname, contents in xml_manifest_list:
- zinfo = zipfile.ZipInfo(docname)
- zip.writestr(zinfo, contents)
- for name, format in image_manifest_list:
- zip.write(name, 'Pictures/' + name)
- zip.close()
-
-if __name__ == '__main__':
- main()
diff --git a/sandbox/pobrien/OpenOffice/rest2oopseudo.py b/sandbox/pobrien/OpenOffice/rest2oopseudo.py
deleted file mode 100755
index 75565eac5..000000000
--- a/sandbox/pobrien/OpenOffice/rest2oopseudo.py
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/usr/bin/env python
-
-"""
-A minimal front end to the Docutils Publisher, producing pseudo-XML.
-"""
-
-__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
-__cvsid__ = "$Id$"
-__revision__ = "$Revision$"[11:-2]
-
-import locale
-try:
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-from docutils.core import publish_cmdline, default_description
-
-import OOdirectives
-
-description = ('Generates pseudo-XML from standalone reStructuredText '
- 'sources (for testing purposes). ' + default_description)
-
-publish_cmdline(description=description)
diff --git a/sandbox/pobrien/OpenOffice/rest2ooxml.py b/sandbox/pobrien/OpenOffice/rest2ooxml.py
deleted file mode 100755
index 671052845..000000000
--- a/sandbox/pobrien/OpenOffice/rest2ooxml.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-
-"""Generates the OpenOffice.org content.xml file outside of a .swx zip
-file. Useful for debugging the OOwriter."""
-
-__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
-__cvsid__ = "$Id$"
-__revision__ = "$Revision$"[11:-2]
-
-import locale
-try:
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-from docutils.core import publish_cmdline, default_description
-
-from OOwriter import Writer
-
-
-def main():
- description = ("Generates OpenOffice.org XML. " + default_description)
- publish_cmdline(writer=Writer(), description=description)
-
-
-if __name__ == '__main__':
- main()
diff --git a/sandbox/pobrien/WriterTemplate.py b/sandbox/pobrien/WriterTemplate.py
deleted file mode 100644
index 868c8434a..000000000
--- a/sandbox/pobrien/WriterTemplate.py
+++ /dev/null
@@ -1,1081 +0,0 @@
-"""Template for creating a new writer."""
-
-__author__ = "Patrick K. O'Brien <pobrien@orbtech.com>"
-__cvsid__ = "$Id$"
-__revision__ = "$Revision$"[11:-2]
-
-
-__docformat__ = 'reStructuredText'
-
-
-import sys
-import os
-import time
-import re
-from types import ListType
-
-import docutils
-from docutils import nodes, utils, writers, languages
-
-
-class Writer(writers.Writer):
-
- supported = ('SomeFormat')
- """Formats this writer supports."""
-
- output = None
- """Final translated form of `document`."""
-
- def __init__(self):
- writers.Writer.__init__(self)
- self.translator_class = Translator
-
- def translate(self):
- visitor = self.translator_class(self.document)
- self.document.walkabout(visitor)
- self.output = visitor.astext()
-
-
-class Translator(nodes.NodeVisitor):
- """Modify this to suite your needs."""
-
- words_and_spaces = re.compile(r'\S+| +|\n')
-
- def __init__(self, document):
- nodes.NodeVisitor.__init__(self, document)
- self.settings = settings = document.settings
- lcode = settings.language_code
- self.language = languages.get_language(lcode)
- self.head = []
- self.body = []
- self.foot = []
- self.section_level = 0
- self.context = []
- self.topic_class = ''
- self.colspecs = []
- self.compact_p = 1
- self.compact_simple = None
- self.in_docinfo = None
-
- def astext(self):
- """Return the final formatted document as a string."""
- raise NotImplementedError
- return ''.join(self.head + self.body + self.foot)
-
- def visit_Text(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(node.astext())
-
- def depart_Text(self, node):
- pass
-
- def visit_address(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'address', meta=None)
-
- def depart_address(self, node):
- self.depart_docinfo_item()
-
- def visit_admonition(self, node, name):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'div', CLASS=name))
- self.body.append('<p class="admonition-title">'
- + self.language.labels[name] + '</p>\n')
-
- def depart_admonition(self):
- raise NotImplementedError, node.astext()
- self.body.append('</div>\n')
-
- def visit_attention(self, node):
- self.visit_admonition(node, 'attention')
-
- def depart_attention(self, node):
- self.depart_admonition()
-
- def visit_author(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'author')
-
- def depart_author(self, node):
- self.depart_docinfo_item()
-
- def visit_authors(self, node):
- pass
-
- def depart_authors(self, node):
- pass
-
- def visit_block_quote(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'blockquote'))
-
- def depart_block_quote(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</blockquote>\n')
-
- def check_simple_list(self, node):
- raise NotImplementedError, node.astext()
- """Check for a simple list that can be rendered compactly."""
- visitor = SimpleListChecker(self.document)
- try:
- node.walk(visitor)
- except nodes.NodeFound:
- return None
- else:
- return 1
-
- def visit_bullet_list(self, node):
- raise NotImplementedError, node.astext()
- atts = {}
- old_compact_simple = self.compact_simple
- self.context.append((self.compact_simple, self.compact_p))
- self.compact_p = None
- self.compact_simple = (self.settings.compact_lists and
- (self.compact_simple
- or self.topic_class == 'contents'
- or self.check_simple_list(node)))
- if self.compact_simple and not old_compact_simple:
- atts['class'] = 'simple'
- self.body.append(self.starttag(node, 'ul', **atts))
-
- def depart_bullet_list(self, node):
- raise NotImplementedError, node.astext()
- self.compact_simple, self.compact_p = self.context.pop()
- self.body.append('</ul>\n')
-
- def visit_caption(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'p', '', CLASS='caption'))
-
- def depart_caption(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</p>\n')
-
- def visit_caution(self, node):
- self.visit_admonition(node, 'caution')
-
- def depart_caution(self, node):
- self.depart_admonition()
-
- def visit_citation(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'table', CLASS='citation',
- frame="void", rules="none"))
- self.body.append('<colgroup><col class="label" /><col /></colgroup>\n'
- '<col />\n'
- '<tbody valign="top">\n'
- '<tr>')
- self.footnote_backrefs(node)
-
- def depart_citation(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</td></tr>\n'
- '</tbody>\n</table>\n')
-
- def visit_citation_reference(self, node):
- raise NotImplementedError, node.astext()
- href = ''
- if node.has_key('refid'):
- href = '#' + node['refid']
- elif node.has_key('refname'):
- href = '#' + self.document.nameids[node['refname']]
- self.body.append(self.starttag(node, 'a', '[', href=href,
- CLASS='citation-reference'))
-
- def depart_citation_reference(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(']</a>')
-
- def visit_classifier(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(' <span class="classifier-delimiter">:</span> ')
- self.body.append(self.starttag(node, 'span', '', CLASS='classifier'))
-
- def depart_classifier(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</span>')
-
- def visit_colspec(self, node):
- self.colspecs.append(node)
-
- def depart_colspec(self, node):
- pass
-
- def write_colspecs(self):
- raise NotImplementedError, node.astext()
- width = 0
- for node in self.colspecs:
- width += node['colwidth']
- for node in self.colspecs:
- colwidth = int(node['colwidth'] * 100.0 / width + 0.5)
- self.body.append(self.emptytag(node, 'col',
- width='%i%%' % colwidth))
- self.colspecs = []
-
- def visit_comment(self, node,
- sub=re.compile('-(?=-)').sub):
- raise NotImplementedError, node.astext()
- """Escape double-dashes in comment text."""
- self.body.append('<!-- %s -->\n' % sub('- ', node.astext()))
- # Content already processed:
- raise nodes.SkipNode
-
- def visit_contact(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'contact', meta=None)
-
- def depart_contact(self, node):
- self.depart_docinfo_item()
-
- def visit_copyright(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'copyright')
-
- def depart_copyright(self, node):
- self.depart_docinfo_item()
-
- def visit_danger(self, node):
- self.visit_admonition(node, 'danger')
-
- def depart_danger(self, node):
- self.depart_admonition()
-
- def visit_date(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'date')
-
- def depart_date(self, node):
- self.depart_docinfo_item()
-
- def visit_decoration(self, node):
- pass
-
- def depart_decoration(self, node):
- pass
-
- def visit_definition(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</dt>\n')
- self.body.append(self.starttag(node, 'dd', ''))
- if len(node):
- node[0].set_class('first')
- node[-1].set_class('last')
-
- def depart_definition(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</dd>\n')
-
- def visit_definition_list(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'dl'))
-
- def depart_definition_list(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</dl>\n')
-
- def visit_definition_list_item(self, node):
- pass
-
- def depart_definition_list_item(self, node):
- pass
-
- def visit_description(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'td', ''))
- if len(node):
- node[0].set_class('first')
- node[-1].set_class('last')
-
- def depart_description(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</td>')
-
- def visit_docinfo(self, node):
- raise NotImplementedError, node.astext()
- self.context.append(len(self.body))
- self.body.append(self.starttag(node, 'table', CLASS='docinfo',
- frame="void", rules="none"))
- self.body.append('<col class="docinfo-name" />\n'
- '<col class="docinfo-content" />\n'
- '<tbody valign="top">\n')
- self.in_docinfo = 1
-
- def depart_docinfo(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</tbody>\n</table>\n')
- self.in_docinfo = None
- start = self.context.pop()
- self.body_pre_docinfo = self.body[:start]
- self.docinfo = self.body[start:]
- self.body = []
-
- def visit_docinfo_item(self, node, name, meta=1):
- raise NotImplementedError, node.astext()
- if meta:
- self.head.append('<meta name="%s" content="%s" />\n'
- % (name, self.attval(node.astext())))
- self.body.append(self.starttag(node, 'tr', ''))
- self.body.append('<th class="docinfo-name">%s:</th>\n<td>'
- % self.language.labels[name])
- if len(node):
- if isinstance(node[0], nodes.Element):
- node[0].set_class('first')
- if isinstance(node[0], nodes.Element):
- node[-1].set_class('last')
-
- def depart_docinfo_item(self):
- raise NotImplementedError, node.astext()
- self.body.append('</td></tr>\n')
-
- def visit_doctest_block(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'pre', CLASS='doctest-block'))
-
- def depart_doctest_block(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('\n</pre>\n')
-
- def visit_document(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'div', CLASS='document'))
-
- def depart_document(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</div>\n')
-
- def visit_emphasis(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('<em>')
-
- def depart_emphasis(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</em>')
-
- def visit_entry(self, node):
- raise NotImplementedError, node.astext()
- if isinstance(node.parent.parent, nodes.thead):
- tagname = 'th'
- else:
- tagname = 'td'
- atts = {}
- if node.has_key('morerows'):
- atts['rowspan'] = node['morerows'] + 1
- if node.has_key('morecols'):
- atts['colspan'] = node['morecols'] + 1
- self.body.append(self.starttag(node, tagname, '', **atts))
- self.context.append('</%s>\n' % tagname.lower())
- if len(node) == 0: # empty cell
- self.body.append('&nbsp;')
- else:
- node[0].set_class('first')
- node[-1].set_class('last')
-
- def depart_entry(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.context.pop())
-
- def visit_enumerated_list(self, node):
- raise NotImplementedError, node.astext()
- """
- The 'start' attribute does not conform to HTML 4.01's strict.dtd, but
- CSS1 doesn't help. CSS2 isn't widely enough supported yet to be
- usable.
- """
- atts = {}
- if node.has_key('start'):
- atts['start'] = node['start']
- if node.has_key('enumtype'):
- atts['class'] = node['enumtype']
- # @@@ To do: prefix, suffix. How? Change prefix/suffix to a
- # single "format" attribute? Use CSS2?
- old_compact_simple = self.compact_simple
- self.context.append((self.compact_simple, self.compact_p))
- self.compact_p = None
- self.compact_simple = (self.settings.compact_lists and
- (self.compact_simple
- or self.topic_class == 'contents'
- or self.check_simple_list(node)))
- if self.compact_simple and not old_compact_simple:
- atts['class'] = (atts.get('class', '') + ' simple').strip()
- self.body.append(self.starttag(node, 'ol', **atts))
-
- def depart_enumerated_list(self, node):
- raise NotImplementedError, node.astext()
- self.compact_simple, self.compact_p = self.context.pop()
- self.body.append('</ol>\n')
-
- def visit_error(self, node):
- self.visit_admonition(node, 'error')
-
- def depart_error(self, node):
- self.depart_admonition()
-
- def visit_field(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'tr', '', CLASS='field'))
-
- def depart_field(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</tr>\n')
-
- def visit_field_body(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'td', '', CLASS='field-body'))
- if len(node):
- node[0].set_class('first')
- node[-1].set_class('last')
-
- def depart_field_body(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</td>\n')
-
- def visit_field_list(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'table', frame='void',
- rules='none', CLASS='field-list'))
- self.body.append('<col class="field-name" />\n'
- '<col class="field-body" />\n'
- '<tbody valign="top">\n')
-
- def depart_field_list(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</tbody>\n</table>\n')
-
- def visit_field_name(self, node):
- raise NotImplementedError, node.astext()
- atts = {}
- if self.in_docinfo:
- atts['class'] = 'docinfo-name'
- else:
- atts['class'] = 'field-name'
- if len(node.astext()) > 14:
- atts['colspan'] = 2
- self.context.append('</tr>\n<tr><td>&nbsp;</td>')
- else:
- self.context.append('')
- self.body.append(self.starttag(node, 'th', '', **atts))
-
- def depart_field_name(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(':</th>')
- self.body.append(self.context.pop())
-
- def visit_figure(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'div', CLASS='figure'))
-
- def depart_figure(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</div>\n')
-
- def visit_footer(self, node):
- raise NotImplementedError, node.astext()
- self.context.append(len(self.body))
-
- def depart_footer(self, node):
- raise NotImplementedError, node.astext()
- start = self.context.pop()
- footer = (['<hr class="footer"/>\n',
- self.starttag(node, 'div', CLASS='footer')]
- + self.body[start:] + ['</div>\n'])
- self.body_suffix[:0] = footer
- del self.body[start:]
-
- def visit_footnote(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'table', CLASS='footnote',
- frame="void", rules="none"))
- self.body.append('<colgroup><col class="label" /><col /></colgroup>\n'
- '<tbody valign="top">\n'
- '<tr>')
- self.footnote_backrefs(node)
-
- def footnote_backrefs(self, node):
- raise NotImplementedError, node.astext()
- if self.settings.footnote_backlinks and node.hasattr('backrefs'):
- backrefs = node['backrefs']
- if len(backrefs) == 1:
- self.context.append('')
- self.context.append('<a class="fn-backref" href="#%s" '
- 'name="%s">' % (backrefs[0], node['id']))
- else:
- i = 1
- backlinks = []
- for backref in backrefs:
- backlinks.append('<a class="fn-backref" href="#%s">%s</a>'
- % (backref, i))
- i += 1
- self.context.append('<em>(%s)</em> ' % ', '.join(backlinks))
- self.context.append('<a name="%s">' % node['id'])
- else:
- self.context.append('')
- self.context.append('<a name="%s">' % node['id'])
-
- def depart_footnote(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</td></tr>\n'
- '</tbody>\n</table>\n')
-
- def visit_footnote_reference(self, node):
- raise NotImplementedError, node.astext()
- href = ''
- if node.has_key('refid'):
- href = '#' + node['refid']
- elif node.has_key('refname'):
- href = '#' + self.document.nameids[node['refname']]
- format = self.settings.footnote_references
- if format == 'brackets':
- suffix = '['
- self.context.append(']')
- elif format == 'superscript':
- suffix = '<sup>'
- self.context.append('</sup>')
- else: # shouldn't happen
- suffix = '???'
- self.content.append('???')
- self.body.append(self.starttag(node, 'a', suffix, href=href,
- CLASS='footnote-reference'))
-
- def depart_footnote_reference(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.context.pop() + '</a>')
-
- def visit_generated(self, node):
- pass
-
- def depart_generated(self, node):
- pass
-
- def visit_header(self, node):
- raise NotImplementedError, node.astext()
- self.context.append(len(self.body))
-
- def depart_header(self, node):
- raise NotImplementedError, node.astext()
- start = self.context.pop()
- self.body_prefix.append(self.starttag(node, 'div', CLASS='header'))
- self.body_prefix.extend(self.body[start:])
- self.body_prefix.append('<hr />\n</div>\n')
- del self.body[start:]
-
- def visit_hint(self, node):
- self.visit_admonition(node, 'hint')
-
- def depart_hint(self, node):
- self.depart_admonition()
-
- def visit_image(self, node):
- raise NotImplementedError, node.astext()
- atts = node.attributes.copy()
- atts['src'] = atts['uri']
- del atts['uri']
- if not atts.has_key('alt'):
- atts['alt'] = atts['src']
- if isinstance(node.parent, nodes.TextElement):
- self.context.append('')
- else:
- self.body.append('<p>')
- self.context.append('</p>\n')
- self.body.append(self.emptytag(node, 'img', '', **atts))
-
- def depart_image(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.context.pop())
-
- def visit_important(self, node):
- self.visit_admonition(node, 'important')
-
- def depart_important(self, node):
- self.depart_admonition()
-
- def visit_label(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'td', '%s[' % self.context.pop(),
- CLASS='label'))
-
- def depart_label(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(']</a></td><td>%s' % self.context.pop())
-
- def visit_legend(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'div', CLASS='legend'))
-
- def depart_legend(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</div>\n')
-
- def visit_line_block(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'pre', CLASS='line-block'))
-
- def depart_line_block(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('\n</pre>\n')
-
- def visit_list_item(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'li', ''))
- if len(node):
- node[0].set_class('first')
-
- def depart_list_item(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</li>\n')
-
- def visit_literal(self, node):
- raise NotImplementedError, node.astext()
- """Process text to prevent tokens from wrapping."""
- self.body.append(self.starttag(node, 'tt', '', CLASS='literal'))
- text = node.astext()
- for token in self.words_and_spaces.findall(text):
- if token.strip():
- # Protect text like "--an-option" from bad line wrapping:
- self.body.append('<span class="pre">%s</span>'
- % self.encode(token))
- elif token in ('\n', ' '):
- # Allow breaks at whitespace:
- self.body.append(token)
- else:
- # Protect runs of multiple spaces; the last space can wrap:
- self.body.append('&nbsp;' * (len(token) - 1) + ' ')
- self.body.append('</tt>')
- # Content already processed:
- raise nodes.SkipNode
-
- def visit_literal_block(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'pre', CLASS='literal-block'))
-
- def depart_literal_block(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('\n</pre>\n')
-
- def visit_meta(self, node):
- raise NotImplementedError, node.astext()
- self.head.append(self.emptytag(node, 'meta', **node.attributes))
-
- def depart_meta(self, node):
- pass
-
- def visit_note(self, node):
- self.visit_admonition(node, 'note')
-
- def depart_note(self, node):
- self.depart_admonition()
-
- def visit_option(self, node):
- raise NotImplementedError, node.astext()
- if self.context[-1]:
- self.body.append(', ')
-
- def depart_option(self, node):
- raise NotImplementedError, node.astext()
- self.context[-1] += 1
-
- def visit_option_argument(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(node.get('delimiter', ' '))
- self.body.append(self.starttag(node, 'var', ''))
-
- def depart_option_argument(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</var>')
-
- def visit_option_group(self, node):
- raise NotImplementedError, node.astext()
- atts = {}
- if len(node.astext()) > 14:
- atts['colspan'] = 2
- self.context.append('</tr>\n<tr><td>&nbsp;</td>')
- else:
- self.context.append('')
- self.body.append(self.starttag(node, 'td', **atts))
- self.body.append('<kbd>')
- self.context.append(0) # count number of options
-
- def depart_option_group(self, node):
- raise NotImplementedError, node.astext()
- self.context.pop()
- self.body.append('</kbd></td>\n')
- self.body.append(self.context.pop())
-
- def visit_option_list(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(
- self.starttag(node, 'table', CLASS='option-list',
- frame="void", rules="none"))
- self.body.append('<col class="option" />\n'
- '<col class="description" />\n'
- '<tbody valign="top">\n')
-
- def depart_option_list(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</tbody>\n</table>\n')
-
- def visit_option_list_item(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'tr', ''))
-
- def depart_option_list_item(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</tr>\n')
-
- def visit_option_string(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'span', '', CLASS='option'))
-
- def depart_option_string(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</span>')
-
- def visit_organization(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'organization')
-
- def depart_organization(self, node):
- raise NotImplementedError, node.astext()
- self.depart_docinfo_item()
-
- def visit_paragraph(self, node):
- raise NotImplementedError, node.astext()
- # Omit <p> tags if this is an only child and optimizable.
- if (self.compact_simple or
- self.compact_p and (len(node.parent) == 1 or
- len(node.parent) == 2 and
- isinstance(node.parent[0], nodes.label))):
- self.context.append('')
- else:
- self.body.append(self.starttag(node, 'p', ''))
- self.context.append('</p>\n')
-
- def depart_paragraph(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.context.pop())
-
- def visit_problematic(self, node):
- raise NotImplementedError, node.astext()
- if node.hasattr('refid'):
- self.body.append('<a href="#%s" name="%s">' % (node['refid'],
- node['id']))
- self.context.append('</a>')
- else:
- self.context.append('')
- self.body.append(self.starttag(node, 'span', '', CLASS='problematic'))
-
- def depart_problematic(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</span>')
- self.body.append(self.context.pop())
-
- def visit_raw(self, node):
- raise NotImplementedError, node.astext()
- if node.get('format') == 'html':
- self.body.append(node.astext())
- # Keep non-HTML raw text out of output:
- raise nodes.SkipNode
-
- def visit_reference(self, node):
- raise NotImplementedError, node.astext()
- if node.has_key('refuri'):
- href = node['refuri']
- elif node.has_key('refid'):
- href = '#' + node['refid']
- elif node.has_key('refname'):
- href = '#' + self.document.nameids[node['refname']]
- self.body.append(self.starttag(node, 'a', '', href=href,
- CLASS='reference'))
-
- def depart_reference(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</a>')
-
- def visit_revision(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'revision', meta=None)
-
- def depart_revision(self, node):
- self.depart_docinfo_item()
-
- def visit_row(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'tr', ''))
-
- def depart_row(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</tr>\n')
-
- def visit_section(self, node):
- raise NotImplementedError, node.astext()
- self.section_level += 1
- self.body.append(self.starttag(node, 'div', CLASS='section'))
-
- def depart_section(self, node):
- raise NotImplementedError, node.astext()
- self.section_level -= 1
- self.body.append('</div>\n')
-
- def visit_status(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'status', meta=None)
-
- def depart_status(self, node):
- self.depart_docinfo_item()
-
- def visit_strong(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('<strong>')
-
- def depart_strong(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</strong>')
-
- def visit_substitution_definition(self, node):
- """Internal only."""
- raise nodes.SkipNode
-
- def visit_substitution_reference(self, node):
- self.unimplemented_visit(node)
-
- def visit_subtitle(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'h2', '', CLASS='subtitle'))
-
- def depart_subtitle(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</h2>\n')
-
- def visit_system_message(self, node):
- raise NotImplementedError, node.astext()
- if node['level'] < self.document.reporter['writer'].report_level:
- # Level is too low to display:
- raise nodes.SkipNode
- self.body.append(self.starttag(node, 'div', CLASS='system-message'))
- self.body.append('<p class="system-message-title">')
- attr = {}
- backref_text = ''
- if node.hasattr('id'):
- attr['name'] = node['id']
- if node.hasattr('backrefs'):
- backrefs = node['backrefs']
- if len(backrefs) == 1:
- backref_text = ('; <em><a href="#%s">backlink</a></em>'
- % backrefs[0])
- else:
- i = 1
- backlinks = []
- for backref in backrefs:
- backlinks.append('<a href="#%s">%s</a>' % (backref, i))
- i += 1
- backref_text = ('; <em>backlinks: %s</em>'
- % ', '.join(backlinks))
- if node.hasattr('line'):
- line = ', line %s' % node['line']
- else:
- line = ''
- if attr:
- a_start = self.starttag({}, 'a', '', **attr)
- a_end = '</a>'
- else:
- a_start = a_end = ''
- self.body.append('System Message: %s%s/%s%s (<tt>%s</tt>%s)%s</p>\n'
- % (a_start, node['type'], node['level'], a_end,
- node['source'], line, backref_text))
-
- def depart_system_message(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</div>\n')
-
- def visit_table(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(
- self.starttag(node, 'table', CLASS="table",
- frame='border', rules='all'))
-
- def depart_table(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</table>\n')
-
- def visit_target(self, node):
- raise NotImplementedError, node.astext()
- if not (node.has_key('refuri') or node.has_key('refid')
- or node.has_key('refname')):
- self.body.append(self.starttag(node, 'a', '', CLASS='target'))
- self.context.append('</a>')
- else:
- self.context.append('')
-
- def depart_target(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.context.pop())
-
- def visit_tbody(self, node):
- raise NotImplementedError, node.astext()
- self.write_colspecs()
- self.body.append(self.context.pop()) # '</colgroup>\n' or ''
- self.body.append(self.starttag(node, 'tbody', valign='top'))
-
- def depart_tbody(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</tbody>\n')
-
- def visit_term(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'dt', ''))
-
- def depart_term(self, node):
- """
- Leave the end tag to `self.visit_definition()`, in case there's a
- classifier.
- """
- raise NotImplementedError, node.astext()
- pass
-
- def visit_tgroup(self, node):
- raise NotImplementedError, node.astext()
- # Mozilla needs <colgroup>:
- self.body.append(self.starttag(node, 'colgroup'))
- # Appended by thead or tbody:
- self.context.append('</colgroup>\n')
-
- def depart_tgroup(self, node):
- pass
-
- def visit_thead(self, node):
- raise NotImplementedError, node.astext()
- self.write_colspecs()
- self.body.append(self.context.pop()) # '</colgroup>\n'
- # There may or may not be a <thead>; this is for <tbody> to use:
- self.context.append('')
- self.body.append(self.starttag(node, 'thead', valign='bottom'))
-
- def depart_thead(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</thead>\n')
-
- def visit_tip(self, node):
- self.visit_admonition(node, 'tip')
-
- def depart_tip(self, node):
- self.depart_admonition()
-
- def visit_title(self, node):
- raise NotImplementedError, node.astext()
- """Only 6 section levels are supported by HTML."""
- if isinstance(node.parent, nodes.topic):
- self.body.append(
- self.starttag(node, 'p', '', CLASS='topic-title'))
- if node.parent.hasattr('id'):
- self.body.append(
- self.starttag({}, 'a', '', name=node.parent['id']))
- self.context.append('</a></p>\n')
- else:
- self.context.append('</p>\n')
- elif self.section_level == 0:
- # document title
- self.head.append('<title>%s</title>\n'
- % self.encode(node.astext()))
- self.body.append(self.starttag(node, 'h1', '', CLASS='title'))
- self.context.append('</h1>\n')
- else:
- self.body.append(
- self.starttag(node, 'h%s' % self.section_level, ''))
- atts = {}
- if node.parent.hasattr('id'):
- atts['name'] = node.parent['id']
- if node.hasattr('refid'):
- atts['class'] = 'toc-backref'
- atts['href'] = '#' + node['refid']
- self.body.append(self.starttag({}, 'a', '', **atts))
- self.context.append('</a></h%s>\n' % (self.section_level))
-
- def depart_title(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.context.pop())
-
- def visit_title_reference(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'cite', ''))
-
- def depart_title_reference(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</cite>')
-
- def visit_topic(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.starttag(node, 'div', CLASS='topic'))
- self.topic_class = node.get('class')
-
- def depart_topic(self, node):
- raise NotImplementedError, node.astext()
- self.body.append('</div>\n')
- self.topic_class = ''
-
- def visit_transition(self, node):
- raise NotImplementedError, node.astext()
- self.body.append(self.emptytag(node, 'hr'))
-
- def depart_transition(self, node):
- pass
-
- def visit_version(self, node):
- raise NotImplementedError, node.astext()
- self.visit_docinfo_item(node, 'version', meta=None)
-
- def depart_version(self, node):
- self.depart_docinfo_item()
-
- def visit_warning(self, node):
- self.visit_admonition(node, 'warning')
-
- def depart_warning(self, node):
- self.depart_admonition()
-
- def unimplemented_visit(self, node):
- raise NotImplementedError('visiting unimplemented node type: %s'
- % node.__class__.__name__)
-
-
-class SimpleListChecker(nodes.GenericNodeVisitor):
-
- """
- Raise `nodes.SkipNode` if non-simple list item is encountered.
-
- Here "simple" means a list item containing nothing other than a single
- paragraph, a simple list, or a paragraph followed by a simple list.
- """
-
- def default_visit(self, node):
- raise nodes.NodeFound
-
- def visit_bullet_list(self, node):
- pass
-
- def visit_enumerated_list(self, node):
- pass
-
- def visit_list_item(self, node):
- children = []
- for child in node.get_children():
- if not isinstance(child, nodes.Invisible):
- children.append(child)
- if (children and isinstance(children[0], nodes.paragraph)
- and (isinstance(children[-1], nodes.bullet_list)
- or isinstance(children[-1], nodes.enumerated_list))):
- children.pop()
- if len(children) <= 1:
- return
- else:
- raise nodes.NodeFound
-
- def visit_paragraph(self, node):
- raise nodes.SkipNode
-
- def invisible_visit(self, node):
- """Invisible nodes should be ignored."""
- pass
-
- visit_comment = invisible_visit
- visit_substitution_definition = invisible_visit
- visit_target = invisible_visit
- visit_pending = invisible_visit
diff --git a/sandbox/pobrien/dwArticle/__init__.py b/sandbox/pobrien/dwArticle/__init__.py
deleted file mode 100644
index db6003cf3..000000000
--- a/sandbox/pobrien/dwArticle/__init__.py
+++ /dev/null
@@ -1 +0,0 @@
-# Orbtech python package. \ No newline at end of file