code: def average(self):
          "Calculate average"
          result = DefaultBunch(str)
  
          # Calculate average if possible
          if self.size:
              result.update(
                  (key, '' if isinstance(val, basestring) else val / self.size)
                  for key, val in self.total.items()
              )
  
          # Handle time fields
          #for key, fielddef in  engine.FieldDefinition.FIELDS.items():
          #    if key in result and fielddef._matcher is matching.TimeFilter:
          #       result[key] = ''
          #for key, fielddef in  engine.FieldDefinition.FIELDS.items():
          #    if key in result and fielddef._matcher is matching.TimeFilter:
          #        result[key] = engine._fmt_duration(result[key])
          #print self.total
          #print result
          return resulf average(self):
          "Calculate average"
          result = DefaultBunch(str)
  
          # Calculate average if possible
          if self.size:
              result.update(
                  (key, '' if isinstance(val, basestring) else val / self.size)
                  for key, val in self.total.items()
              )
  
          # Handle time fields
          #for key, fielddef in  engine.FieldDefinition.FIELDS.items():
          #    if key in result and fielddef._matcher is matching.TimeFilter:
          #       result[key] = ''
          #for key, fielddef in  engine.FieldDefinition.FIELDS.items():
          #    if key in result and fielddef._matcher is matching.TimeFilter:
          #        result[key] = engine._fmt_duration(result[key])
          #print self.total
          #print result
          return result
docs: Calculate average