Tweaks replacing for-loops with iterator expressions

svn: r13664
This commit is contained in:
Gerald Britton 2009-11-23 20:52:04 +00:00
parent 2c3fe84b9b
commit 9698b0306f

View File

@ -333,12 +333,10 @@ class BasePage(object):
attr_data_row.append(note_row) attr_data_row.append(note_row)
# display attribute list # display attribute list
for (colclass, value) in attr_data_row: trow.extend(
Html("td", value, class_ = "Column" + colclass,
# determine if same row or not? inline = (colclass == "Type" or colclass == "Sources"))
samerow = (colclass == "Type" or colclass == "Sources") for (colclass, value) in attr_data_row)
trow += Html("td", value, class_ = "Column%s" % colclass, inline = samerow)
# return table row to its caller # return table row to its caller
return trow return trow
@ -471,14 +469,10 @@ class BasePage(object):
# begin event table row # begin event table row
trow = Html("tr") trow = Html("tr")
trow.extend(
for (label, colclass, data) in event_data: Html("td", data or " ", class_ = "Column" + colclass,
data = data or " " inline = (not data or colclass == "Date"))
for (label, colclass, data) in event_data)
# determine if information will fit on same line?
samerow = (data == " " or colclass == "Date")
trow += Html("td", data, class_ = "Column%s" % colclass, inline = samerow)
# return events table row to its callers # return events table row to its callers
return trow return trow
@ -601,8 +595,9 @@ class BasePage(object):
# finish the label's missing piece # finish the label's missing piece
header_row[5][0] += _("Parents") if LDSSealedType == "Person" else _("Spouse") header_row[5][0] += _("Parents") if LDSSealedType == "Person" else _("Spouse")
for (label, colclass) in header_row: trow.extend(
trow += Html("th", label, class_ = "Column%s" % colclass, inline = True) Html("th", label, class_ = "Column" + colclass, inline = True)
for (label, colclass) in header_row)
# start table body # start table body
tbody = Html("tbody") tbody = Html("tbody")
@ -628,13 +623,10 @@ class BasePage(object):
trow = Html("tr") trow = Html("tr")
tbody += trow tbody += trow
for (colclass, value) in lds_ord_data: trow.extend(
value = value or " " Html("td", value or " ", class_ = "Column" + colclass,
inline = (not value or colclass == "LDSDate"))
# determine if inline = True or False for (colclass, value) in lds_ord_data)
samerow = (value == " " or colclass == "LDSDate")
trow += Html("td", value, class_ = "Column%s" % colclass, inline = samerow)
# return table to its callers # return table to its callers
return table return table
@ -858,22 +850,23 @@ class BasePage(object):
trow = Html("tr") trow = Html("tr")
thead += trow thead += trow
for (label, colclass) in [ header_row = [
(THEAD, "Type"), (THEAD, "Type"),
(VHEAD, "Value"), (VHEAD, "Value"),
(SHEAD, "Sources"), (SHEAD, "Sources"),
(NHEAD, "Notes") ]: (NHEAD, "Notes") ]
trow += Html("th", label, class_ = "Column%s" % colclass, inline = True)
trow.extend(
Html("th", label, class_ = "Column" + colclass, inline = True)
for (label, colclass) in header_row)
# begin table body # begin table body
tbody = Html("tbody") tbody = Html("tbody")
table += tbody table += tbody
tbody.extend(
for attr in attrlist: self.dump_attribute(attr, showsrc)
for attr in attrlist)
tbody += self.dump_attribute(attr, showsrc)
# return section to its caller # return section to its caller
return section return section
@ -1233,6 +1226,7 @@ class BasePage(object):
try: try:
note_text = unicode(note_text) note_text = unicode(note_text)
except UnicodeDecodeError: except UnicodeDecodeError:
print "unicode(note_text) exception"
note_text = unicode(str(note_text), errors='replace') note_text = unicode(str(note_text), errors='replace')
# add section title # add section title
@ -2131,13 +2125,15 @@ class EventListPage(BasePage):
trow = Html("tr") trow = Html("tr")
thead += trow thead += trow
for (label, colclass) in [ header_row = [
[_("Event"), "Event"], [_("Event"), "Event"],
[DHEAD, "Date"], [DHEAD, "Date"],
[_("Person"), "Person"], [_("Person"), "Person"],
[_("Partner"), "Partner"] ]: [_("Partner"), "Partner"] ]
trow += Html("th", label, class_ = "Column%s" % colclass, inline = True) trow.extend(
Html("th", label, class_ = "Column" + colclass, inline = True)
for (label, colclass) in header_row)
# begin table body # begin table body
tbody = Html("tbody") tbody = Html("tbody")
@ -2191,13 +2187,10 @@ class EventListPage(BasePage):
for more information: see get_event_data() for more information: see get_event_data()
""" """
event_data = self.get_event_data(evt, evt_ref, False, False, False, False, subdirs, True) event_data = self.get_event_data(evt, evt_ref, False, False, False, False, subdirs, True)
for (label, colclass, data) in event_data: trow.extend(
data = data or " " Html("td", data or " ", class_ = "Column" + colclass,
inline = (not data or colclass == "Event" or colclass == "Date"))
# determine if same row or not? for (label, colclass, data) in event_data)
samerow = (data == " " or colclass in ["Event", "Date"])
trow += Html("td", data, class_ = "Column%s" % colclass, inline = samerow)
# determine if same row or not? # determine if same row or not?
samerow = (person_hyper == " ") samerow = (person_hyper == " ")