Abstract
Describes the implementation of a system for representing a classification of a set of birds, using the Python programming language and XML (Extensible Markup Language).
This publication is available in Web form and also as a PDF document. Please
forward any comments to john@nmt.edu.
Table of Contents
xnomo3.py module: prologueclass TxnyTxny.genAbbrs(): Generate
all valid bird codesTxny.genTxKeys(): Generate all
phylogenetic key numbersTxny.lookupAbbr()Txny.lookupCollision()Txny.lookupSci()Txny.lookupTxKey()Txny.abbrToEng()Txny.abbrToEngComma()Txny.abbrToHtml()Txny.abbrToHtmlComma()Txny.abbrHtmlSubelt()Txny.abbrHtmlSubeltComma()Txny.abbrToTeX()Txny.abbrToTeXComma()Txny.abbrToRawEng()Txny.__init__()Txny.__openDoc(): Open and validate the
XML fileTxny.__readTaxonomy()Txny.__buildMaps(): Index by key and
scientific nameTxny.__addTaxonMaps(): Add a taxon
to the internal dictionariesTxny.__readAbbrs()Txny.__readCollisions()Txny.__addCollision(): Add one
collisionclass Hierclass Rank: One taxonomic rankclass TaxonTaxon.contains()Taxon.nearestAncestor()Taxon.childContaining(): Find child
containing a descendantTaxon.__cmp__(): Compare taxa
in phylogenetic orderTaxon.__getitem__()Taxon.__iter__()Taxon.__len__()Taxon.__str__()Taxon.engHtml()Taxon.engHtmlComma()Taxon.engHtmlSubelt()Taxon.engHtmlSubeltComma()Taxon.__init__(): The
constructorTaxon.__engNames(): Build the variants on
the English nameUtility functions for the xnomo3.py modulehtmlify(): Mark up text for HTMLhtmlSubelt(): Add a name to an et.ElementuniQuotes(): Convert double-quotes to
Unicode paired formclass Htmler: State machine for HTML
markupHtmler.__init__()Htmler.convert()Htmler._italStart()Htmler._italEnd()texify(): Mark up text for TEXclass Texer: State machine for TEX
markupTexer.__init__()Texer.convert()abbr.py moduleabbreviate()engComma(): Invert an English nameengDeComma(): Normalize an English
namefixAbbr(): Standardize a bird codeclass BirdIdBirdId.__init__()BirdId.standardize()birdId.engComma(): Inverted English
nameBirdId.commafy(): Invert word order
(static method)BirdId.__str__()BirdId.scan()BirdId.scanFlat()BirdId.scanAbbr()BirdId.scanAbbrFlat()BirdId.parse(): Parse a code
from a stringtest3: A test driverThis document describes the internals of the programs associated with xnomo3: A system for representing bird taxonomy. Refer to that document for downloadable online files.
In addition to its utility in bird records management, this module is also an example of several useful techniques:
Literate programming, the writing of code and documentation as a single process with a single source file. See the author's page on lightweight literate programming.
For the program that extracts the Python source code from this document's DocBook-XML source file, see litlxml: A source extractor for lightweight literate programming.
Cleanroom (zero-defect) programming. See Toward Zero-defect Programming by Allan M. Stavely (Addison-Wesley, 1999, ISBN 0-201-38595-3) for an overview of this methodology, and see also the author's Cleanroom pages for details of the method as he practices it.
XML processing using the Python lxml
package; see Python XML processing with lxml.