Next / Previous / Contents / TCC Help System / NM Tech homepage

36.4. CensusRowLabel._htmlCompound()

For design details, see Section 36.2, “CensusRowLabel.html().

cbchistlib.py
# - - -   C e n s u s R o w L a b e l . _ h t m l C o m p o u n d

    def _htmlCompound(self, sox):
        '''Format a compound name: abbr stacked on top of (rel+abbr2)

          [ sox is a sox.Sox instance ->
              if self.birdId.abbr and self.birdId.abbr2 are both
              defined in self.birdId.txny ->
                sox  +:=  (a div containing the Taxon for
                    self.birdId.abbr, formatted as XHTML in inverted
                    order) + (a div containing self.birdId.rel +
                    (' ') + the Taxon for self.birdId.abbr2, formatted
                    as XHTML in inverted order)
              else -> raise ScriptError ]
        '''
        #-- 1
        # [ if self.birdId.abbr is defined in self.birdId.txny ->
        #       name1  :=  the corresponding inverted English name
        #                  as XHTML
        #   else -> raise ScriptError ]
        try:
            name1 = self.birdId.txny.abbrToHtmlComma(self.birdId.abbr)
        except KeyError:
            raise ScriptError("Unknown bird code: '%s'" % self.birdId.abbr)

        #-- 2
        # [ if self.birdId.abbr2 is defined in self.birdId.txny ->
        #       name1  :=  the corresponding inverted English name
        #                  as XHTML
        #   else -> raise ScriptError ]
        try:
            name2 = self.birdId.txny.abbrToHtmlComma(self.birdId.abbr2)
        except KeyError:
            raise ScriptError("Unknown bird code: '%s'" % self.birdId.abbr2)

        #-- 3
        # [ sox  +:=  (a div containing name1) + (a div containing
        #             self.birdId.rel + " " + name2) ]
        sox.leaf("div", name1)
        sox.leaf("div", "%s %s" % (self.birdId.rel, name2))