rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
if isinstance(node[0], nodes.title):
if len(node) and isinstance(node[0], nodes.title):
def visit_document(self, node): self.body_prefix.append('\\begin{document}\n') # titled document? if isinstance(node[0], nodes.title): self.body_prefix.append('\\maketitle\n\n') # alternative use titlepage environment. # \begin{titlepage} self.body.append('\n\\setlength{\\locallinewidth}{\\linewidth}\n')
self.within_title = 0
self.in_document_title = 0
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.meta = [self.content_type % settings.output_encoding, self.generator % docutils.__version__] self.head_prefix = [ self.d...
self.body_pre_docinfo = self.body[:start]
def depart_docinfo(self, node): 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 = []
else:
elif isinstance(node.parent, nodes.document):
def visit_subtitle(self, node): if isinstance(node.parent, nodes.sidebar): self.body.append(self.starttag(node, 'p', '', CLASS='sidebar-subtitle')) self.context.append('</p>\n') else: self.body.append(self.starttag(node, 'h2', '', CLASS='subtitle')) self.context.append('</h2>\n') self.within_title = len(self.body)
self.within_title = len(self.body)
self.in_document_title = len(self.body)
def visit_subtitle(self, node): if isinstance(node.parent, nodes.sidebar): self.body.append(self.starttag(node, 'p', '', CLASS='sidebar-subtitle')) self.context.append('</p>\n') else: self.body.append(self.starttag(node, 'h2', '', CLASS='subtitle')) self.context.append('</h2>\n') self.within_title = len(self.body)
if self.within_title: self.subtitle = self.body[self.within_title:] self.within_title = 0
def depart_subtitle(self, node): if self.within_title: self.subtitle = self.body[self.within_title:] self.within_title = 0 self.body.append(self.context.pop())
self.within_title = len(self.body)
self.in_document_title = len(self.body)
def visit_title(self, node): """Only 6 section levels are supported by HTML.""" check_id = 0 close_tag = '</p>\n' if isinstance(node.parent, nodes.topic): self.body.append( self.starttag(node, 'p', '', CLASS='topic-title first')) check_id = 1 elif isinstance(node.parent, nodes.sidebar): self.body.append( self.starttag(...
if self.within_title: self.title = self.body[self.within_title:] self.within_title = 0
def depart_title(self, node): if self.within_title: self.title = self.body[self.within_title:] self.within_title = 0 self.body.append(self.context.pop())
def visit_author(self, node): pass def depart_author(self, node): pass def visit_authors(self, node): pass def depart_authors(self, node): pass 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_pa...
## def visit_(self, node):
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'...
def visit_citation(self, node): self.body.append(self.starttag(node, 'table', CLASS='citation', frame="void", rules="none")) self.footnote_backrefs(node)
colwidth = int(node['colwidth'] * 100.0 / width + 0.5) self.body.append(self.emptytag(node, 'col', colwidth='%i%%' % colwidth))
self.body.append('<table:table-column/>')
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_date(self, node): pass def depart_date(self, node): pass
def visit_date(self, node): pass
pass
raise nodes.SkipNode
def visit_decoration(self, node): pass
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')
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')
self.body.append('</dd>\n')
pass
def depart_definition(self, node): self.body.append('</dd>\n')
print node.astext() self.body.append(self.starttag(node, 'dl'))
pass
def visit_definition_list(self, node): print node.astext() self.body.append(self.starttag(node, 'dl'))
self.body.append('</dl>\n')
pass
def depart_definition_list(self, node): self.body.append('</dl>\n')
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 depart_definition_list_item(self, node): pass
self.body.append(self.start_charstyle % 'italic')
self.body.append(self.start_charstyle % 'Emphasis')
def visit_emphasis(self, node): self.body.append(self.start_charstyle % 'italic')
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' %...
self.body.append('<table:table-cell table:value-type="string">\n')
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)) se...
self.body.append(self.context.pop())
self.body.append('</table:table-cell>\n')
def depart_entry(self, node): self.body.append(self.context.pop())
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...
def visit_field(self, node): self.body.append(self.starttag(node, 'tr', '', CLASS='field'))
def footnote_backrefs(self, node): warn("footnote backrefs not available")
def footnote_backrefs(self, node): warn("footnote backrefs not available")
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) sel...
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) sel...
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_header(self, node): self.context.append(len(self.body))
def visit_interpreted(self, node): self.body.append(node.astext()) raise nodes.SkipNode def depart_interpreted(self, node): pass 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): s...
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 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(...
def visit_option(self, node): if self.context[-1]: self.body.append(', ')
def visit_problematic(self, node): if node.hasattr('refid'): self.body.append('<a href=" 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.co...
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 visit_revision(self, node): pass def depart_revision(self, node): pass
def visit_revision(self, node): pass
self.body.append(self.starttag(node, 'tr', ''))
self.body.append('<table:table-row>\n')
def visit_row(self, node): self.body.append(self.starttag(node, 'tr', ''))
self.body.append('</tr>\n')
self.body.append('</table:table-row>\n')
def depart_row(self, node): self.body.append('</tr>\n')
self.body.append('<strong>')
self.body.append(self.start_charstyle % 'Strong Emphasis')
def visit_strong(self, node): self.body.append('<strong>')
self.body.append('</strong>')
self.body.append(self.end_charstyle)
def depart_strong(self, node): self.body.append('</strong>')
self.body.append( self.starttag(node, 'table', CLASS="table", frame='border', rules='all'))
self.body.append('<table:table>\n')
def visit_table(self, node): self.body.append( self.starttag(node, 'table', CLASS="table", frame='border', rules='all'))
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(sel...
self.body.append('</table:table>\n') self.bodyOne = True
def depart_table(self, node): self.body.append('</table>\n')
self.body.append(self.context.pop()) self.body.append(self.starttag(node, 'tbody', valign='top'))
self.inTableBody = True
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'))
self.body.append('</tbody>\n')
self.inTableBody = False
def depart_tbody(self, node): self.body.append('</tbody>\n')
self.body.append(self.starttag(node, 'dt', ''))
self.bodyOne = True self.visit_paragraph(node) self.body.append(self.start_charstyle % 'Strong Emphasis')
def visit_term(self, node): self.body.append(self.starttag(node, 'dt', ''))
pass
self.body.append(self.end_charstyle) self.depart_paragraph(node)
def depart_term(self, node): """ Leave the end tag to `self.visit_definition()`, in case there's a classifier. """ pass
self.body.append(self.starttag(node, 'colgroup')) self.context.append('</colgroup>\n')
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')
self.body.append(self.context.pop()) self.context.append('') self.body.append(self.starttag(node, 'thead', valign='bottom'))
self.inTableHead = True
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'))
self.body.append('</thead>\n')
self.inTableHead = False
def depart_thead(self, node): self.body.append('</thead>\n')
print "Failure processing at line", node.line print "Failure is", node.astext() raise NotImplementedError('visiting unimplemented node type: %s'
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'
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__)
if inlines: assert len(inlines) == 1
if len(inlines) == 1:
def substitution_reference(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inlineobj( match, lineno, self.inline.patterns.substitution_ref, nodes.substitution_reference) if inlines: assert len(inlines) == 1 subrefnode = inlines[0] assert isinstance(subrefnode, nodes.substitution_referenc...
assert isinstance(subrefnode, nodes.substitution_reference) subreftext = subrefnode.astext() refname = normname(subreftext) subrefnode['refname'] = refname self.statemachine.memo.document.note_substitution_ref(subrefnode) if endstring[-1:] == '_': referencenode = nodes.reference('|%s%s' % (subreftext, endstring), '') i...
if isinstance(subrefnode, nodes.substitution_reference): subreftext = subrefnode.astext() refname = normname(subreftext) subrefnode['refname'] = refname self.statemachine.memo.document.note_substitution_ref( subrefnode) if endstring[-1:] == '_': referencenode = nodes.reference( '|%s%s' % (subreftext, endstring), '') if...
def substitution_reference(self, match, lineno): before, inlines, remaining, sysmessages, endstring = self.inlineobj( match, lineno, self.inline.patterns.substitution_ref, nodes.substitution_reference) if inlines: assert len(inlines) == 1 subrefnode = inlines[0] assert isinstance(subrefnode, nodes.substitution_referenc...
def unindentwarning(self):
def unindent_warning(self, node_name):
def unindentwarning(self): return self.statemachine.memo.reporter.warning( ('Unindent without blank line at line %s.' % (self.statemachine.abslineno() + 1)))
('Unindent without blank line at line %s.' % (self.statemachine.abslineno() + 1)))
('%s ends without a blank line; unexpected unindent at line %s.' % (node_name, self.statemachine.abslineno() + 1)))
def unindentwarning(self): return self.statemachine.memo.reporter.warning( ('Unindent without blank line at line %s.' % (self.statemachine.abslineno() + 1)))
self.statemachine.node += self.unindentwarning()
self.statemachine.node += self.unindent_warning('Block quote')
def indent(self, match, context, nextstate): """Block quote.""" indented, indent, lineoffset, blankfinish = \ self.statemachine.getindented() blockquote = self.block_quote(indented, lineoffset) self.statemachine.node += blockquote if not blankfinish: self.statemachine.node += self.unindentwarning() return context, next...
self.statemachine.node += self.unindentwarning()
self.statemachine.node += self.unindent_warning('Bullet list')
def bullet(self, match, context, nextstate): """Bullet list item.""" bulletlist = nodes.bullet_list() self.statemachine.node += bulletlist bulletlist['bullet'] = match.string[0] i, blankfinish = self.list_item(match.end()) bulletlist += i offset = self.statemachine.lineoffset + 1 # next line newlineoffset, blankfinis...
self.statemachine.node += self.unindentwarning()
self.statemachine.node += self.unindent_warning( 'Enumerated list')
def enumerator(self, match, context, nextstate): """Enumerated List Item""" format, sequence, text, ordinal = self.parse_enumerator(match) if ordinal is None: msg = self.statemachine.memo.reporter.error( ('Enumerated list start value invalid at line %s: ' '%r (sequence %r)' % (self.statemachine.abslineno(), text, seque...
self.statemachine.node += self.unindentwarning()
self.statemachine.node += self.unindent_warning('Field list')
def field_marker(self, match, context, nextstate): """Field list item.""" fieldlist = nodes.field_list() self.statemachine.node += fieldlist field, blankfinish = self.field(match) fieldlist += field offset = self.statemachine.lineoffset + 1 # next line newlineoffset, blankfinish = self.nestedlistparse( self.statemach...
self.statemachine.node += self.unindentwarning()
self.statemachine.node += self.unindent_warning('Option list')
def option_marker(self, match, context, nextstate): """Option list item.""" optionlist = nodes.option_list() try: listitem, blankfinish = self.option_list_item(match) except MarkupError, detail: # shouldn't happen; won't match pattern msg = self.statemachine.memo.reporter.error( ('Invalid option list marker at line...
self.statemachine.node += self.unindentwarning()
self.statemachine.node += self.unindent_warning('Explicit markup')
def explicitlist(self, blankfinish): """ Create a nested state machine for a series of explicit markup constructs (including anonymous hyperlink targets). """ offset = self.statemachine.lineoffset + 1 # next line newlineoffset, blankfinish = self.nestedlistparse( self.statemachine.inputlines[offset:], inputoffset=sel...
self.statemachine.node += self.unindentwarning()
self.statemachine.node += self.unindent_warning('Definition list')
def indent(self, match, context, nextstate): """Definition list item.""" definitionlist = nodes.definition_list() definitionlistitem, blankfinish = self.definition_list_item(context) definitionlist += definitionlistitem self.statemachine.node += definitionlist offset = self.statemachine.lineoffset + 1 # next line new...
nodelist.append(self.unindentwarning())
nodelist.append(self.unindent_warning('Literal block'))
def literal_block(self): """Return a list of nodes.""" indented, indent, offset, blankfinish = \ self.statemachine.getindented() nodelist = [] while indented and not indented[-1].strip(): indented.pop() if indented: data = '\n'.join(indented) nodelist.append(nodes.literal_block(data, data)) if not blankfinish: nodelist...
reftarget = None if self.document.explicit_targets.has_key(refname): reftarget = self.document.explicit_targets[refname] elif self.document.implicit_targets.has_key(refname): reftarget = self.document.implicit_targets[refname] if not reftarget:
reftarget_id = self.document.nameids.get(refname) if not reftarget_id:
def resolve_indirect_target(self, target): refname = target['refname'] reftarget = None if self.document.explicit_targets.has_key(refname): reftarget = self.document.explicit_targets[refname] elif self.document.implicit_targets.has_key(refname): reftarget = self.document.implicit_targets[refname] if not reftarget: self...
reflist = self.document.refnames[target['name']]
reflist = self.document.refnames.get(target['name'], [])
def nonexistent_indirect_target(self, target): naming = '' if target.hasattr('name'): naming = '"%s" ' % target['name'] reflist = self.document.refnames[target['name']] else: reflist = self.document.refnames[target['id']] naming += '(id="%s")' % target['id'] msg = self.document.reporter.warning( 'Indirect hyperlink tar...
reflist = self.document.refnames[target['id']]
reflist = self.document.refids.get(target['id'], [])
def nonexistent_indirect_target(self, target): naming = '' if target.hasattr('name'): naming = '"%s" ' % target['name'] reflist = self.document.refnames[target['name']] else: reflist = self.document.refnames[target['id']] naming += '(id="%s")' % target['id'] msg = self.document.reporter.warning( 'Indirect hyperlink tar...
if not self.document.explicit_targets.has_key(label):
if not self.document.nameids.has_key(label):
def number_footnotes(self, startnum): """ Assign numbers to autonumbered footnotes.
footnote = self.document.explicit_targets[label] ref['refid'] = footnote['id']
id = self.document.nameids[label] footnote = self.document.ids[id] ref['refid'] = id
def number_footnote_references(self, startnum): """Assign numbers to autonumbered footnote references.""" i = 0 for ref in self.document.autofootnote_refs: if ref.resolved or ref.hasattr('refid'): continue try: label = self.autofootnote_labels[i] except IndexError: msg = self.document.reporter.error( 'Too many autonumb...
doctype = '<!DOCTYPE html' \ ' PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' \ ' SYSTEM "http://www.w3.org/TR/xhtml1/DTD/' \ 'xhtml1-transitional.dtd">\n'
doctype = ('<!DOCTYPE html' ' PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' ' "http://www.w3.org/TR/xhtml1/DTD/' 'xhtml1-transitional.dtd">\n')
def translate(self): visitor = self.translator_class(self.document) self.document.walkabout(visitor) self.output = visitor.astext() self.head_prefix = visitor.head_prefix self.stylesheet = visitor.stylesheet self.head = visitor.head self.body_prefix = visitor.body_prefix self.body_pre_docinfo = visitor.body_pre_docinfo...
content_type = '<meta http-equiv="Content-Type" content="text/html; ' \ 'charset=%s" />\n' generator = '<meta name="generator" content="Docutils %s: ' \ 'http://docutils.sourceforge.net/" />\n'
content_type = ('<meta http-equiv="Content-Type" content="text/html; ' 'charset=%s" />\n') generator = ('<meta name="generator" content="Docutils %s: ' 'http://docutils.sourceforge.net/" />\n')
def translate(self): visitor = self.translator_class(self.document) self.document.walkabout(visitor) self.output = visitor.astext() self.head_prefix = visitor.head_prefix self.stylesheet = visitor.stylesheet self.head = visitor.head self.body_prefix = visitor.body_prefix self.body_pre_docinfo = visitor.body_pre_docinfo...
return self._dom_node(dom)
domroot = dom.Document() return self._dom_node(domroot)
def asdom(self, dom=xml.dom.minidom): """Return a DOM representation of this Node.""" return self._dom_node(dom)
def _dom_node(self, dom): return dom.Text(self.data) def _rooted_dom_node(self, domroot):
def _dom_node(self, domroot):
def _dom_node(self, dom): return dom.Text(self.data)
def _dom_node(self, dom): element = dom.Element(self.tagname) for attribute, value in self.attributes.items(): element.setAttribute(attribute, str(value)) for child in self.children: element.appendChild(child._dom_node(dom)) return element def _rooted_dom_node(self, domroot):
def _dom_node(self, domroot):
def _dom_node(self, dom): element = dom.Element(self.tagname) for attribute, value in self.attributes.items(): element.setAttribute(attribute, str(value)) for child in self.children: element.appendChild(child._dom_node(dom)) return element
element.appendChild(child._rooted_dom_node(domroot))
element.appendChild(child._dom_node(domroot))
def _rooted_dom_node(self, domroot): element = domroot.createElement(self.tagname) for attribute, value in self.attributes.items(): if type(value) is ListType: value = ' '.join(value) element.setAttribute(attribute, str(value)) for child in self.children: element.appendChild(child._rooted_dom_node(domroot)) return elem...
assert key.step is None, 'cannot handle slice with stride'
assert key.step in (None, 1), 'cannot handle slice with stride'
def __getitem__(self, key): if isinstance(key, UnicodeType) or isinstance(key, StringType): return self.attributes[key] elif isinstance(key, IntType): return self.children[key] elif isinstance(key, SliceType): assert key.step is None, 'cannot handle slice with stride' return self.children[key.start:key.stop] else: rais...
assert key.step is None, 'cannot handle slice with stride'
assert key.step in (None, 1), 'cannot handle slice with stride'
def __setitem__(self, key, item): if isinstance(key, UnicodeType) or isinstance(key, StringType): self.attributes[str(key)] = item elif isinstance(key, IntType): self.setup_child(item) self.children[key] = item elif isinstance(key, SliceType): assert key.step is None, 'cannot handle slice with stride' for node in item:...
assert key.step is None, 'cannot handle slice with stride'
assert key.step in (None, 1), 'cannot handle slice with stride'
def __delitem__(self, key): if isinstance(key, UnicodeType) or isinstance(key, StringType): del self.attributes[key] elif isinstance(key, IntType): del self.children[key] elif isinstance(key, SliceType): assert key.step is None, 'cannot handle slice with stride' del self.children[key.start:key.stop] else: raise TypeErr...
domroot.appendChild(self._rooted_dom_node(domroot))
domroot.appendChild(self._dom_node(domroot))
def asdom(self, dom=xml.dom.minidom): domroot = dom.Document() domroot.appendChild(self._rooted_dom_node(domroot)) return domroot
if self.insert_newline:
if self.insert_newline or self.literal_block:
def encode(self, text): """ Encode special characters in `text` & return. # $ % & ~ _ ^ \ { } Escaping with a backslash does not help with backslashes, ~ and ^.
else: text = text.replace("\n", "\\\\\n")
def encode(self, text): """ Encode special characters in `text` & return. # $ % & ~ _ ^ \ { } Escaping with a backslash does not help with backslashes, ~ and ^.
parts = ['..'] * (len(source_parts) - 1) + target_parts
parts = ['..'] * len(source_parts) + target_parts
def relative_path(source, target): """ Build and return a path to `target`, relative to `source`. If there is no common prefix, return the absolute path to `target`. """ source_parts = os.path.abspath(source or '').split(os.sep) target_parts = os.path.abspath(target).split(os.sep) # Check first 2 parts because '/dir'....
elif self.in_anydesc in ('cvardesc','excclassdesc',
elif self.in_anydesc in ('classdesc', 'cvardesc','excclassdesc',
def anydesc_title(self, title): """Returns the title for xxxdesc environments.""" if self.in_anydesc in ('ctypedesc','memberdesc','memberdescni',): # TODO [tag_or_type] {name} return '%s' % title elif self.in_anydesc in ('cvardesc','excclassdesc', 'funcdesc','funcdescni'): # "funcname(arguments)" to "{funcname}{argumen...
name = self.default_interpreted_role canonical = None try: canonical = self.language.roles[name] except AttributeError, error: msg_text.append('Problem retrieving role entry from language ' 'module %r: %s.' % (self.language, error)) except KeyError: msg_text.append('No role entry for "%s" in module "%s".' % (name, self...
canonical = self.default_interpreted_role
def get_role_function(self, role, lineno): messages = [] msg_text = [] if role: name = role.lower() else: name = self.default_interpreted_role canonical = None try: canonical = self.language.roles[name] except AttributeError, error: msg_text.append('Problem retrieving role entry from language ' 'module %r: %s.' % (self...
s = node.replace(u'\xa0', '& return s.replace(u'\u2020', '&
for i in node: if ord(i) > 127: node = node.replace(i, '& return node
def html_escape_unicode(node): # Find Python function that does this for me. string.encode('ascii', # 'xmlcharrefreplace') only 2.3 and above. s = node.replace(u'\xa0', '&#xa0;') return s.replace(u'\u2020', '&#x2020;')
self.num_includes = 0 self.max_includes = 20
self.included_documents = []
def __init__(self, request): self.request = request
if self.num_includes < self.max_includes: self.num_includes += 1 else: lines = [_("**Maximum number of allowable included documents exceeded**")] state_machine.insert_input(lines, 'MoinDirectives') return
def include(self, name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): # content contains the included file name _ = self.request.getText # Limit the number of documents that can be included if self.num_includes < self.max_includes: self.num_includes += 1 else: lines = [_("**M...
self.body.append(self.starttag({}, 'a', attr, ''))
self.body.append(self.starttag({}, 'a', '', attr))
def visit_system_message(self, node): if node['level'] < self.document.reporter['writer'].report_level: raise nodes.SkipNode self.body.append(self.starttag(node, 'div', CLASS='system-message')) self.body.append('<p class="system-message-title">') attr = {} a_end = '' backref_text = '' if node.hasattr('id'): attr['name'...
isinstance(node, nodes.raw))
isinstance(node, nodes.raw) or node.get('align', None) in ('left', 'center', 'right'))
def is_invisible(self, node): # Return true if node is invisible or moved away in the LaTeX # rendering. return (isinstance(node, nodes.Invisible) or isinstance(node, nodes.footnote) or isinstance(node, nodes.citation) or # We never know what's inside raw nodes, and often # they *are* invisible. So let's have the user...
default_priority = 890
default_priority = 880
def visit_system_message(self, node): if node['level'] < self.document.reporter.report_level: node.parent.remove(node)
os.path.walk(os.path.join(datadir, 'tests'), self.walker, None)
os.path.walk(join_path(datadir, 'tests'), self.walker, None)
def __init__(self): """Process all config files in functional/tests/.""" DocutilsTestSupport.CustomTestSuite.__init__(self) os.chdir(testroot) self.added = 0 os.path.walk(os.path.join(datadir, 'tests'), self.walker, None) assert self.added, 'No functional tests found.'
config_file_full_path = os.path.join(dirname, name)
config_file_full_path = join_path(dirname, name)
def walker(self, dummy, dirname, names): """ Process all config files among `names` in `dirname`.
execfile(os.path.join(datadir, 'tests', '_default.py'), params)
execfile(join_path(datadir, 'tests', '_default.py'), params)
def test(self): """Process self.configfile.""" os.chdir(testroot) # Keyword parameters for publish_file: params = {} # Initialize 'settings_overrides' for test settings scripts, # and disable configuration files: params['settings_overrides'] = {'_disable_config': 1} # Read the variables set in the default config file a...
os.path.join(datadir, 'input',
join_path(datadir, 'input',
def test(self): """Process self.configfile.""" os.chdir(testroot) # Keyword parameters for publish_file: params = {} # Initialize 'settings_overrides' for test settings scripts, # and disable configuration files: params['settings_overrides'] = {'_disable_config': 1} # Read the variables set in the default config file a...
os.path.join(datadir, 'output',
join_path(datadir, 'output',
def test(self): """Process self.configfile.""" os.chdir(testroot) # Keyword parameters for publish_file: params = {} # Initialize 'settings_overrides' for test settings scripts, # and disable configuration files: params['settings_overrides'] = {'_disable_config': 1} # Read the variables set in the default config file a...
expected_path = os.path.join(datadir, 'expected',
expected_path = join_path(datadir, 'expected',
def test(self): """Process self.configfile.""" os.chdir(testroot) # Keyword parameters for publish_file: params = {} # Initialize 'settings_overrides' for test settings scripts, # and disable configuration files: params['settings_overrides'] = {'_disable_config': 1} # Read the variables set in the default config file a...
if options.generator or options.datestamp or options.source_link:
if options.generator or options.datestamp or options.source_link \ or options.source_url:
def generate_footer(self): # @@@ Text is hard-coded for now. # Should be made dynamic (language-dependent). options = self.document.options if options.generator or options.datestamp or options.source_link: text = [] if options.source_link and options.source or options.source_uri: if options.source_uri: source = options...
if options.source_link and options.source or options.source_uri:
if options.source_link and options.source or options.source_url:
def generate_footer(self): # @@@ Text is hard-coded for now. # Should be made dynamic (language-dependent). options = self.document.options if options.generator or options.datestamp or options.source_link: text = [] if options.source_link and options.source or options.source_uri: if options.source_uri: source = options...
d_options = '10pt' d_paper = 'a4paper'
d_paper = 'a4paper'
def get_language(self): if self._ISO639_TO_BABEL.has_key(self.language): return self._ISO639_TO_BABEL[self.language] else: # support dialects. l = self.language.split("_")[0] if self._ISO639_TO_BABEL.has_key(l): return self._ISO639_TO_BABEL[l] return None
if self.use_latex_toc:
if 'contents' in node['classes'] and self.use_latex_toc:
def visit_topic(self, node): self.topic_classes = node['classes'] if self.use_latex_toc: self.body.append('\\tableofcontents\n\n\\bigskip\n') self.topic_classes = [] raise nodes.SkipNode
if node.has_key('align'): atts['align'] = self.attval(node['align']) atts['class'] = 'align-%s' % atts['align']
def visit_image(self, node): atts = {} atts['src'] = node['uri'] if node.has_key('width'): atts['width'] = node['width'] if node.has_key('height'): atts['height'] = node['height'] if node.has_key('scale'): if Image and not (node.has_key('width') and node.has_key('height')): try: im = Image.open(str(atts['src'])) except...
if options.source_uri: source = options.source_uri
if options.source_url: source = options.source_url
def generate_footer(self): # @@@ Text is hard-coded for now. # Should be made dynamic (language-dependent). options = self.document.options if options.generator or options.datestamp or options.source_link \ or options.source_url: text = [] if options.source_link and options.source or options.source_url: if options.sour...
prefix = self.startnode.details.get('prefix', None) if prefix is None: self.prefix = () else: self.prefix = (prefix,)
self.prefix = self.startnode.details.get('prefix', '') self.suffix = self.startnode.details.get('suffix', '')
def apply(self): self.maxdepth = self.startnode.details.get('depth', sys.maxint) self.startvalue = self.startnode.details.get('start', 1) prefix = self.startnode.details.get('prefix', None) if prefix is None: self.prefix = () else: self.prefix = (prefix,) self.startnode.parent.remove(self.startnode) if self.document.se...
def update_section_numbers(self, node, prefix=None, depth=0):
def update_section_numbers(self, node, prefix=(), depth=0):
def update_section_numbers(self, node, prefix=None, depth=0): depth += 1
if prefix is None: prefix = self.prefix
def update_section_numbers(self, node, prefix=None, depth=0): depth += 1
'', '.'.join(numbers) + u'\u00a0' * 3, CLASS='sectnum')
'', (self.prefix + '.'.join(numbers) + self.suffix + u'\u00a0' * 3), CLASS='sectnum')
def update_section_numbers(self, node, prefix=None, depth=0): depth += 1
self.doctree = doctree
self.document = doctree
def __init__(self, doctree): readers.Reader.__init__(self) self.doctree = doctree
self.body.append(self.starttag(node, 'pre', CLASS='address'))
def visit_address(self, node): self.visit_docinfo_item(node, 'address', meta=None) self.body.append(self.starttag(node, 'pre', CLASS='address'))
self.body.append('\n</pre>\n')
def depart_address(self, node): self.body.append('\n</pre>\n') self.depart_docinfo_item()