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

27.2. ReportInfo.__buildRooms(): Build the room dictionary

The input to this method is a node list containing ROOM_N nodes. The purpose is to create the .roomMap attribute, mapping room names onto Room objects representing those rooms.

hwscan3.py
# - - -   R e p o r t I n f o . _ _ b u i l d R o o m s   - - -

    def __buildRooms ( self, roomNodeSet ):
        '''Build the .roomMap dictionary from the room node set.

          [ roomNodeSet is a list of ROOM_N nodes as et.Element
            instances ->
              self.roomMap  :=  as invariant, with data taken from
                  roomNodeSet ]
        '''

First we set up the empty dictionary, then iterate over the room nodes, adding the information from each to the dictionary.

hwscan3.py
        #-- 1 --
        self.roomMap  =  {}

        #-- 2 --
        # [ self.room  +:=  entries made from elements of roomNodeSet ]
        for roomNode in roomNodeSet:
            #-- 2 body --
            # [ roomNode is a ROOM_N et.Element ->
            #     self.roomMap  :=  self.roomMap with an entry added,
            #         mapping the PREFIX_A attribute of roomNode
            #         to a new Room object representing roomNode ]
            roomType  =  roomNode.attrib [ TYPE_A ]
            roomPrefix  =  roomNode.attrib [ PREFIX_A ]
            roomFull  =  roomNode.attrib [ FULL_A ]
            room  =  Room ( roomType, roomPrefix, roomFull )
            self.roomMap [ roomPrefix ]  =  room