Commits

Chris Mutel  committed a9e5ff6

Clean up representations of query results

  • Participants
  • Parent commits 7a4fd2d

Comments (0)

Files changed (1)

File brightway2/query.py

         return u"Query result with %i entries" % len(self.result)
 
     def __repr__(self):
-        return repr(self.result)
+        if len(self.result) > 25:
+            data = dict([(key, self.result[key]) for key in \
+                self.result.keys()[:25]])
+        elif not len(self.result):
+            return "Query result\nNo query results found."
+        else:
+            data = self.result
+        return "Query result:\n" + "\n".join(["%s: %s" % (key, data[key][
+            "name"]) for key in data]) + "\n\t(total %i results)" % len(
+            self.result)
 
     def __getitem__(self, key):
         return self.result[key]