This method handles building the .__abbrMap dictionary from the ABBR_SET_N node.
# - - - T x n y . _ _ r e a d A b b r s - - -
def __readAbbrs ( self, abbrSetNode ):
"""Read the ABBR_SET_N subtree and build self.__abbrMap.
[ abbrSetNode is a ABBR_SET_N node ->
self.__abbrMap := a dictionary whose keys are the
valid bird codes in self, with the corresponding
values the Taxon object for each code
self.__abbrEng := as invariant, from that subtree
self.__abbrTex := as invariant, from that subtree ]
"""
#-- 1 --
# [ self.__abbrMap := a new, empty dictionary
# self.__abbrEng := a new, empty dictionary
# self.__abbrTex := a new, empty dictionary
# abbrNodeList := list of the ABBR_N children of abbrSetNode ]
self.__abbrMap = {}
self.__abbrEng = {}
self.__abbrTex = {}
abbrNodeList = abbrSetNode.xpath ( rnc.ABBR_N )
#-- 2 --
# [
for abbrNode in abbrNodeList:
#-- 2 body --
# [ abbrNode is a ABBR_N Element whose SCI_A attribute
# is a scientific name defined in self.__sciMap ->
# self.__abbrMap +:= an entry mapping the uppercased
# CODE_A attribute of abbrNode |-> the Taxon
# in self with that scientific name
# self.__abbrEng +:= an entry mapping the uppercased
# CODE_A attribute of abbrNode |-> the text content
# of abbrNode
# self.__abbrTeX +:= an entry mapping the uppercased
# CODE_A attribute of abbrNode |-> the content of
# of the TEX_NAME_N child of abbrNode, if any,
# defaulting to the text content of abbrNode ]
abbr = abbrNode.attrib[rnc.CODE_A]
upAbbr = abbr.upper().ljust(ABBR_L)
sci = abbrNode.attrib[rnc.SCI_A]
eng = textContent ( abbrNode ).strip()
tex = getChildContent ( abbrNode, rnc.TEX_NAME_N )
if not tex:
tex = eng
taxon = self.__sciMap[sci]
self.__abbrMap[upAbbr] = taxon
self.__abbrEng[upAbbr] = eng
self.__abbrTex[upAbbr] = tex