This function builds just the content part of the room page for one room. For the generated XHTML, see Section 3.2, “XHTML for the room page”.
# - - - b u i l d R o o m T a b l e
def buildRoomTable ( parent, room, reportInfo, clientSet ):
'''Build the content of a room's client page.
[ (parent is an et.Element) and
(room is a Room instance) and
(reportInfo is a ReportInfo) and
(clientSet is a ClientSet) ->
parent +:= table of clients in room room.roomPrefix
from clientSet with devices from reportInfo ]
'''
For the constants used here, see
Section 6.22, “TABLE_ATTRS”;
Section 6.23, “L_ALIGN”;
Section 6.24, “R_ALIGN”;
Section 6.25, “TOP_VALIGN”; and
Section 6.26, “BOT_VALIGN”.
#-- 1 --
# [ parent +:= a new table element defining the layout of
# the client table, with an empty tbody element
# tbody := that empty tbody element ]
table = E.table (
TABLE_ATTRS,
E.col ( TOP_VALIGN, L_ALIGN ),
E.col ( TOP_VALIGN, R_ALIGN ),
E.col ( TOP_VALIGN, R_ALIGN ),
E.col ( TOP_VALIGN, L_ALIGN ),
E.col ( TOP_VALIGN, R_ALIGN ),
E.col ( TOP_VALIGN, L_ALIGN ),
E.col ( TOP_VALIGN, L_ALIGN ),
E.thead (
E.tr (
E.th ( BOT_VALIGN, 'Name' ),
E.th ( BOT_VALIGN, '# CPUs' ),
E.th ( BOT_VALIGN,
E.div ( 'Speed' ),
E.div ( '(MHz)' ) ),
E.th ( BOT_VALIGN, 'Architecture' ),
E.th ( BOT_VALIGN,
E.div ( 'Memory' ),
E.div ( '(MB)' ) ),
E.th ( BOT_VALIGN,
E.div ( 'Operating' ),
E.div ( 'system' ) ),
E.th ( BOT_VALIGN,
E.div ( 'Peripheral' ),
E.div ( 'devices' ) ) ) ) )
tbody = et.SubElement ( table, 'tbody' )
parent.append ( table )
To find all the clients in this room, we generate the ClientConfig instances in clientSet, and look for those whose hostName
attribute starts with room.roomPrefix. For
the formatting of one row, see Section 19, “buildRoomRow(): Build one row of the
room table”.
#-- 2 --
# [ tbody +:= rows describing the configurations of clients
# in clientSet whose names start with room.roomPrefix ]
for clientConfig in clientSet.genClients():
fullPrefix = room.roomPrefix + "-"
if clientConfig.hostName.startswith ( fullPrefix ):
#-- 2 body --
# [ tbody +:= a tr element describing the
# configuration of clientConfig with devices
# from reportInfo ]
buildRoomRow ( tbody, reportInfo, clientConfig )