This function counts the number of workstations and
instructor stations and builds the tr
element displaying those numbers, with the room name as a
link to the room page.
# - - - b u i l d C l a s s r o o m R o w
def buildClassroomRow ( parent, room, clientSet ):
'''Build one row of the classroom table.
[ (parent is an et.Element) and
(room is a Room) and
(clientSet is a ClientSet) ->
parent +:= a tr with the room name as a link to the
room page for (room), and count of workstations
and instructor stations in room from clientSet ]
'''
The first order of business is to generate all the clients
from clientSet and count the number of
workstations and instructor stations whose names start
with room.roomPrefix.
#-- 1 --
# [ seatCount := number of clients in clientSet whose names
# start with room.roomPrefix but don't end with INST_SUFFIX
# instCount := number of clients in clientSet whose names
# start with room.roomPrefix but do end with INST_SUFFIX ]
seatCount = instCount = 0
for clientConfig in clientSet.genClients():
fullPrefix = room.roomPrefix+"-"
if clientConfig.hostName.startswith ( fullPrefix ):
if clientConfig.hostName.endswith ( INST_SUFFIX ):
instCount += 1
else:
seatCount += 1
We have everything we need now to build the actual table row.
#-- 2 --
# [ parent +:= a new tr element containing a link to
# pageURL with room.roomFull as the link text,
# seatCount, and instCount ]
parent.append (
E.tr (
E.td ( L_ALIGN, linkToRoomPage ( room ) ),
E.td ( R_ALIGN, seatCount ),
E.td ( R_ALIGN, instCount ) ) )