Python docutils.writers.Writer() Examples

The following are 30 code examples of docutils.writers.Writer(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module docutils.writers , or try the search function .
Example #1
Source File: __init__.py    From faces with GNU General Public License v2.0 6 votes vote down vote up
def assemble_my_parts(self):
        """Assemble the `self.parts` dictionary.  Extend in subclasses.
        """
        writers.Writer.assemble_parts(self)
        f = tempfile.NamedTemporaryFile()
        zfile = zipfile.ZipFile(f, 'w', zipfile.ZIP_DEFLATED)
        self.write_zip_str(zfile, 'mimetype', self.MIME_TYPE,
            compress_type=zipfile.ZIP_STORED)
        content = self.visitor.content_astext()
        self.write_zip_str(zfile, 'content.xml', content)
        s1 = self.create_manifest()
        self.write_zip_str(zfile, 'META-INF/manifest.xml', s1)
        s1 = self.create_meta()
        self.write_zip_str(zfile, 'meta.xml', s1)
        s1 = self.get_stylesheet()
        self.write_zip_str(zfile, 'styles.xml', s1)
        self.store_embedded_files(zfile)
        self.copy_from_stylesheet(zfile)
        zfile.close()
        f.seek(0)
        whole = f.read()
        f.close()
        self.parts['whole'] = whole
        self.parts['encoding'] = self.document.settings.output_encoding
        self.parts['version'] = docutils.__version__ 
Example #2
Source File: _html_base.py    From blackmamba with MIT License 5 votes vote down vote up
def assemble_parts(self):
        writers.Writer.assemble_parts(self)
        for part in self.visitor_attributes:
            self.parts[part] = ''.join(getattr(self, part)) 
Example #3
Source File: writer.py    From StrepHit with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, builder):
        writers.Writer.__init__(self)
        self.builder = builder
        self.translator_class = self.builder.translator_class or WikisyntaxTranslator 
Example #4
Source File: __init__.py    From aws-builders-fair-projects with Apache License 2.0 5 votes vote down vote up
def assemble_parts(self):
        """Assemble the `self.parts` dictionary of output fragments."""
        writers.Writer.assemble_parts(self)
        for part in self.visitor_attributes:
            lines = getattr(self, part)
            if part in self.head_parts:
                if lines:
                    lines.append('') # to get a trailing newline
                self.parts[part] = '\n'.join(lines)
            else:
                # body contains inline elements, so join without newline
                self.parts[part] = ''.join(lines) 
Example #5
Source File: writer.py    From rst2pdf with MIT License 5 votes vote down vote up
def __init__(self, builder):
        writers.Writer.__init__(self)
        self.builder = builder
        self.output = u'' 
Example #6
Source File: __init__.py    From aws-builders-fair-projects with Apache License 2.0 5 votes vote down vote up
def get_transforms(self):
       return writers.Writer.get_transforms(self) + [
       # Convert specific admonitions to generic one
       writer_aux.Admonitions,
       # TODO: footnote collection transform
       ] 
Example #7
Source File: docutils_xml.py    From aws-builders-fair-projects with Apache License 2.0 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = XMLTranslator 
Example #8
Source File: manpage.py    From aws-builders-fair-projects with Apache License 2.0 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = Translator 
Example #9
Source File: __init__.py    From aws-builders-fair-projects with Apache License 2.0 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = ODFTranslator 
Example #10
Source File: textwriter.py    From aws-builders-fair-projects with Apache License 2.0 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self) 
Example #11
Source File: _html_base.py    From aws-builders-fair-projects with Apache License 2.0 5 votes vote down vote up
def get_transforms(self):
        return writers.Writer.get_transforms(self) + [writer_aux.Admonitions] 
Example #12
Source File: manpage.py    From aws-extender with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = Translator 
Example #13
Source File: __init__.py    From aws-extender with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = ODFTranslator 
Example #14
Source File: textwriter.py    From aws-extender with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self) 
Example #15
Source File: __init__.py    From blackmamba with MIT License 5 votes vote down vote up
def assemble_parts(self):
        """Assemble the `self.parts` dictionary of output fragments."""
        writers.Writer.assemble_parts(self)
        for part in self.visitor_attributes:
            lines = getattr(self, part)
            if part in self.head_parts:
                if lines:
                    lines.append('') # to get a trailing newline
                self.parts[part] = '\n'.join(lines)
            else:
                # body contains inline elements, so join without newline
                self.parts[part] = ''.join(lines) 
Example #16
Source File: __init__.py    From blackmamba with MIT License 5 votes vote down vote up
def get_transforms(self):
       return writers.Writer.get_transforms(self) + [
       # Convert specific admonitions to generic one
       writer_aux.Admonitions,
       # TODO: footnote collection transform
       ] 
Example #17
Source File: docutils_xml.py    From aws-extender with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = XMLTranslator 
Example #18
Source File: _html_base.py    From blackmamba with MIT License 5 votes vote down vote up
def get_transforms(self):
        return writers.Writer.get_transforms(self) + [writer_aux.Admonitions] 
Example #19
Source File: docutils_xml.py    From blackmamba with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = XMLTranslator 
Example #20
Source File: manpage.py    From blackmamba with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = Translator 
Example #21
Source File: __init__.py    From blackmamba with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = ODFTranslator 
Example #22
Source File: __init__.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def get_transforms(self):
       return writers.Writer.get_transforms(self) + [
       # Convert specific admonitions to generic one
       writer_aux.Admonitions,
       # TODO: footnote collection transform
       ] 
Example #23
Source File: __init__.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = LaTeXTranslator

    # Override parent method to add latex-specific transforms 
Example #24
Source File: _html_base.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def assemble_parts(self):
        writers.Writer.assemble_parts(self)
        for part in self.visitor_attributes:
            self.parts[part] = ''.join(getattr(self, part)) 
Example #25
Source File: _html_base.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def get_transforms(self):
        return writers.Writer.get_transforms(self) + [writer_aux.Admonitions] 
Example #26
Source File: docutils_xml.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = XMLTranslator 
Example #27
Source File: __init__.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self)
        self.translator_class = ODFTranslator 
Example #28
Source File: textwriter.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def __init__(self):
        writers.Writer.__init__(self) 
Example #29
Source File: __init__.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def assemble_parts(self):
        """Assemble the `self.parts` dictionary of output fragments."""
        writers.Writer.assemble_parts(self)
        for part in self.visitor_attributes:
            lines = getattr(self, part)
            if part in self.head_parts:
                if lines:
                    lines.append('') # to get a trailing newline
                self.parts[part] = '\n'.join(lines)
            else:
                # body contains inline elements, so join without newline
                self.parts[part] = ''.join(lines) 
Example #30
Source File: __init__.py    From AWS-Transit-Gateway-Demo-MultiAccount with MIT License 5 votes vote down vote up
def get_transforms(self):
       return writers.Writer.get_transforms(self) + [
       # Convert specific admonitions to generic one
       writer_aux.Admonitions,
       # TODO: footnote collection transform
       ]