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

23.2. SecIndex.html()

cbchistlib.py
# - - -   S e c I n d e x . h t m l

    def html(self, parent):
        '''Add our content to the report.

          [ parent is an et.Element ->
              parent  +:=  XHTML rendering of self with a link
                  to the primary index entry for self.priIndex.circle ]
        '''

In order to display the list of years worked under the secondary name, we find all the Effort instances for the primary, and select the ones whose names match the secondary name. If there are none, then all the variants are outside the given year range, and we generate no output.

cbchistlib.py
        #-- 1
        # [ variantEffList  :=  Effort instances for priIndex.effortList
        #       whose effort.as_name fields match priIndex.cir_name ]
        variantEffList = [
            effort
            for effort in self.priIndex.effortList
            if ((effort.as_name == self.priIndex.cir_name) and
                (effort.year_no >= self.firstYear) and
                (effort.year_no <= self.lastYear)) ]

        #-- 2
        if len(variantEffList) == 0:
            return

For the generated XHTML, see Section 4.3.2, “Secondary entry format”. See also Section 27, “latLonFormat(): Present the center coordinates in standard format” and Section 24, “yearBrackets(): Display a bracketed list of years worked”.

cbchistlib.py
        #-- 3
        # [ parent  +:=  a new div et.Element of class CLASS_SEC_DIV
        #       containing (a span of class CLASS_SEC_NAME containing
        #       self.variant) + (": See ") ]
        div = subElement(parent,
                  E.div(CLASS_SEC_DIV,
                      E.span(CLASS_SEC_NAME, self.variant),
                      ": See "))

        #-- 4
        # [ div  +:=  a new 'a' element linking to the primary index
        #       entry for self.priIndex.circle
        #   link  :=  that new 'a' element ]
        priAnchor = '#' + anchorName(self.priIndex.circle)
        link = subElement(div, E.a(href=priAnchor))

        #-- 5
        # [ node  +:=  (self.circle.cir_name) + (a span of class
        #       CLASS_LAT_LON displaying circle.lat and circle.lon) ]
        addText(link, self.circle.cir_name)
        link.append(
            E.span(CLASS_LAT_LON,
                   latLonFormat(self.priIndex.circle.lat,
                   self.priIndex.circle.lon)))

        #-- 6
        # [ div  +:=  a span of class CLASS_YEAR_LIST displaying the
        #       years in variantEffList ]
        div.append(        
            E.span(CLASS_YEAR_LIST,
                   yearBrackets(variantEffList)))