summaryrefslogtreecommitdiff
path: root/sandbox/aahz/OO
diff options
context:
space:
mode:
Diffstat (limited to 'sandbox/aahz/OO')
-rw-r--r--sandbox/aahz/OO/Makefile27
-rw-r--r--sandbox/aahz/OO/OOdirectives.py72
-rw-r--r--sandbox/aahz/OO/OOtext.py127
-rw-r--r--sandbox/aahz/OO/OOwriter.py676
-rw-r--r--sandbox/aahz/OO/graphics_output.py28
-rw-r--r--sandbox/aahz/OO/open_office.py33
-rwxr-xr-xsandbox/aahz/OO/publish.py27
7 files changed, 0 insertions, 990 deletions
diff --git a/sandbox/aahz/OO/Makefile b/sandbox/aahz/OO/Makefile
deleted file mode 100644
index 57b826b59..000000000
--- a/sandbox/aahz/OO/Makefile
+++ /dev/null
@@ -1,27 +0,0 @@
-export PYTHON=python
-export PYTHONPATH=$(HOME)/src/Lib-Python
-MAIN=$(HOME)/write/effective/book
-
-CHAPTER=Way
-CHAPTER=Control
-CHAPTER=Objects
-CHAPTER=Data
-
-SRCDIR=$(MAIN)/tmp/$(CHAPTER)
-SRCDIR=$(MAIN)/Chapters/$(CHAPTER)
-SRC=$(SRCDIR)/$(CHAPTER)
-
-DESTDIR=$(MAIN)/Output/$(CHAPTER)
-DESTDIR=$(MAIN)/Output/upload
-DEST=$(DESTDIR)/$(CHAPTER).sxw
-
-#DEST=$(MAIN)/Output/foo.xml
-
-GRAPH_TYPE=pdf
-GRAPH_TYPE=eps
-
-test:
- #$(PYTHON) force_mkdir.py $(DESTDIR)
- $(PYTHON) graphics_output.py $(GRAPH_TYPE) $(SRCDIR) $(DESTDIR)
- $(PYTHON) open_office.py $(SRC) $(DEST)
- #$(PYTHON) publish.py $(SRC) > $(DEST)
diff --git a/sandbox/aahz/OO/OOdirectives.py b/sandbox/aahz/OO/OOdirectives.py
deleted file mode 100644
index e437f6fbf..000000000
--- a/sandbox/aahz/OO/OOdirectives.py
+++ /dev/null
@@ -1,72 +0,0 @@
-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/aahz/OO/OOtext.py b/sandbox/aahz/OO/OOtext.py
deleted file mode 100644
index 9651a10c6..000000000
--- a/sandbox/aahz/OO/OOtext.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# Can't have blank line at beginning of XML
-
-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="StarSymbol" fo:font-family="StarSymbol" style:font-charset="x-symbol"/>
- <style:font-decl style:name="Courier" fo:font-family="Courier" style:font-family-generic="modern" style:font-pitch="fixed"/>
- <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="Thorndale" fo:font-family="Thorndale" style:font-family-generic="roman" style:font-pitch="variable"/>
- </office:font-decls>
- <office:styles>
- <style:default-style style:family="graphics">
- <style:properties draw:start-line-spacing-horizontal="0.283cm" draw:start-line-spacing-vertical="0.283cm" draw:end-line-spacing-horizontal="0.283cm" draw:end-line-spacing-vertical="0.283cm" fo:color="#000000" style:font-name="Thorndale" fo:font-size="12pt" fo:language="en" fo:country="US" 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="hanging" 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="Thorndale" fo:font-size="12pt" fo:language="en" fo:country="US" 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="2.205cm"/>
- </style:default-style>
- <style:style style:name="Standard" style:family="paragraph" style:class="text"/>
- <style:style style:name=".body" style:family="paragraph" style:parent-style-name="Standard"/>
- <style:style style:name=".CALLOUT" style:family="paragraph" style:parent-style-name=".body"/>
- <style:style style:name=".figure" style:family="paragraph" style:parent-style-name=".body"/>
- <style:style style:name=".quotes" style:family="paragraph" style:parent-style-name=".body">
- <style:properties fo:margin-left="2cm" fo:margin-right="2cm" fo:text-indent="0cm" style:auto-text-indent="false"/>
- </style:style>
- <style:list-style style:name=".bullet"/>
- <style:style style:name=".ch title" style:family="paragraph" style:parent-style-name=".body">
- <style:properties style:font-size="24pt" fo:font-size="24pt"/>
- </style:style>
- <style:style style:name=".head 1" style:family="paragraph" style:parent-style-name=".body">
- <style:properties style:font-size="20pt" fo:font-size="20pt"/>
- </style:style>
- <style:style style:name=".head 2" style:family="paragraph" style:parent-style-name=".body">
- <style:properties style:font-size="16pt" fo:font-size="16pt"/>
- </style:style>
- <style:style style:name=".code" style:family="paragraph" style:parent-style-name=".body">
- <style:properties style:font-name="Courier"/>
- </style:style>
- <style:style style:name=".code first" style:family="paragraph" style:parent-style-name=".body"/>
- <style:style style:name=".code last" style:family="paragraph" style:parent-style-name=".body"/>
- <style:style style:name="Footnote Symbol" style:family="text"/>
- <style:style style:name="Bullet Symbols" style:family="text">
- <style:properties style:font-name="StarSymbol" fo:font-size="9pt" style:font-name-complex="StarSymbol" style:font-size-complex="9pt"/>
- </style:style>
- <style:style style:name="Footnote anchor" style:family="text">
- <style:properties style:text-position="super 58%"/>
- </style:style>
- <style:style style:name="code" style:family="text">
- <style:properties style:font-name="Courier"/>
- </style:style>
- <style:style style:name="italic" style:family="text">
- <style:properties fo:font-style="italic"/>
- </style:style>
- <text:outline-style>
- <text:outline-level-style text:level="1" style:num-format=""/>
- <text:outline-level-style text:level="2" style:num-format=""/>
- <text:outline-level-style text:level="3" style:num-format=""/>
- <text:outline-level-style text:level="4" style:num-format=""/>
- <text:outline-level-style text:level="5" style:num-format=""/>
- <text:outline-level-style text:level="6" style:num-format=""/>
- <text:outline-level-style text:level="7" style:num-format=""/>
- <text:outline-level-style text:level="8" style:num-format=""/>
- <text:outline-level-style text:level="9" style:num-format=""/>
- <text:outline-level-style text:level="10" style:num-format=""/>
- </text:outline-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.499cm" style:num-format="1" text:number-position="left" text:increment="5"/>
- </office:styles>
- <office:automatic-styles>
- <style:page-master style:name="pm1">
- <style:properties fo:page-width="20.999cm" fo:page-height="29.699cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2.54cm" fo:margin-bottom="2.54cm" fo:margin-left="0cm" fo:margin-right="5cm" style:footnote-max-height="0cm">
- <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
- </style:properties>
- <style:header-style/>
- <style:footer-style/>
- </style:page-master>
- <style:page-master style:name="pm2">
- <style:properties fo:page-width="20.999cm" fo:page-height="29.699cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:footnote-max-height="0cm">
- <style:footnote-sep style:adjustment="left" style:rel-width="25%" style:color="#000000"/>
- </style:properties>
- <style:header-style/>
- <style:footer-style/>
- </style:page-master>
- </office:automatic-styles>
- <office:master-styles>
- <style:master-page style:name="Standard" style:page-master-name="pm1"/>
- <style:master-page style:name="Footnote" style:page-master-name="pm2"/>
- </office:master-styles>
-</office:document-styles>
-'''
-
-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="/"/>
- <manifest:file-entry manifest:media-type="" manifest:full-path="Pictures/"/>
- %s
-</manifest:manifest>
-'''
-
-manifest_format = '<manifest:file-entry manifest:media-type="text/xml" manifest:full-path="%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:script/>
- <office:font-decls>
- <style:font-decl style:name="Courier" fo:font-family="Courier" style:font-family-generic="modern" style:font-pitch="fixed"/>
- <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="Thorndale" fo:font-family="Thorndale" style:font-family-generic="roman" style:font-pitch="variable"/>
- </office:font-decls>
- <office:automatic-styles/>
- <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>
-'''
diff --git a/sandbox/aahz/OO/OOwriter.py b/sandbox/aahz/OO/OOwriter.py
deleted file mode 100644
index 6a0841040..000000000
--- a/sandbox/aahz/OO/OOwriter.py
+++ /dev/null
@@ -1,676 +0,0 @@
-# Author: Aahz
-# Contact: aahz@pythoncraft.com
-# Revision:
-# Date: $Date$
-# Copyright: This module has been placed in the public domain.
-
-"""
-OpenOffice writer
-
-The output is an OpenOffice.org 1.0-compatible document.
-"""
-
-__docformat__ = 'reStructuredText'
-
-
-import sys
-from warnings import warn
-import re
-
-import docutils
-from docutils import nodes, utils, writers, languages
-
-import OOtext
-
-
-section_styles = [
- '.ch title',
- '.head 1',
- '.head 2'
- ]
-
-class Writer(writers.Writer):
-
- supported = ('OpenOffice')
- """Formats this writer supports."""
-
- def __init__(self):
- writers.Writer.__init__(self)
- self.output = None
- 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
-
- def astext(self):
- 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 = True
- self.body.append(self.start_para % '.CALLOUT')
-
- def depart_admonition(self):
- self.body.append(self.end_para)
- self.skip_para_tag = False
-
- 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
-
- def visit_bullet_list(self, node):
- self.body.append('\n<text:unordered-list text:style-name=".bullet">\n')
-
- def depart_bullet_list(self, node):
- self.body.append('</text:unordered-list>\n')
-
- def visit_caption(self, node):
- self.body.append(self.starttag(node, 'p', '', CLASS='caption'))
-
- def depart_caption(self, node):
- 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):
- 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:
- 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):
- pass
-
- def depart_decoration(self, node):
- pass
-
- def visit_definition(self, node):
- self.body.append('</dt>\n')
- self.body.append(self.starttag(node, 'dd', ''))
- if len(node) and isinstance(node[0], nodes.paragraph):
- node[0].set_class('first')
-
- def depart_definition(self, node):
- self.body.append('</dd>\n')
-
- def visit_definition_list(self, node):
- print node.astext()
- self.body.append(self.starttag(node, 'dl'))
-
- def depart_definition_list(self, node):
- 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):
- self.body.append(self.starttag(node, 'td', ''))
- if len(node) and isinstance(node[0], nodes.paragraph):
- node[0].set_class('first')
-
- def depart_description(self, node):
- self.body.append('</td>')
-
- 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 % 'italic')
-
- def depart_emphasis(self, node):
- self.body.append(self.end_charstyle)
-
- def visit_entry(self, node):
- 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;')
- elif isinstance(node[0], nodes.paragraph):
- node[0].set_class('first')
-
- def depart_entry(self, node):
- self.body.append(self.context.pop())
-
- def visit_enumerated_list(self, node):
- """
- 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.options.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):
- 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):
- self.body.append(self.starttag(node, 'tr', '', CLASS='field'))
-
- def depart_field(self, node):
- self.body.append('</tr>\n')
-
- def visit_field_body(self, node):
- self.body.append(self.starttag(node, 'td', '', CLASS='field-body'))
- if len(node) and isinstance(node[0], nodes.paragraph):
- node[0].set_class('first')
-
- def depart_field_body(self, node):
- self.body.append('</td>\n')
-
- def visit_field_list(self, node):
- 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):
- self.body.append('</tbody>\n</table>\n')
-
- def visit_field_name(self, node):
- 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):
- self.body.append(':</th>')
- self.body.append(self.context.pop())
-
- def visit_figure(self, node):
- self.body.append(self.start_para % '.figure')
-
- def depart_figure(self, node):
- self.body.append(self.end_para)
-
- 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 = "Figure: %s\n" % node.attributes['uri']
- self.body.append(name)
-
- 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_interpreted(self, node):
- # @@@ Incomplete, pending a proper implementation on the
- # Parser/Reader end.
- #self.body.append(node['role'] + ':')
- self.body.append(node.astext())
- raise nodes.SkipNode
-
- def depart_interpreted(self, node):
- pass
-
- # Don't need footnote labels/numbers
- def visit_label(self, node):
- print "!"
- raise nodes.SkipNode
-
- def visit_legend(self, node):
- self.body.append(self.starttag(node, 'div', CLASS='legend'))
-
- def depart_legend(self, node):
- self.body.append('</div>\n')
-
- 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>')
-
- 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)
- raise nodes.SkipNode
-
- def visit_note(self, node):
- self.visit_admonition(node, '.note')
-
- def depart_note(self, node):
- self.depart_admonition()
-
- def visit_option(self, node):
- if self.context[-1]:
- self.body.append(', ')
-
- def depart_option(self, node):
- self.context[-1] += 1
-
- def visit_option_argument(self, node):
- self.body.append(node.get('delimiter', ' '))
- self.body.append(self.starttag(node, 'var', ''))
-
- def depart_option_argument(self, node):
- self.body.append('</var>')
-
- def visit_option_group(self, node):
- 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):
- self.context.pop()
- self.body.append('</kbd></td>\n')
- self.body.append(self.context.pop())
-
- def visit_option_list(self, node):
- 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):
- self.body.append('</tbody>\n</table>\n')
-
- def visit_option_list_item(self, node):
- self.body.append(self.starttag(node, 'tr', ''))
-
- def depart_option_list_item(self, node):
- self.body.append('</tr>\n')
-
- def visit_option_string(self, node):
- self.body.append(self.starttag(node, 'span', '', CLASS='option'))
-
- def depart_option_string(self, node):
- self.body.append('</span>')
-
- def visit_paragraph(self, node):
- if not self.skip_para_tag:
- self.body.append(self.start_para % '.body')
-
- def depart_paragraph(self, node):
- if not self.skip_para_tag:
- self.body.append(self.end_para)
-
- def visit_problematic(self, node):
- 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):
- self.body.append('</span>')
- self.body.append(self.context.pop())
-
- def visit_raw(self, node):
- if node.has_key('format') and node['format'] == 'html':
- self.body.append(node.astext())
- raise nodes.SkipNode
-
- def visit_reference(self, node):
- pass
-
- def depart_reference(self, node):
- pass
-
- def visit_row(self, node):
- self.body.append(self.starttag(node, 'tr', ''))
-
- def depart_row(self, node):
- self.body.append('</tr>\n')
-
- def visit_section(self, node):
- self.section_level += 1
-
- def depart_section(self, node):
- self.section_level -= 1
-
- def visit_strong(self, node):
- self.body.append('<strong>')
-
- def depart_strong(self, node):
- self.body.append('</strong>')
-
- def visit_table(self, node):
- self.body.append(
- self.starttag(node, 'table', CLASS="table",
- frame='border', rules='all'))
-
- def depart_table(self, node):
- self.body.append('</table>\n')
-
- def visit_target(self, node):
- 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):
- self.body.append(self.context.pop())
-
- def visit_tbody(self, node):
- 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):
- self.body.append('</tbody>\n')
-
- def visit_term(self, node):
- 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.
- """
- pass
-
- def visit_tgroup(self, node):
- # 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):
- 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):
- 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):
- """Only 3 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_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 "Failure processing at line", node.line
- print "Failure is", node.astext()
- raise NotImplementedError('visiting unimplemented node type: %s'
- % node.__class__.__name__)
diff --git a/sandbox/aahz/OO/graphics_output.py b/sandbox/aahz/OO/graphics_output.py
deleted file mode 100644
index 35d2f9516..000000000
--- a/sandbox/aahz/OO/graphics_output.py
+++ /dev/null
@@ -1,28 +0,0 @@
-import sys
-import os
-
-SOURCE_EXT = '.fig'
-
-TypeList = {
- 'eps': {
- 'ext': '.eps',
- 'cmd': 'fig2dev -L eps %s %s'
- },
- 'pdf': {
- 'ext': '.pdf',
- 'cmd': 'fig2dev -L pdf %s %s'
- }
- }
-
-type = TypeList[sys.argv[1]]
-SourceDir = sys.argv[2]
-DestDir = sys.argv[3]
-
-for name in os.listdir(SourceDir):
- base, ext = os.path.splitext(name)
- if ext == SOURCE_EXT:
- src = SourceDir + '/' + name
- dest = DestDir + '/' + base + type['ext']
- cmd = type['cmd'] % (src, dest)
- print cmd
- os.system(cmd)
diff --git a/sandbox/aahz/OO/open_office.py b/sandbox/aahz/OO/open_office.py
deleted file mode 100644
index 90e4c4393..000000000
--- a/sandbox/aahz/OO/open_office.py
+++ /dev/null
@@ -1,33 +0,0 @@
-import sys
-import zipfile
-from cStringIO import StringIO
-
-from docutils import core, io
-
-import OOdirectives
-import OOtext
-import OOwriter
-
-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()
-
-manifest_list = [
- ('content.xml', content),
- ('styles.xml', OOtext.styles)
- ]
-
-manifest_entries = []
-for docname, _ in manifest_list:
- manifest_entries.append(OOtext.manifest_format % docname)
-manifest = OOtext.manifest % '\n '.join(manifest_entries)
-manifest_list.append( ('META-INF/manifest.xml', manifest) )
-
-zip = zipfile.ZipFile(sys.argv[2], "w")
-for docname, contents in manifest_list:
- zinfo = zipfile.ZipInfo(docname)
- zip.writestr(zinfo, contents)
-zip.close()
diff --git a/sandbox/aahz/OO/publish.py b/sandbox/aahz/OO/publish.py
deleted file mode 100755
index 006d3fd97..000000000
--- a/sandbox/aahz/OO/publish.py
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/usr/bin/env python
-
-# Author: David Goodger
-# Contact: goodger@users.sourceforge.net
-# Revision: $Revision$
-# Date: $Date$
-# Copyright: This module has been placed in the public domain.
-
-"""
-A minimal front end to the Docutils Publisher, producing pseudo-XML.
-"""
-
-import locale
-try:
- locale.setlocale(locale.LC_ALL, '')
-except:
- pass
-
-from docutils.core import publish, default_description
-
-import OOdirectives
-
-
-description = ('Generates pseudo-XML from standalone reStructuredText '
- 'sources (for testing purposes). ' + default_description)
-
-publish(description=description)