Next / Previous / Contents / Shipman's homepage

4. Imported modules

Next are imported modules.

xnomo3.py
# - - - - -   I m p o r t s

The standard Python regular expression module.

xnomo3.py
import re

We use a number of utility functions from Section 11, “The abbr.py module”. To avoid collision with variables named abbr, we import it as abbrMod.

xnomo3.py
import abbr as abbrMod

The lxml.etree package handles XML parsing; see Python XML processing with lxml. We also use the etbuilder.py module from that document for functions such as Section 6.11, “Txny.abbrHtmlSubelt(), so we get the et module from there (same as lxml.etree), plus the E() constructor and also the CLASS() helper function.

xnomo3.py
# - - - - -   I m p o r t s

from etbuilder import et, E, CLASS, addText

File rnc_txny.py contains symbolic constants for all the XML element and attribute names used in the schema. It is created automatically from the schema: see pyrang: A single-sourcing tool for Python-XML applications.

xnomo3.py
import rnc_txny as rnc

We use the rnc_validate.py module to validate the XML file against the txny.rng schema. This module is part of the pylxml package.

xnomo3.py
import rnc_validate