Converts RST XML (Sphinx/ReST XML) into DocBook XML
Collect several cleanup steps
rstxml2db.cleanup.add_pi_in_screen(xml, limit=83, target='dbsuse-fo', fontsize='8pt')¶Add processing-instruction for long texts in screens
Note
This function modifies directly the XML tree
| Parameters: |
|---|
rstxml2db.cleanup.allelementswithid(xml)¶Generator: yielding all elements with an ‘id’ attribute
| Parameters: | xml – root tree or element |
|---|---|
| Yield: | XML element with id |
| Return type: | Iterator[lxml.etree.Element] |
rstxml2db.cleanup.alltableelements(xml)¶Generator: yield all table or informaltable elements
| Parameters: | xml – root tree or element node |
|---|---|
| Yield: | XML node, either table or informaltable |
| Return type: | Iterator[lxml.etree.Element] |
rstxml2db.cleanup.cleanupxml(xml)¶Cleanup steps to execute
Note
This function modifies directly the XML tree
| Parameters: | xml (lxml.etree._ElementTree) – XML tree |
|---|
rstxml2db.cleanup.finddoubleids(allids)¶Find all double IDs
| Parameters: | allids (list) – list with lxml.etree.Element |
|---|---|
| Returns: | all nodes which contains more than one IDs; èach entry
represented as (node, number) |
| Return type: | list |
rstxml2db.cleanup.fix_colspec_width(xml)¶columspec/@width from simple absolute values into the relative| Parameters: | xml (lxml.etree.Element) – root tree or element node |
|---|
rstxml2db.cleanup.remove_double_ids(xml, usedoubleids=True)¶Cleanup step to remove all IDs with no corresponding xref
Note
This function modifies directly the XML tree
| Parameters: |
|
|---|
Implements CLI parsing
rstxml2db.cli.check_arguments(parser, args)¶Checks the parsed arguments for consistency
| Parameters: |
|
|---|---|
| Returns: | parsed arguments, possibly enriched with additional |
| Return type: |
rstxml2db.cli.main(cliargs=None)¶Entry point for the application script
| Parameters: | cliargs (list) – Arguments to parse or None (=use sys.argv) |
|---|---|
| Returns: | error code |
| Return type: | int |
rstxml2db.cli.parsecli(cliargs=None)¶Parse CLI with argparse.ArgumentParser and return parsed result
| Parameters: | cliargs (list) – Arguments to parse or None (=use sys.argv) |
|---|---|
| Returns: | parsed CLI result |
| Return type: | argparse.Namespace |
rstxml2db.cli.prepareparams(params)¶Convert the list with NAME=VALUE strings into
tuples of ('NAME', 'VALUE')
| Parameters: | params (list) – a list with NAME=VALUE entries |
|---|---|
| Returns: | a new list with ('NAME', 'VALUE') entries |
| Return type: | list |
rstxml2db.cli.print_all_xsl_params(parser)¶Prints all availalbe XSLT parameters that can be used in -p/–param
| Parameters: | parser (argparse.ArgumentParse) – the argument parser |
|---|
Common error codes
Core variables, used in other modules.
rstxml2db.core.DEBUG_FORMAT = '[%(levelname)s] %(name)s:%(lineno)s %(message)s'¶logging format for debugging purposes
rstxml2db.core.DOCTYPE = '<!DOCTYPE {}\n[\n<!--\n <!ENTITY % entities SYSTEM "entity-decl.ent">\n %entities;\n-->\n]>'¶DOCTYPE declaration with placeholders
rstxml2db.core.LOGFILECONFIGS = ('/home/travis/build/openSUSE/rstxml2docbook/src/rstxml2db/logging.conf', '/home/travis/.config/rstxml2db/logging.conf')¶log config files to search for
rstxml2db.core.LOGLEVELS = {None: 30, 0: 30, 1: 20, 2: 10}¶Map verbosity to log levels
rstxml2db.core.LOGNAMES = {0: 'NOTSET', None: 'NOTSET', 10: 'DEBUG', 20: 'INFO', 30: 'WARNING', 40: 'ERROR', 50: 'CRITICAL'}¶Map log numbers to log names
rstxml2db.core.LOG_CONFIG = {'formatters': {'default': {'datefmt': '%Y-%m-%d %H:%M:%S', 'format': '%(levelname)s:%(name)s:%(message)s'}, 'rstxml2db': {'datefmt': '%Y%m%dT%H:%M:%S', 'format': '[%(levelname)s] %(name)s:%(lineno)s %(message)s'}}, 'handlers': {'console': {'class': 'logging.StreamHandler', 'formatter': 'default', 'level': 'NOTSET'}, 'rstxml2db': {'class': 'logging.StreamHandler', 'formatter': 'rstxml2db', 'level': 'DEBUG'}}, 'loggers': {'rstxml2db': {'handlers': ['rstxml2db'], 'propagate': False}}, 'root': {'level': 'DEBUG'}, 'version': 1}¶fallback logging configuration
rstxml2db.core.NSMAP = {'d': 'http://docbook.org/ns/docbook', 'doc': 'urn:x-suse:xslt-doc', 'xi': 'http://www.w3.org/2001/XInclude', 'xl': 'http://www.w3.org/1999/xlink', 'xsl': 'http://www.w3.org/1999/XSL/Transform'}¶Namespace mappings
rstxml2db.core.XSLTINLINES = '/home/travis/build/openSUSE/rstxml2docbook/src/rstxml2db/move-inlines-into-para.xsl'¶Stylesheet to move outplaced inlines into paragraph
rstxml2db.core.XSLTMOVEBLOCKS = '/home/travis/build/openSUSE/rstxml2docbook/src/rstxml2db/move-blocks-outof-para.xsl'¶Stylesheet to move block elements out of <paragraph>
rstxml2db.core.XSLTRESOLVE = '/home/travis/build/openSUSE/rstxml2docbook/src/rstxml2db/resolve.xsl'¶Stylesheet to resolves RST XML :file:index.xml
file into one, single RST XML file
rstxml2db.core.XSLTRST2DB = '/home/travis/build/openSUSE/rstxml2docbook/src/rstxml2db/rstxml2db.xsl'¶Stylesheet to transform RST XML tree into DocBook 5
rstxml2db.core.XSLTSPLIT = '/home/travis/build/openSUSE/rstxml2docbook/src/rstxml2db/split_xml.xsl'¶Stylesheet to split up the XML file