Here is the class constructor, which takes as its argument the name of the XML data file.
# - - - T x n y . _ _ i n i t _ _ - - -
def __init__ ( self, dataFile=None ):
"""Constructor for the Txny object.
"""
For the logic that finds the file, opens it, and checks the
version, see Section 6.17, “Txny.__openDoc(): Open and validate the
XML file”.
#-- 1 --
# [ if dataFile, defaulting to DEFAULT_FILE_NAME, names a
# readable XML file that is valid against the txny.rnc
# schema ->
# doc := that file as an et.ElementTree
# root := the root node of that tree ]
# else -> raise IOError ]
doc = self.__openDoc(dataFile)
root = doc.getroot()
First we process the rankSet element,
which returns a Hier instance:
#-- 2 --
# [ self.hier := a new Hier instance made from root's
# RANK_SET_N subtree ]
rankSetNode = root.find(rnc.RANK_SET_N)
self.hier = Hier ( rankSetNode )
Next we process the taxonomic tree:
#-- 3 --
# [ self.root := a Taxon instance made from root's TAXONOMY_N
# subtree, with children representing that subtree
# self.__txKeyMap := as invariant, from that subtree
# self.__sciMap := as invariant, from that subtree ]
taxonomyNode = root.find(rnc.TAXONOMY_N)
self.__readTaxonomy ( taxonomyNode )
Now, read the set of valid bird codes, then the set of collisions:
#-- 4 --
# [ self.__abbrMap := as invariant, from root's ABBR_SET_N
# subtree
# self.__abbrEng := as invariant, from that subtree ]
abbrSetNode = root.find(rnc.ABBR_SET_N)
self.__readAbbrs ( abbrSetNode )
#-- 5 --
# [ self.__collMap := as invariant, from root's
# COLLISION_SET_N subtree ]
collSetNode = root.find(rnc.COLLISION_SET_N)
self.__readCollisions ( collSetNode )