This method is used by both XHTML and PDF rendering to construct the text to be displayed in the table cell.
# - - - C e n s u s C e l l . _ d i s p l a y
def _display(self):
'''Generate the displayed text.
[ return self's contents as a text string ]
'''
There are four categories: regular, questional, count-week,
and questionable count-week. First we build a list of the
numbers for each, each with its characteristic suffix (if
any), but leave out the ones whose counts are zero. Although
Section 43.3, “CensusTotal.html()” sounds specific to HTML,
it does not actually use any markup, so the result is suitable
for XSL-FO as well.
#-- 1
# [ textList +:= XHTML renderings of any of self.q,
# self._plus, and self._qPlus that are not in the
# initial state ]
textList = [ censusTotal.html()
for censusTotal in (self._regular, self._q, self._plus,
self._qPlus)
if censusTotal.total != 0 ]
If none of the category totals had any data, textList will be empty, and we will display
“-” as a placeholder; otherwise
we return the contents of the list joined with commas between
them.
#-- 2
# [ if textList is empty ->
# text := '-'
# else -> elements of textList joined with commas ]
if len(textList) == 0:
text = '-'
else:
text = ','.join(textList)
#-- 3
return text