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

22.8. PriIndex._buildAs(): Build an “As” line

cbchistlib.py
# - - -   P r i I n d e x . _ b u i l d A s

    def _buildAs(self, parent, name, lat, lon):
        '''Build an "As" entry.

          [ (parent is an et.Element) and
            (name, lat, and lon are strings) ->
              parent  +:=  an "As" entry showing name (if different
                  from self.circle.cir_name), coordinates (if lat
                  or lon differ from self.circle's coordinates),
                  and a year list from self.effortList entries
                  that match name, lat, and lon ]
        '''
        #-- 1
        # [ if name != self.circle.cir_name ->
        #       namePart  :=  ' ' + name
        #   else ->
        #       namePart  :=  '' ]
        if name != self.circle.cir_name:
            namePart = ' %s' % name
        else:
            namePart = ''

See Section 27, “latLonFormat(): Present the center coordinates in standard format”.

cbchistlib.py
        #-- 2
        # [ if (lat or lon differ from self.circle's coordinates ->
        #     coordPart  :=  ' ' + (lat and lon formatted as unicode)
        #   else ->
        #     coordPart  :=  '' ]
        if ((self.circle.lat != lat) or (self.circle.lon != lon)):
            coordPart = ' %s' % latLonFormat(lat, lon)
        else:
            coordPart = ''

Next we the set of Effort instances that match the name and center we are looking for.

cbchistlib.py
        #-- 3
        # [ variantEfforts  :=  elements of self.effortList for which
        #       as_name, as_lat, and as_lon match name, lat, and lon ]
        variantEfforts = [ effort
                           for effort in self.effortList
                           if ( (effort.as_name == name) and
                                (effort.as_lat == lat) and
                                (effort.as_lon == lon) ) ]

For the generated XHTML, see Section 4.3.1, “Primary entry format”. See also Section 24, “yearBrackets(): Display a bracketed list of years worked”.

cbchistlib.py
        #-- 4
        # [ years  :=  bracketed year numbers from variantEfforts ]
        years = yearBrackets(variantEfforts)

        #-- 5
        parent.append(
            E.div(CLASS_AS_DIV,
                "As",
                E.span(CLASS_SEC_NAME, namePart),
                E.span(CLASS_LAT_LON, coordPart), ' ',
                E.span(CLASS_YEAR_LIST, years)))