diff options
Diffstat (limited to 'summain')
-rwxr-xr-x | summain | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -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') |