To build the index, we need the base class defined in Section 21, “
class BaseIndex: Base class for regional
page index entries” and its two derived classes Section 22, “
class PriIndex: Primary regional index
entry” and Section 23, “
class SecIndex: Secondary regional index
entry”. The work proceeds in three phases.
Find every circle that occurs all or partly in the region
whose code is specified by
and which has at least one effort in the date range
RegArgs().lastYear. Then, for each qualified
circle, build a
PriIndex instance, plus
zero or more
representing other names with the same center coordinates,
and throw all these instances into a list.
Sort the list using the function defined in Section 21.2, “
For each element of the sorted list, call its
.html() method to generate the XHTML form of the
# - - - b u i l d I n d e x S e c t i o n def buildIndexSection(form, db, firstYear, lastYear, isOverlap): '''Build the index of all circles. [ (form is an et.Element) and (db is a pycbc.CBCDatabase instance) and (firstYear is the first included year number in year-number format) and (lastYear is the last included year number in year-number format) and (isOverlap is True iff overlap is desired) -> form := form with index entries added for circles in the region with code RegArgs().reg_code that fall within the year range specified by RegArgs() ] '''
For the logic that builds the primary and secondary entries,
see Section 8.9, “
buildEntries(): Build all the
#-- 1 # [ entryList := instances of BaseEntry representing index # elements from db for region code RegArgs().reg_code ] entryList = buildEntries(db, RegArgs().reg_code, firstYear, lastYear, isOverlap) #-- 2 # [ entryList := entryList ordered by the .__cmp__() method of # its elements ] entryList.sort() #-- 3 # [ form +:= XHTML renderings of the elements of entryList in # the same order ] for entry in entryList: entry.html(form)