rstxml2db.xml package

Submodules

rstxml2db.xml.process module

Transform the RSTXML file into DocBook

rstxml2db.xml.process.logging_xslt(resultxslt, logger=<Logger rstxml2db.xml.process (WARNING)>)

Log result from XSLT transformation

Parameters:
rstxml2db.xml.process.process(args)

Process arguments from CLI parser

Parameters:args – result from argparse parser
Returns:True or False
Return type:bool
rstxml2db.xml.process.step_blockelements_transform(tree, args)
Step 2: Moves block elements inside <paragraphs> outside
of <paragraphs>
Parameters:
  • tree – tree of class lxml.etree._ElementTree
  • args – argument result from argparse
Returns:

XML tree

Return type:

lxml.etree._ElementTree

rstxml2db.xml.process.step_inlines_into_para_transform(tree, args)

Step 3: Move misplaced inline elements into <paragraph>

Parameters:
  • tree – tree of class lxml.etree._ElementTree
  • args – argument result from argparse
Returns:

XML tree

Return type:

lxml.etree._ElementTree

rstxml2db.xml.process.step_resolve_transform(tree, args)

Step 1: Resolve any outgoing references in the RST XML document

Parameters:
  • tree – tree of class lxml.etree._ElementTree
  • args – argument result from argparse
Returns:

XML tree

Return type:

lxml.etree._ElementTree

rstxml2db.xml.process.step_rst2db_transform(tree, args)

Step 4: Transform clean RST XML into DocBook 5

Parameters:
  • tree – tree of class lxml.etree._ElementTree
  • args – argument result from argparse
Returns:

XML tree

Return type:

lxml.etree._ElementTree

rstxml2db.xml.process.transform(doc, args)

Transformation step

Parameters:
  • doc – tree of class lxml.etree._ElementTree
  • args – argument result from argparse
Returns:

XML tree

Return type:

lxml.etree._ElementTree

rstxml2db.xml.process.write_result_tree(xml, name)

Write result tree

Parameters:
  • xml (lxml.etree._ElementTree) – the tree
  • name (str) – filename to write the tree to

rstxml2db.xml.struct module

rstxml2db.xml.struct.addchapter(xml, convfile)

Replace first chapter with content of conventions file

Parameters:
  • xmllxml.etree._ElementTree
  • convfile – filename to some conventions, usually as root element <preface> or <chapter>
rstxml2db.xml.struct.addlegalnotice(xml, legalfile)

Add legalnotice file into book/bookinfo

Parameters:
  • xmllxml.etree._ElementTree
  • legalfile – filename with root element <legalnotice>

rstxml2db.xml.util module

rstxml2db.xml.util.quoteparams(args)

Quote parameters with etree.XSLT.strparam()

Parameters:args – result from argparse parser
Returns:parameter list with quoted values
Return type:list

Module contents

The XML module

rstxml2db.xml.addchapter(xml, convfile)

Replace first chapter with content of conventions file

Parameters:
  • xmllxml.etree._ElementTree
  • convfile – filename to some conventions, usually as root element <preface> or <chapter>
rstxml2db.xml.addlegalnotice(xml, legalfile)

Add legalnotice file into book/bookinfo

Parameters:
  • xmllxml.etree._ElementTree
  • legalfile – filename with root element <legalnotice>
rstxml2db.xml.process(args)

Process arguments from CLI parser

Parameters:args – result from argparse parser
Returns:True or False
Return type:bool
rstxml2db.xml.quoteparams(args)

Quote parameters with etree.XSLT.strparam()

Parameters:args – result from argparse parser
Returns:parameter list with quoted values
Return type:list
rstxml2db.xml.transform(doc, args)

Transformation step

Parameters:
  • doc – tree of class lxml.etree._ElementTree
  • args – argument result from argparse
Returns:

XML tree

Return type:

lxml.etree._ElementTree