summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsummain14
1 files changed, 13 insertions, 1 deletions
diff --git a/summain b/summain
index cf35a41..579c6d9 100755
--- a/summain
+++ b/summain
@@ -70,10 +70,22 @@ class CSV(OutputFormat):
self.writer.writerow(values)
+class GeneratorList(list):
+
+ def __init__(self, gen):
+ self.gen = gen
+
+ def __len__(self):
+ return 1
+
+ def __iter__(self):
+ return iter(self.gen)
+
+
class Json(OutputFormat):
def write(self):
- json.dump(list(self.dictify(name, o) for name, o in self.objects),
+ json.dump(GeneratorList(self.dictify(name, o) for name, o in self.objects),
self.output, sort_keys=True, indent=1)
self.output.write('\n')