transport_data.util.docutils.ODTWriter¶
- class transport_data.util.docutils.ODTWriter[source]¶
Bases:
WriterDocutils writer for OpenDocument Text.
This subclass works around bugs in the upstream class.
- __init__()¶
Methods
__init__()Assemble the self.parts dictionary.
Assemble the self.parts dictionary.
copy_from_stylesheet(outzipfile)Copy images, settings, etc from the stylesheet doc into target doc.
create_manifest()create_meta()modeled after get_stylesheet
Get the stylesheet from the visitor.
Transforms required by this class.
store_embedded_files(zfile)supports(format)Is format supported by this component?
Do final translation of self.document into self.output.
update_stylesheet(stylesheet_root, ...)Update xml style sheet element with language and region/country.
write(document, destination)Process a document into its final form.
write_zip_str(zfile, name, bytes_[, ...])Attributes
EXTENSIONMIME_TYPEName of the component type ('reader', 'parser', 'writer').
The name of the config file section specific to this component (lowercase, no brackets).
A list of names of config file sections that are to be applied before config_section, in order (from general to specific).
default_stylesheetdefault_stylesheet_pathdefault_templatedefault_template_pathdefault_transformsdocutils.io Output object; where to write the document.
The document to write (Docutils doctree); set by write().
Language module for the document; set by write().
Final translated form of document
Settings containing filesystem paths.
A dictionary of auxiliary defaults, to override defaults for settings defined in other components' setting_specs.
A dictionary of defaults for settings not in settings_spec (internal settings, intended to be inaccessible by command-line and config file).
Runtime settings specification.
Formats this writer supports.
List of hook functions which assist in resolving references.
Mapping of document part names to fragments of self.output.
- assemble_parts() None¶
Assemble the self.parts dictionary. Extend in subclasses.
See <https://docutils.sourceforge.io/docs/api/publisher.html>.
- component_type = 'writer'¶
Name of the component type (‘reader’, ‘parser’, ‘writer’). Override in subclasses.
- config_section = 'odf_odt writer'¶
The name of the config file section specific to this component (lowercase, no brackets). Override in subclasses.
- config_section_dependencies = ('writers',)¶
A list of names of config file sections that are to be applied before config_section, in order (from general to specific). In other words, the settings in config_section are to be overlaid on top of the settings from these sections. The “general” section is assumed implicitly. Override in subclasses.
- copy_from_stylesheet(outzipfile: ZipFile) None¶
Copy images, settings, etc from the stylesheet doc into target doc.
- destination = None¶
docutils.io Output object; where to write the document.
Set by write().
- document = None¶
The document to write (Docutils doctree); set by write().
- get_settings()¶
modeled after get_stylesheet
- get_stylesheet()¶
Get the stylesheet from the visitor. Ask the visitor to setup the page.
- language = None¶
Language module for the document; set by write().
- output = None¶
Final translated form of document
(str for text, bytes for binary formats); set by translate().
- parts¶
Mapping of document part names to fragments of self.output.
See Writer.assemble_parts() below and <https://docutils.sourceforge.io/docs/api/publisher.html>.
- relative_path_settings = ('odf_config_file', 'stylesheet')¶
Settings containing filesystem paths. Override in subclasses. Settings listed here are to be interpreted relative to the current working directory.
- settings_default_overrides = None¶
A dictionary of auxiliary defaults, to override defaults for settings defined in other components’ setting_specs. Override in subclasses.
- settings_defaults = {'output_encoding_error_handler': 'xmlcharrefreplace'}¶
A dictionary of defaults for settings not in settings_spec (internal settings, intended to be inaccessible by command-line and config file). Override in subclasses.
- settings_spec = ('ODF-Specific Options.', None, (('Specify a stylesheet. Default: "../../../envs/latest/lib/python3.13/site-packages/docutils/writers/odf_odt/styles.odt"', ['--stylesheet'], {'default': '../../../envs/latest/lib/python3.13/site-packages/docutils/writers/odf_odt/styles.odt', 'dest': 'stylesheet', 'metavar': '<filename>'}), ('Specify an ODF-specific configuration/mapping file relative to the current working directory.', ['--odf-config-file'], {'metavar': '<file>'}), ('Obfuscate email addresses to confuse harvesters.', ['--cloak-email-addresses'], {'action': 'store_true', 'default': False, 'dest': 'cloak_email_addresses', 'validator': <function validate_boolean>}), ('Do not obfuscate email addresses.', ['--no-cloak-email-addresses'], {'action': 'store_false', 'default': False, 'dest': 'cloak_email_addresses', 'validator': <function validate_boolean>}), ('Specify the thickness of table borders in thousands of a cm. Default is 35.', ['--table-border-thickness'], {'default': None, 'metavar': '<int>', 'validator': <function validate_nonnegative_int>}), ('Add syntax highlighting in literal code blocks.', ['--add-syntax-highlighting'], {'action': 'store_true', 'default': False, 'dest': 'add_syntax_highlighting', 'validator': <function validate_boolean>}), ('Do not add syntax highlighting in literal code blocks. (default)', ['--no-syntax-highlighting'], {'action': 'store_false', 'default': False, 'dest': 'add_syntax_highlighting', 'validator': <function validate_boolean>}), ('Create sections for headers. (default)', ['--create-sections'], {'action': 'store_true', 'default': True, 'dest': 'create_sections', 'validator': <function validate_boolean>}), ('Do not create sections for headers.', ['--no-sections'], {'action': 'store_false', 'default': True, 'dest': 'create_sections', 'validator': <function validate_boolean>}), ('Create links.', ['--create-links'], {'action': 'store_true', 'default': False, 'dest': 'create_links', 'validator': <function validate_boolean>}), ('Do not create links. (default)', ['--no-links'], {'action': 'store_false', 'default': False, 'dest': 'create_links', 'validator': <function validate_boolean>}), ('Generate endnotes at end of document, not footnotes at bottom of page.', ['--endnotes-end-doc'], {'action': 'store_true', 'default': False, 'dest': 'endnotes_end_doc', 'validator': <function validate_boolean>}), ('Generate footnotes at bottom of page, not endnotes at end of document. (default)', ['--no-endnotes-end-doc'], {'action': 'store_false', 'default': False, 'dest': 'endnotes_end_doc', 'validator': <function validate_boolean>}), ('Generate a bullet list table of contents, not a native ODF table of contents.', ['--generate-list-toc'], {'action': 'store_false', 'dest': 'generate_oowriter_toc', 'validator': <function validate_boolean>}), ('Generate a native ODF table of contents, not a bullet list. (default)', ['--generate-oowriter-toc'], {'action': 'store_true', 'default': True, 'dest': 'generate_oowriter_toc', 'validator': <function validate_boolean>}), ('Specify the contents of an custom header line. See ODF/ODT writer documentation for details about special field character sequences.', ['--custom-odt-header'], {'default': '', 'dest': 'custom_header', 'metavar': '<custom header>'}), ('Specify the contents of an custom footer line. See ODF/ODT writer documentation for details.', ['--custom-odt-footer'], {'default': '', 'dest': 'custom_footer', 'metavar': '<custom footer>'})))¶
Runtime settings specification. Override in subclasses.
Defines runtime settings and associated command-line options, as used by docutils.frontend.OptionParser. This is a tuple of:
Option group title (string or None which implies no group, just a list of single options).
Description (string or None).
A sequence of option tuples. Each consists of:
Help text (string)
List of option strings (e.g.
['-Q', '--quux']).Dictionary of keyword arguments sent to the OptionParser/OptionGroup
add_optionmethod.Runtime setting names are derived implicitly from long option names (’–a-setting’ becomes
settings.a_setting) or explicitly from the ‘dest’ keyword argument.Most settings will also have a ‘validator’ keyword & function. The validator function validates setting values (from configuration files and command-line option arguments) and converts them to appropriate types. For example, the
docutils.frontend.validate_booleanfunction, required by all boolean settings, converts true values (‘1’, ‘on’, ‘yes’, and ‘true’) to 1 and false values (‘0’, ‘off’, ‘no’, ‘false’, and ‘’) to 0. Validators need only be set once per setting. See the docutils.frontend.validate_* functions.See the optparse docs for more details.
More triples of group title, description, options, as many times as needed. Thus, settings_spec tuples can be simply concatenated.
- supported = ('odt',)¶
Formats this writer supports.
- supports(format: str) bool¶
Is format supported by this component?
To be used by transforms to ask the dependent component if it supports a certain input context or output format.
- translate() None¶
Do final translation of self.document into self.output. Called from write. Override in subclasses.
Usually done with a docutils.nodes.NodeVisitor subclass, in combination with a call to docutils.nodes.Node.walk() or docutils.nodes.Node.walkabout(). The
NodeVisitorsubclass must support all standard elements (listed in docutils.nodes.node_class_names) and possibly non-standard elements used by the current Reader as well.
- unknown_reference_resolvers = ()¶
List of hook functions which assist in resolving references.
Deprecated. Will be removed in Docutils 1.0
- update_stylesheet(stylesheet_root, language_code, region_code)¶
Update xml style sheet element with language and region/country.
- write(document: nodes.document, destination: Output) str | bytes | None¶
Process a document into its final form.
Translate document (a Docutils document tree) into the Writer’s native format, and write it out to its destination (a docutils.io.Output subclass object).
Normally not overridden or extended in subclasses.