pop = pop + 1
maxpop = len(self.roomlists[d]) * 2
self.log("Registered Population: {0} of {1} ({2}%)".format(pop , maxpop, pop * 100 / maxpop ) )
- self.log("Breakdown by floor:")
+
# The following code assumes four floors and a numbering scheme where the
# hundreds digit of the room number is the floor. If this changes, this
# code will need to be rewritten.
- floors = [ [], [], [], [] ] # Note: sorted from bottom floor to top
- for r in self.roomlists[d]:
- if r < 200:
- floors[0].append(r)
- if r >= 200 and r < 300:
- floors[1].append(r)
- if r >= 300 and r < 400:
- floors[2].append(r)
- if r >= 400 and r < 500:
- floors[3].append(r)
+ self.log("Breakdown by floor:")
+ floors = [] # Note: sorted from bottom floor to top
+ floors.append( filter(lambda x: x >= 100 and x < 200, self.roomlists[d]) )
+ floors.append( filter(lambda x: x >= 200 and x < 300, self.roomlists[d]) )
+ floors.append( filter(lambda x: x >= 300 and x < 400, self.roomlists[d]) )
+ floors.append( filter(lambda x: x >= 400 and x < 500, self.roomlists[d]) )
floorpop = []
for floor in floors: # calculate the registered population
thisfloorpop = 0
self.log("Second floor: {0} of {1} registered ({2}%)".format( floorpop[1], len(floors[1]) * 2, floorpop[1] * 50 / len(floors[1])))
self.log("Third floor: {0} of {1} registered ({2}%)".format( floorpop[2], len(floors[2]) * 2, floorpop[2] * 50 / len(floors[2])))
self.log("Fourth floor: {0} of {1} registered ({2}%)".format( floorpop[3], len(floors[3]) * 2, floorpop[3] * 50 / len(floors[3])))
+
+ # Breakdown by room only in verbose log
self.vlog("Breakdown by room:")
for room in self.roomlists[d]:
q.prepare("SELECT id, surname, forename FROM people WHERE dorm=:dorm AND room=:room")