See Section 4.5, “XHTML for locality definitions”.
# - - - M o n t h C e l l . _ _ l o c D e f
def __locDef ( self, parent, loc ):
'''Display the definition of one locality.
[ (parent is an et.Element) and
(loc is a birdnotes.Loc instance) ->
parent +:= a div element displaying loc ]
'''
All the content generated by this method is wrapped in a
div class=LOC_DEF_CLASS. In each case,
the first content is “@”
followed by the locality's code, a colon, and the locality's
name.
#-- 1 --
# [ parent +:= a div element with class=LOC_DEF_CLASS
# topDiv := that div element ]
topDiv = et.SubElement ( parent, 'div' )
topDiv.attrib['class'] = LOC_DEF_CLASS
#-- 2 --
# [ topDiv +:= '@' + loc.code + ': ' + loc.name ]
topDiv.text = '@%s: %s' % (loc.code, loc.name )
If there is a narrative block for this locality, render
it next inside a div
class=LOC_NARRATIVE_CLASS. The text is just a
string, not an instance of the Narrative
class.
#-- 3 --
# [ if bool(loc.text) ->
# topDiv +:= loc.text, wrapped in a div element
# with class=LOC_NARRATIVE_CLASS
# else -> I ]
if loc.text:
narraDiv = et.SubElement ( topDiv, 'div' )
narraDiv.attrib['class'] = LOC_NARRATIVE_CLASS
narraDiv.text = loc.text
The list of GPS waypoints follows, if there are any.
#-- 4 --
# [ topDiv +:= a sequence of divs with class
# LOC_NARRATIVE_CLASS containing GPS descriptions
# from loc, if any ]
for gps in loc.genGps():
narraDiv = et.SubElement ( topDiv, 'div' )
narraDiv.attrib['class'] = LOC_NARRATIVE_CLASS
narraDiv.text = ( 'GPS: %s %s' %
(gps.waypoint, gps.text) )