Next / Previous / Contents / TCC Help System / NM Tech homepage

12. buildOpenLabsList(): Bullet list of open labs

This function builds the bullet list of open labs on the start page. It also builds the room pages for each open lab, which are linked from the bullet list.

hwscan3.py
# - - -   b u i l d O p e n L a b s L i s t

def buildOpenLabsList ( parent, reportInfo, clientSet ):
    '''Build open lab pages and the bullet list that links to them.

      [ (parent is an et.Element) and
        (reportInfo is a ReportInfo) and
        (clientSet is a ClientSet ) ->
          parent  +:=  bullet list of open labs named in reportInfo,
                       with configuration data from clientSet, as
                       links to room pages for those labs
          room pages for open labs  :=  tables of clients in
              those labs from clientSet ]
    '''

If we sort the keys of reportInfo.roomMap, that will put the rooms more or less into ascending order. Note that, for instance, speare4 sorts between speare23 and speare5. If that ever bothers anyone, we could split the room number into a string room name and an integer room number and sort those. However, this is probably sufficient for now.

hwscan3.py
    #-- 1 --
    # [ prefixList  :=  keys of reportInfo.roomMap, sorted into
    #                   ascending order ]
    prefixList  =  reportInfo.roomMap.keys()
    prefixList.sort()

Next comes the subhead and the bullet list.

hwscan3.py
    #-- 2 --
    # [ parent  +:=  (hr element)+(h2 subtitle) ]
    parent.append ( E.hr() )
    parent.append (E.h2 ( 'Open labs' ) )
    parent.append (
        E.p ( 'Click on the room name for a list of the '
              'workstations in that room.' ) )
    
    #-- 3 --
    # [ parent  +:=  a new ul child element
    #   ul      :=   that element ]
    ul  =  et.SubElement ( parent, 'ul' )

For each room prefix that is identified as an open lab in reportInfo.roomMap, we'll generate a room page for that lab, and also add a bullet linking to that page. See Section 13, “buildOpenLab(): Build the page for an open lab”.

hwscan3.py
    #-- 4 --
    # [ room pages for open labs in reportInfo  :=  tables of
    #       clients in those labs
    #   ul  :=  ul with new 'li' elements added for open labs
    #           in reportInfo, linking to those corresponding
    #           room pages ]
    for prefix in prefixList:
        #-- 4 body --
        # [ if reportInfo.roomMap[prefix] is an open lab ->
        #     room page for that lab  :=  table of clients
        #         in that lab from clientSet, with devices from
        #         reportInfo
        #     ul  +:=  a new 'li' element linking to that
        #              room page ]
        room  =  reportInfo.roomMap[prefix]
        if room.roomType == Room.ROOM_OPEN:
            buildOpenLab ( ul, room, reportInfo, clientSet )