This method looks through the records inside a birdnotes.DayNotes instance to see if any of the
records are flagged as notable. If so, it generates a
div element containing a list of their names.
# - - - M o n t h C e l l . _ _ n o t a b l e s B l o c k
def __notablesBlock ( self, parent, dayNotes ):
'''If any records are notable, display their names.
[ (parent is an et.Element) and
(dayNotes is a DayNotes instance) ->
if any records within dayNotes are flagged as notable ->
parent +:= a div element containing the names
from all notable records
else -> I ]
'''
First we'll go through the BirdForm
instances inside dayNotes and accumulate a
list of those flagged as notable. If the list is empty,
we're done.
#-- 1 --
notablesList = [ birdForm
for birdForm in dayNotes.genForms()
if birdForm.notable ]
#-- 2 --
if len(notablesList) == 0:
return
The block is a “div class='loc-child” element. Its first child is a span
class='notable' containing the label
“Notable:”. The bird names
follow, separated by commas.
#-- 3 --
# [ parent +:= a new div element with class=LOC_CHILD_CLASS
# div := that new element ]
div = et.SubElement ( parent, 'div' )
div.attrib['class'] = LOC_CHILD_CLASS
See Section 23.9, “MonthCell.__span(): Add a span inline”.
#-- 4 --
# [ div +:= a new span element with class=NOTABLE_CLASS,
# containing the text 'Notable: ', plus a space ]
self.__span ( div, NOTABLE_CLASS, 'Notable: ' )
tccpage2.addTextMixed ( div, NBSP )
#-- 5 --
# [ div +:= names of the birds in notablesList,
# separated by ', ' ]
nameList = [ str(birdForm.birdId)
for birdForm in notablesList ]
tccpage2.addTextMixed ( div, '; '.join ( nameList ) )