Each instance of this class holds the information in one row of the index table: the year number, and a list of the months for which valid HTML monthly pages have been built.
# - - - - - c l a s s Y e a r R o w
class YearRow:
'''Represents one year's line in the index table.
Exports:
YearRow ( yearCollection, txny, yyyy ):
[ (yearCollection is the parent YearCollection) and
(txny is an xnomo3.Txny instance) and
(yyyy is a four-digit year as a string) ->
return a new, empty YearRow with year=yyyy ]
.yearCollection: [ as passed to constructor, read-only ]
.txny: [ as passed to constructor, read-only ]
.yyyy: [ as passed to constructor, read-only ]
.__len__(self):
[ return the number of months in self ]
.__getitem(self, mm):
[ mm is a month key as 'mm' ->
if self has a month mm ->
return the corresponding MonthCell
else -> raise KeyError ]
.firstMonth():
[ if self has any months ->
return the month key of the first as 'mm'
else -> raise KeyError ]
.lastMonth():
[ if self has any months ->
return the month key of the last as 'mm'
else -> raise KeyError ]
.predecessor ( mm ):
[ if 'mm' is a month key in self ->
if self has any months before mm ->
return the last such month key as 'mm'
else -> raise KeyError ]
.successor ( mm ):
[ if 'mm' is a month key in self ->
if self has any months after mm ->
return the first such month key as 'mm'
else -> raise KeyError ]
.readAllMonths():
[ self := self with MonthCell instances added for
XML notes files in directory yyyy valid
against birdnotes.rnc and txny
sys.stderr +:= error message(s) for invalid XML
notes files in that directory, if any ]
State/Invariants:
.__monthMap:
[ a dictionary whose keys are two-digit, zero-filled
month numbers, and each corresponding value is the
MonthCell instance representing that month's
field notes ]
'''