rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return 'image:: %s\n :align: middle\n' % (self.process(text),) | src = self.process(text) return '''\ image:: %(src)s :align: middle :class: texmath :alt: %(text)s ''' % locals() | def texmath(self, text): return 'image:: %s\n :align: middle\n' % (self.process(text),) |
return 'image:: %s\n :align: center\n' % (self.process(text),) | src = self.process(text) return '''\ image:: %(src)s :align: center :class: texdisplay :alt: %(text)s ''' % locals() | def texdisplay(self, text): return 'image:: %s\n :align: center\n' % (self.process(text),) |
htmlfile) | 'file://%s' % quote(htmlfile)) | def publishFileAsHTML(self, file): if os.path.exists(file): go_ahead = 1 if self.project != None: dir = self.project.directory else: dir = os.path.dirname(file) dlg = wxDirDialog(self, 'Outputdirectory?', dir) if dlg.ShowModal() == wxID_OK: dir = dlg.GetPath() else: go_ahead = 0 dlg.Destroy() if go_ahead: wxBeginBusyCu... |
if not self.literal_block: | if self.literal_block or self.literal: pass else: | def encode(self, text): """ Encode special characters in `text` & return. # $ % & ~ _ ^ \ { } Escaping with a backslash does not help with backslashes, ~ and ^. |
key = max(self.tools.keys())+1 self.tools[key] = [0, name, command, init_dir] | if self.tools == {}: key = 1 else: key = max(self.tools.keys())+1 self.tools[key] = [0, name, command, init_dir] | def add_tool(self, name, command, init_dir): key = max(self.tools.keys())+1 self.tools[key] = [0, name, command, init_dir] i = 1 for tool in self.tools.values(): tool[0] = i i = i+1 self.update_list() |
i = 0 for tool in cfg.options('tools'): i = i+1 self.tools[i]=[i]+cfg.get('tools', tool).split(';') | for i in range(len(cfg.options('tools'))): self.tools[i+1] = [i+1] \ + cfg.get('tools', str(i+1)).split(';') | def init_tools(self): self.tools = {} if os.path.exists(DATA): try: cfg = ConfigParser.ConfigParser() cfg.read(DATA) if cfg.has_section('tools'): i = 0 for tool in cfg.options('tools'): i = i+1 self.tools[i]=[i]+cfg.get('tools', tool).split(';') except: customMsgBox(self, '%s:\n%s\n%s' % sys.exc_info(), 'error') |
if not self.use_latex_toc and self.topic_class == 'contents': self.body.append( '\\begin{list}{}{}\n' ) | if self.topic_class == 'contents': if not self.use_latex_toc: self.body.append( '\\begin{list}{}{}\n' ) | def visit_bullet_list(self, node): if not self.use_latex_toc and self.topic_class == 'contents': self.body.append( '\\begin{list}{}{}\n' ) else: self.body.append( '\\begin{itemize}\n' ) |
if not self.use_latex_toc and self.topic_class == 'contents': self.body.append( '\\end{list}\n' ) | if self.topic_class == 'contents': if not self.use_latex_toc: self.body.append( '\\end{list}\n' ) | def depart_bullet_list(self, node): if not self.use_latex_toc and self.topic_class == 'contents': self.body.append( '\\end{list}\n' ) else: self.body.append( '\\end{itemize}\n' ) |
if self.use_latex_toc: self.body.append('\\tableofcontents\n\n\\bigskip\n') | def depart_docinfo(self, node): self.docinfo.append('\\end{tabularx}\n') self.docinfo.append('\\end{center}\n') self.body = self.docinfo + self.body # clear docinfo, so field names are no longer appended. self.docinfo = None if self.use_latex_toc: self.body.append('\\tableofcontents\n\n\\bigskip\n') | |
if self.topic_class == 'contents': self.body.append('\n') else: self.body.append('\n') | self.body.append('\n') | def depart_paragraph(self, node): if self.topic_class == 'contents': self.body.append('\n') else: self.body.append('\n') |
self.stylesheet = [self.stylesheet_link % stylesheet] | self.stylesheet = [self.stylesheet_link % self.encode(stylesheet)] | 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... |
os.environ = dict(os.environ) | os.environ = os.environ.copy() | def setUp(self): ConfigFileTests.setUp(self) self.orig_environ = os.environ os.environ = dict(os.environ) |
if not self.use_latex_docinfo: self.head.extend( [ '\\author{}\n', '\\date{}\n' ] ) | self.title = '' self.author_stack = [] self.date = '' | def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.settings = settings = document.settings self.latex_encoding = self.to_latex_encoding(settings.output_encoding) self.use_latex_toc = settings.use_latex_toc self.use_latex_docinfo = settings.use_latex_docinfo self.use_latex_footnotes = settings... |
self.title = "" | def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.settings = settings = document.settings self.latex_encoding = self.to_latex_encoding(settings.output_encoding) self.use_latex_toc = settings.use_latex_toc self.use_latex_docinfo = settings.use_latex_docinfo self.use_latex_footnotes = settings... | |
self.author_stack = [] | def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.settings = settings = document.settings self.latex_encoding = self.to_latex_encoding(settings.output_encoding) self.use_latex_toc = settings.use_latex_toc self.use_latex_docinfo = settings.use_latex_docinfo self.use_latex_footnotes = settings... | |
if self.pdfinfo: | if self.pdfinfo is not None: | def astext(self): if self.pdfinfo: if self.pdfauthor: self.pdfinfo.append('pdfauthor={%s}' % self.pdfauthor) pdfinfo = '\\hypersetup{\n' + ',\n'.join(self.pdfinfo) + '\n}\n' else: pdfinfo = '' title = '\\title{%s}\n' % self.title return ''.join(self.head_prefix + [title] + self.head + [pdfinfo] + self.body_prefix + se... |
title = '\\title{%s}\n' % self.title return ''.join(self.head_prefix + [title] + self.head + [pdfinfo] | head = '\\title{%s}\n\\author{%s}\n\\date{%s}\n' % \ (self.title, ' \\and\n'.join(['~\\\\\n'.join(author_lines) for author_lines in self.author_stack]), self.date) return ''.join(self.head_prefix + [head] + self.head + [pdfinfo] | def astext(self): if self.pdfinfo: if self.pdfauthor: self.pdfinfo.append('pdfauthor={%s}' % self.pdfauthor) pdfinfo = '\\hypersetup{\n' + ',\n'.join(self.pdfinfo) + '\n}\n' else: pdfinfo = '' title = '\\title{%s}\n' % self.title return ''.join(self.head_prefix + [title] + self.head + [pdfinfo] + self.body_prefix + se... |
if self.use_latex_docinfo and self.author_stack: self.head.append('\\author{%s}\n' % \ ' \\and\n'.join(['~\\\\\n'.join(author_lines) for author_lines in self.author_stack]) ) | def depart_docinfo(self, node): if self.use_latex_docinfo and self.author_stack: self.head.append('\\author{%s}\n' % \ ' \\and\n'.join(['~\\\\\n'.join(author_lines) for author_lines in self.author_stack]) ) self.docinfo.append('\\end{tabularx}\n') self.docinfo.append('\\end{center}\n') self.body = self.docinfo + self.b... | |
self.head.append('\\date{%s}\n' % self.attval(node.astext())) | self.date = self.attval(node.astext()) | def visit_docinfo_item(self, node, name): if name == 'author': if not self.pdfinfo == None: if not self.pdfauthor: self.pdfauthor = self.attval(node.astext()) else: self.pdfauthor += self.author_separator + self.attval(node.astext()) if self.use_latex_docinfo: if name in ('author', 'organization', 'contact', 'address')... |
if len(node) and isinstance(node[0], nodes.title): | if self.use_latex_docinfo or len(node) and isinstance(node[0], nodes.title): | def visit_document(self, node): self.body_prefix.append('\\begin{document}\n') # titled document? if len(node) and 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') |
raise nodes.SkipNode | def visit_title(self, node): #self.pdebug('%% [(visit_title) section_level: %d node: "%s"]\n' % \ # (self.section_level, node.astext().lower())) if self.section_level == 0: self.title_before_section = 1 if self.seealso: self.body.append('\\end{seealso}\n') self.seealso = 0 if node.astext().lower() == 'see also': se... | |
s1 = self.encode(node.astext()) s2 = self.string_to_label(node.astext()) | def visit_title(self, node): #self.pdebug('%% [(visit_title) section_level: %d node: "%s"]\n' % \ # (self.section_level, node.astext().lower())) if self.section_level == 0: self.title_before_section = 1 if self.seealso: self.body.append('\\end{seealso}\n') self.seealso = 0 if node.astext().lower() == 'see also': se... | |
self.body.append('\\section{') | self.body.append('\\section{%s\label{%s}}\n' % (s1, s2)) | def visit_title(self, node): #self.pdebug('%% [(visit_title) section_level: %d node: "%s"]\n' % \ # (self.section_level, node.astext().lower())) if self.section_level == 0: self.title_before_section = 1 if self.seealso: self.body.append('\\end{seealso}\n') self.seealso = 0 if node.astext().lower() == 'see also': se... |
self.body.append('\\subsection{') | self.body.append('\\subsection{%s\label{%s}}\n' % (s1, s2)) | def visit_title(self, node): #self.pdebug('%% [(visit_title) section_level: %d node: "%s"]\n' % \ # (self.section_level, node.astext().lower())) if self.section_level == 0: self.title_before_section = 1 if self.seealso: self.body.append('\\end{seealso}\n') self.seealso = 0 if node.astext().lower() == 'see also': se... |
self.body.append('\\subsubsection{') | self.body.append('\\subsubsection{%s\label{%s}}\n' % (s1, s2)) | def visit_title(self, node): #self.pdebug('%% [(visit_title) section_level: %d node: "%s"]\n' % \ # (self.section_level, node.astext().lower())) if self.section_level == 0: self.title_before_section = 1 if self.seealso: self.body.append('\\end{seealso}\n') self.seealso = 0 if node.astext().lower() == 'see also': se... |
self.body.append('\\paragraph{') | self.body.append('\\paragraph{%s\label{%s}}\n' % (s1, s2)) | def visit_title(self, node): #self.pdebug('%% [(visit_title) section_level: %d node: "%s"]\n' % \ # (self.section_level, node.astext().lower())) if self.section_level == 0: self.title_before_section = 1 if self.seealso: self.body.append('\\end{seealso}\n') self.seealso = 0 if node.astext().lower() == 'see also': se... |
self.body.append('\\subparagraph{') | self.body.append('\\subparagraph{%s\label{%s}}\n' % (s1, s2)) raise nodes.SkipNode | def visit_title(self, node): #self.pdebug('%% [(visit_title) section_level: %d node: "%s"]\n' % \ # (self.section_level, node.astext().lower())) if self.section_level == 0: self.title_before_section = 1 if self.seealso: self.body.append('\\end{seealso}\n') self.seealso = 0 if node.astext().lower() == 'see also': se... |
if self.section_level > 0: self.body.append('}\n') | pass | def depart_title(self, node): if self.section_level > 0: self.body.append('}\n') |
atts['width'] = int(im.size[0] * (float(atts['scale']) / 100)) | atts['width'] = im.size[0] | def visit_image(self, node): atts = node.attributes.copy() if atts.has_key('class'): del atts['class'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if Image and not (atts.has_key('width') and atts.has_key('height')): try: im = Image.open(str(atts['s... |
atts['height'] = int(im.size[1] * (float(atts['scale']) / 100)) | atts['height'] = im.size[1] | def visit_image(self, node): atts = node.attributes.copy() if atts.has_key('class'): del atts['class'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if Image and not (atts.has_key('width') and atts.has_key('height')): try: im = Image.open(str(atts['s... |
Subtitle | Section ------- | def suite(): s = DocutilsTestSupport.HtmlPublishPartsTestSuite() s.generateTests(totest) return s |
<div class="section" id="subtitle"> <h1><a name="subtitle">Subtitle</a></h1> | <div class="section" id="section"> <h1><a name="section">Section</a></h1> | def suite(): s = DocutilsTestSupport.HtmlPublishPartsTestSuite() s.generateTests(totest) return s |
<div class="section" id="subtitle"> <h2><a name="subtitle">Subtitle</a></h2> | <div class="section" id="section"> <h3><a name="section">Section</a></h3> | def suite(): s = DocutilsTestSupport.HtmlPublishPartsTestSuite() s.generateTests(totest) return s |
<h3><a name="another-section">Another Section</a></h3> | <h4><a name="another-section">Another Section</a></h4> | def suite(): s = DocutilsTestSupport.HtmlPublishPartsTestSuite() s.generateTests(totest) return s |
self.document.note_internal_target(next_node) | if isinstance(next_node, nodes.target): self.document.note_internal_target(next_node) | def apply(self): for target in self.document.internal_targets: if not (len(target) == 0 and not (target.attributes.has_key('refid') or target.attributes.has_key('refuri') or target.attributes.has_key('refname'))): continue next_node = target.next_node(ascend=1) # Do not move names and ids into Invisibles (we'd lose the... |
config_files = os.environ['DOCUTILSCONFIG'] | config_files = os.environ['DOCUTILSCONFIG'].split(os.pathsep) | def get_standard_config_files(self): """Return list of config files, from environment or standard.""" try: config_files = os.environ['DOCUTILSCONFIG'] except KeyError: config_files = self.standard_config_files return [os.path.expanduser(f) for f in config_files.split(os.pathsep) if f.strip()] |
return [os.path.expanduser(f) for f in config_files.split(os.pathsep) if f.strip()] | return [os.path.expanduser(f) for f in config_files if f.strip()] | def get_standard_config_files(self): """Return list of config files, from environment or standard.""" try: config_files = os.environ['DOCUTILSCONFIG'] except KeyError: config_files = self.standard_config_files return [os.path.expanduser(f) for f in config_files.split(os.pathsep) if f.strip()] |
s.addTestCase( SpecialIncludeTestCase, 'test_parser', SpecialIncludeTestCase.input, SpecialIncludeTestCase.expected_regex) | def suite(): s = DocutilsTestSupport.ParserTestSuite() s.generateTests(totest) s.addTestCase( SpecialIncludeTestCase, 'test_parser', SpecialIncludeTestCase.input, SpecialIncludeTestCase.expected_regex) return s | |
None, '../docutils/parsers/rst/include/nonexistent') | os.path.join(DocutilsTestSupport.testroot, 'dummy'), nonexistent) | def suite(): s = DocutilsTestSupport.ParserTestSuite() s.generateTests(totest) s.addTestCase( SpecialIncludeTestCase, 'test_parser', SpecialIncludeTestCase.input, SpecialIncludeTestCase.expected_regex) return s |
] class SpecialIncludeTestCase(DocutilsTestSupport.ParserTestCase): def test_parser(self): if self.run_in_debugger: pdb.set_trace() document = DocutilsTestSupport.utils.new_document( 'test data', self.settings) DocutilsTestSupport.roles._roles = {} self.parser.parse(self.input, document) output = document.pformat()... | ["""\ | def suite(): s = DocutilsTestSupport.ParserTestSuite() s.generateTests(totest) s.addTestCase( SpecialIncludeTestCase, 'test_parser', SpecialIncludeTestCase.input, SpecialIncludeTestCase.expected_regex) return s |
^<document source="test data"> | \ <document source="test data"> | def test_parser(self): if self.run_in_debugger: pdb.set_trace() document = DocutilsTestSupport.utils.new_document( 'test data', self.settings) # Remove any additions made by "role" directives: DocutilsTestSupport.roles._roles = {} self.parser.parse(self.input, document) output = document.pformat() self.assert_(re.match... |
IOError: \[Errno 2\] No such file or directory: .*\. | IOError: [Errno 2] No such file or directory: '%s'. | def test_parser(self): if self.run_in_debugger: pdb.set_trace() document = DocutilsTestSupport.utils.new_document( 'test data', self.settings) # Remove any additions made by "role" directives: DocutilsTestSupport.roles._roles = {} self.parser.parse(self.input, document) output = document.pformat() self.assert_(re.match... |
\.\. include:: <nonexistent> $""" | .. include:: <nonexistent> """ % nonexistent_rel], ] | def test_parser(self): if self.run_in_debugger: pdb.set_trace() document = DocutilsTestSupport.utils.new_document( 'test data', self.settings) # Remove any additions made by "role" directives: DocutilsTestSupport.roles._roles = {} self.parser.parse(self.input, document) output = document.pformat() self.assert_(re.match... |
visitor.document.reporter.debug(self.__class__.__name__, | visitor.document.reporter.debug('visit_' + self.__class__.__name__, | def walk(self, visitor): """ Traverse a tree of `Node` objects, calling ``visit_...`` methods of `visitor` when entering each node. If there is no ``visit_particular_node`` method for a node of type ``particular_node``, the ``unknown_visit`` method is called. (The `walkabout()` method is similar, except it also calls ... |
visitor.document.reporter.debug(self.__class__.__name__, | visitor.document.reporter.debug('visit_' + self.__class__.__name__, | def walkabout(self, visitor): """ Perform a tree traversal similarly to `Node.walk()` (which see), except also call ``depart_...`` methods before exiting each node. If there is no ``depart_particular_node`` method for a node of type ``particular_node``, the ``unknown_departure`` method is called. |
visitor.document.reporter.debug(self.__class__.__name__, category='nodes.Node.walkabout') visitor.dispatch_depart(self, self.__class__.__name__) | visitor.document.reporter.debug( 'depart_' + self.__class__.__name__, category='nodes.Node.walkabout') visitor.dispatch_departure(self, self.__class__.__name__) | def walkabout(self, visitor): """ Perform a tree traversal similarly to `Node.walk()` (which see), except also call ``depart_...`` methods before exiting each node. If there is no ``depart_particular_node`` method for a node of type ``particular_node``, the ``unknown_departure`` method is called. |
def dispatch_depart(self, node, method_name): | def dispatch_departure(self, node, method_name): | def dispatch_depart(self, node, method_name): method = getattr(self, 'depart_' + method_name, self.unknown_departure) return method(node) |
text = text.replace("[", '{}[') text = text.replace("]", '{}]') | def encode(self, text): """ Encode special characters in `text` & return. # $ % & ~ _ ^ \ { } Escaping with a backslash does not help with backslashes, ~ and ^. | |
if not self.__dict__.has_key('encode_re_bracketts'): self.encode_re_bracketts = re.compile(r'([\[\]])') if self.literal_block and not self.mbox_newline: text = self.encode_re_bracketts.sub(r'{\1}',text) | self.encode_re_bracketts = re.compile(r'([\[\]])') text = self.encode_re_bracketts.sub(r'{\1}',text) | def encode(self, text): """ Encode special characters in `text` & return. # $ % & ~ _ ^ \ { } Escaping with a backslash does not help with backslashes, ~ and ^. |
title = self.document[1][1].astext() | title = header[1][1].astext() | def translate(self): html4css1.Writer.translate(self) options = self.document.options template = open(options.template).read() stylesheet = options.stylesheet pyhome = options.python_home pephome = options.pep_home index = self.document.first_child_matching_class(nodes.field_list) header = self.document[index] pep = he... |
self.encode_re_bracketts = re.compile(r'([\[\]])') text = self.encode_re_bracketts.sub(r'{\1}',text) | text = text.replace('[', '{[}') | def encode(self, text): """ Encode special characters in `text` & return. # $ % & ~ _ ^ \ { } Escaping with a backslash does not help with backslashes, ~ and ^. |
self.body.append(' & ') | count = 0 while self.active_table.get_rowspan(count): count += 1 self.body.append(' & ') | def visit_entry(self, node): self.active_table.visit_entry() # cell separation if self.active_table.get_entry_number() == 1: # if the firstrow is a multirow, this actually is the second row. # this gets hairy if rowspans follow each other. if self.active_table.get_rowspan(0): self.body.append(' & ') self.active_table.v... |
def section(self, title, source, style, lineno): | def section(self, title, source, style, lineno, messages): | def section(self, title, source, style, lineno): """Check for a valid subsection and create one if it checks out.""" if self.check_subsection(source, style, lineno): self.new_subsection(title, lineno) |
self.new_subsection(title, lineno) | self.new_subsection(title, lineno, messages) | def section(self, title, source, style, lineno): """Check for a valid subsection and create one if it checks out.""" if self.check_subsection(source, style, lineno): self.new_subsection(title, lineno) |
def new_subsection(self, title, lineno): | def new_subsection(self, title, lineno, messages): | def new_subsection(self, title, lineno): """Append new subsection to document tree. On return, check level.""" memo = self.memo mylevel = memo.section_level memo.section_level += 1 sectionnode = nodes.section() self.parent += sectionnode textnodes, messages = self.inline_text(title, lineno) titlenode = nodes.title(titl... |
textnodes, messages = self.inline_text(title, lineno) | textnodes, title_messages = self.inline_text(title, lineno) | def new_subsection(self, title, lineno): """Append new subsection to document tree. On return, check level.""" memo = self.memo mylevel = memo.section_level memo.section_level += 1 sectionnode = nodes.section() self.parent += sectionnode textnodes, messages = self.inline_text(title, lineno) titlenode = nodes.title(titl... |
msg = self.reporter.info( | msg = self.reporter.warning( | def underline(self, match, context, next_state): """Section title.""" lineno = self.state_machine.abs_line_number() if not self.state_machine.match_titles: blocktext = context[0] + '\n' + self.state_machine.line msg = self.reporter.severe( 'Unexpected section title at line %s.' % lineno, '', nodes.literal_block(blockte... |
self.parent += msg | messages.append(msg) | def underline(self, match, context, next_state): """Section title.""" lineno = self.state_machine.abs_line_number() if not self.state_machine.match_titles: blocktext = context[0] + '\n' + self.state_machine.line msg = self.reporter.severe( 'Unexpected section title at line %s.' % lineno, '', nodes.literal_block(blockte... |
self.section(title, source, style, lineno - 1) | self.section(title, source, style, lineno - 1, messages) | def underline(self, match, context, next_state): """Section title.""" lineno = self.state_machine.abs_line_number() if not self.state_machine.match_titles: blocktext = context[0] + '\n' + self.state_machine.line msg = self.reporter.severe( 'Unexpected section title at line %s.' % lineno, '', nodes.literal_block(blockte... |
msg = self.reporter.info( | msg = self.reporter.warning( | def text(self, match, context, next_state): """Potential over- & underlined title.""" lineno = self.state_machine.abs_line_number() - 1 overline = context[0] title = match.string underline = '' try: underline = self.state_machine.next_line() except IndexError: blocktext = overline + '\n' + title msg = self.reporter.sev... |
self.parent += msg | messages.append(msg) | def text(self, match, context, next_state): """Potential over- & underlined title.""" lineno = self.state_machine.abs_line_number() - 1 overline = context[0] title = match.string underline = '' try: underline = self.state_machine.next_line() except IndexError: blocktext = overline + '\n' + title msg = self.reporter.sev... |
self.section(title.lstrip(), source, style, lineno + 1) | self.section(title.lstrip(), source, style, lineno + 1, messages) | def text(self, match, context, next_state): """Potential over- & underlined title.""" lineno = self.state_machine.abs_line_number() - 1 overline = context[0] title = match.string underline = '' try: underline = self.state_machine.next_line() except IndexError: blocktext = overline + '\n' + title msg = self.reporter.sev... |
atts['width'] = im.size[0] | atts['width'] = str(im.size[0]) | 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... |
atts['height'] = im.size[1] | atts['height'] = str(im.size[1]) | 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 atts.has_key('width'): atts['width'] = int(round(node['width'] * (float(node['scale']) / 100))) if atts.has_key('height'): atts['height'] = int(round(node['height'] * (float(node['scale']) / 100))) | for att_name in 'width', 'height': if atts.has_key(att_name): match = re.match(r'([0-9.]+)(.*)', atts[att_name]) assert match atts[att_name] = '%s%s' % ( float(match.group(1)) * (float(node['scale']) / 100), match.group(2)) | 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... |
domroot.appendChild(Element._rooted_dom_node(self, domroot)) | domroot.appendChild(self._rooted_dom_node(domroot)) | def asdom(self, dom=xml.dom.minidom): domroot = dom.Document() domroot.appendChild(Element._rooted_dom_node(self, domroot)) return domroot |
class footnote(General, Element, BackLinkable): pass class citation(General, Element, BackLinkable): pass | class footnote(General, Element, Labeled, BackLinkable): pass class citation(General, Element, Labeled, BackLinkable): pass | def astext(self): return self.get('delimiter', ' ') + TextElement.astext(self) |
return 0, ('unknown option: "%s"' % detail) | return 0, ('unknown option: "%s"' % detail.args[0]) | def parse_extension_options(self, option_spec, datalines): """ Parse `datalines` for a field list containing extension options matching `option_spec`. |
<reference ids="internal" name="external_" names="internal" refuri="http://uri"> | <reference ids="internal" name="external" names="internal" refuri="http://uri"> | def suite(): parser = Parser() s = DocutilsTestSupport.TransformTestSuite(parser) s.generateTests(totest) return s |
<reference name="indirect_" refuri="http://uri"> | <reference name="indirect" refuri="http://uri"> | def suite(): parser = Parser() s = DocutilsTestSupport.TransformTestSuite(parser) s.generateTests(totest) return s |
<reference name="internal_" refid="internal"> | <reference name="internal" refid="internal"> | def suite(): parser = Parser() s = DocutilsTestSupport.TransformTestSuite(parser) s.generateTests(totest) return s |
'charset=UTF-8">\n', | 'charset=UTF-8">\n' | def record(self): self.recordfile(self.output, self.destination) |
' type="text/css" />\n'] | ' type="text/css" />\n' | def record(self): self.recordfile(self.output, self.destination) |
default_section = 'options' for section_name in config_parser.sections: if section_name == default_section: prefix = '' else: prefix = section_name + '_' settings = config_parser.get_section(section_name) make_paths_absolute(settings, parser.relative_path_settings, | settings = config_parser.get_section('options') make_paths_absolute(settings, parser.relative_path_settings, | def read_config_file(option, opt, value, parser): """ Read a configuration file during option processing. (Option callback.) """ config_parser = ConfigParser() config_parser.read(value) default_section = 'options' for section_name in config_parser.sections: if section_name == default_section: prefix = '' else: prefix... |
components=publisher.components, | components=publisher.components, read_config_files=1, | def setup_publishers(self): """ Manage configurations for individual publishers. |
self.config_settings = option_parser.get_standard_config_settings() | publisher.config_settings = ( option_parser.get_standard_config_settings()) | def setup_publishers(self): """ Manage configurations for individual publishers. |
settings.update(self.config_settings, publisher.option_parser) | settings.update(publisher.config_settings, publisher.option_parser) | def get_settings(self, publisher_name, directory=None): """ Return a settings object, from multiple sources. |
self.body.append('<p class="admonition-title first">' + self.language.labels[name] + '</p>\n') node[-1].set_class('last') else: self.set_first_last(node) | node.insert(0, nodes.title(name, self.language.labels[name])) self.set_first_last(node) | def visit_admonition(self, node, name=''): self.body.append(self.starttag(node, 'div', CLASS=(name or 'admonition'))) if name: self.body.append('<p class="admonition-title first">' + self.language.labels[name] + '</p>\n') node[-1].set_class('last') else: self.set_first_last(node) |
elif isinstance(node.parent, nodes.admonition): | elif isinstance(node.parent, nodes.Admonition): | 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(... |
self.starttag(node, 'p', '', CLASS='admonition-title first')) | self.starttag(node, 'p', '', CLASS='admonition-title')) | 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 node.attributes.has_key('dupname'): name = node.attributes['dupname'] | if node['names']: name = node.attributes['names'][0] | def visit_section(self, node): if node.attributes.has_key('dupname'): name = node.attributes['dupname'] else: name = node.attributes['name'] self.slidenum += 1 self.w('<slide id="Slide%03d" title="%s">\n' '<frame x="90" y="72" width="600" height="432" leftmargin="12"' 'rightmargin="0">\n'%(self.slidenum, name)) |
name = node.attributes['name'] | name = node.attributes['dupnames'][0] | def visit_section(self, node): if node.attributes.has_key('dupname'): name = node.attributes['dupname'] else: name = node.attributes['name'] self.slidenum += 1 self.w('<slide id="Slide%03d" title="%s">\n' '<frame x="90" y="72" width="600" height="432" leftmargin="12"' 'rightmargin="0">\n'%(self.slidenum, name)) |
atts = node.non_default_attributes() if atts.has_key('classes'): del atts['classes'] atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if Image and not (atts.has_key('width') and atts.has_key('height')): | 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')): | def visit_image(self, node): atts = node.non_default_attributes() if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if Image and not (atts.has_key('width') and atts.has_key('height')): try: im = Image.open(st... |
atts['width'] = int(round(atts['width'] * (float(atts['scale']) / 100))) | atts['width'] = int(round(node['width'] * (float(node['scale']) / 100))) | def visit_image(self, node): atts = node.non_default_attributes() if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if Image and not (atts.has_key('width') and atts.has_key('height')): try: im = Image.open(st... |
atts['height'] = int(round(atts['height'] * (float(atts['scale']) / 100))) del atts['scale'] if not atts.has_key('alt'): atts['alt'] = atts['src'] if atts.has_key('align'): atts['align'] = self.attval(atts['align']) | atts['height'] = int(round(node['height'] * (float(node['scale']) / 100))) atts['alt'] = node.get('alt', atts['src']) if node.has_key('align'): atts['align'] = self.attval(node['align']) | def visit_image(self, node): atts = node.non_default_attributes() if atts.has_key('classes'): del atts['classes'] # prevent duplication with node attrs atts['src'] = atts['uri'] del atts['uri'] if atts.has_key('scale'): if Image and not (atts.has_key('width') and atts.has_key('height')): try: im = Image.open(st... |
_inlineRE = re.compile(r'( *).. +inline: *(.*)') _inlineAllRE = re.compile(r'( *).. +inline-all: *') _ignoreRE = re.compile(r'( *).. ignore: *(.*)\n?') | _inlineRE = re.compile(r'( *).. +inline:: *(.*)') _inlineAllRE = re.compile(r'( *).. +inline-all:: *') _ignoreRE = re.compile(r'( *).. ignore:: *(.*)\n?') | def __init__(self, rootNode): self.rootNode = rootNode |
return d + indent(doc) | return d + indent(doc) + "\n" | def documentation(self, context): d = "`%s(%s)`:\n" % (self.name, ', '.join([self.parameterText(p) for p in self.parameters])) doc = Document.documentation(self, context) if not doc: doc = "Not documented." return d + indent(doc) |
document['source'] = self.source | if self.source.source_path: document['source'] = self.source.source_path | def new_document(self): """Create and return a new empty document tree (root node).""" document = utils.new_document(self.options) document['source'] = self.source return document |
latex_toc = 0 | latex_toc = 1 | def translate(self): visitor = LaTeXTranslator(self.document) self.document.walkabout(visitor) self.output = visitor.astext() self.head_prefix = visitor.head_prefix self.head = visitor.head self.body_prefix = visitor.body_prefix self.body = visitor.body self.body_suffix = visitor.body_suffix |
'\\usepackage{babel}\n', | '\\usepackage{babel}\n', '\\usepackage{shortvrb}\n', | def __init__(self, document): nodes.NodeVisitor.__init__(self, document) self.options = options = document.options # language: labels, bibliographic_fields, and author_separators. # to allow writing labes for specific languages. self.language = languages.get_language(document.options.language_code) if _ISO639_TO_BABEL.... |
text = text.replace("\\", '{\\\\}') | text = text.replace("\\", '{$\\backslash$}') | def encode(self, text): """Encode special characters in `text` & return.""" text = text.replace("\\", '{\\\\}') text = text.replace("&", '{\\&}') text = text.replace("_", '{\\_}') text = text.replace("^", '{\\^}') text = text.replace("%", '{\\%}') text = text.replace("#", '{\\#}') text = text.replace(u'\u2020', '{$\\da... |
text = text.replace("^", '{\\^}') | text = text.replace("^", '{\verb|^|}') | def encode(self, text): """Encode special characters in `text` & return.""" text = text.replace("\\", '{\\\\}') text = text.replace("&", '{\\&}') text = text.replace("_", '{\\_}') text = text.replace("^", '{\\^}') text = text.replace("%", '{\\%}') text = text.replace("#", '{\\#}') text = text.replace(u'\u2020', '{$\\da... |
self.body.append('% [visit_topic]\n') | def visit_topic(self, node): self.body.append('% [visit_topic]\n') self.topic_class = node.get('class') if self.latex_toc: self.body.append('\\tableofcontents\n\n\\bigskip\n') self.body.append('% [depart_topic]\n') self.topic_class = '' raise nodes.SkipNode | |
self.body.append('\\tableofcontents\n\n\\bigskip\n') self.body.append('% [depart_topic]\n') | def visit_topic(self, node): self.body.append('% [visit_topic]\n') self.topic_class = node.get('class') if self.latex_toc: self.body.append('\\tableofcontents\n\n\\bigskip\n') self.body.append('% [depart_topic]\n') self.topic_class = '' raise nodes.SkipNode | |
from MoinMoin.parser.wiki import Parser self.wikiparser = Parser('', self.request) | self.wikiparser = MoinMoin.parser.wiki.Parser('', self.request) | def __init__(self, formatter, request): html4css1.Writer.__init__(self) self.formatter = formatter self.request = request # Add our wiki unknown_reference_resolver to our list of functions to # run when a target isn't found self.unknown_reference_resolvers = [self.wiki_resolver] # We create a new parser to process Moin... |
parser = MoinDirectives() | parser = MoinDirectives(self.request) | def format(self, formatter): # Create our simple parser parser = MoinDirectives() parts = publish_parts(source = self.raw, writer = MoinWriter(formatter, self.request)) text = '' if parts['title']: text += '<h2>' + parts['title'] + '</h2>' # If there is only one subtitle then it is held in parts['subtitle']. # Howev... |
def __init__(self): | def __init__(self, request): self.request = request | def __init__(self): directives.register_directive('include', self.include) directives.register_directive('macro', self.macro) |
for directive in ('meta', 'raw'): directives.register_directive(directive, None) roles._roles['raw'] = None self.num_includes = 0 self.max_includes = 20 | def __init__(self): directives.register_directive('include', self.include) directives.register_directive('macro', self.macro) | |
page = Page(content[0]) text = page.get_raw_body() lines = text.split('\n') lines = lines[1:] | page = Page(page_name = content[0], request = self.request) if page.exists(): text = page.get_raw_body() lines = text.split('\n') if lines[0].startswith(" del lines[0] else: lines = [_("**Could not find the referenced page: %s**") % (content[0],)] | def include(self, name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): # content contains the included file name if len(content): page = Page(content[0]) text = page.get_raw_body() lines = text.split('\n') # Remove the "#format rst" line lines = lines[1:] # Insert the text from ... |
from docutils.nodes import reference | def macro(self, name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): # content contains macro to be called if len(content): from docutils.nodes import reference # Allow either with or without brackets if content[0].startswith('[['): macro = content[0] else: macro = '[[%s]]' % co... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.