summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--fracture/__main__.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/fracture/__main__.py b/fracture/__main__.py
index 90f2dd3..a4be0b9 100644
--- a/fracture/__main__.py
+++ b/fracture/__main__.py
@@ -125,17 +125,20 @@ def summarize(xlsx=False, year=None, quarter=None):
rows = sorted((map(lambda x: x.to_row(), invoices)),
key=lambda x: x["type"])
- keys = list(rows[0].keys())
- # FIXME all rows don't match and I'm putting them together in weird orders
- for r in rows:
- for k in r.keys():
- if k not in keys:
- keys.append(k)
- import sys
- wrtr = DictWriter(sys.stdout, keys)
- wrtr.writeheader()
- for r in rows:
- wrtr.writerow(r)
+ if len(rows) > 0:
+ keys = list(rows[0].keys())
+ # FIXME all rows don't match and I'm putting them together in weird orders
+ for r in rows:
+ for k in r.keys():
+ if k not in keys:
+ keys.append(k)
+ import sys
+ wrtr = DictWriter(sys.stdout, keys)
+ wrtr.writeheader()
+ for r in rows:
+ wrtr.writerow(r)
+ else:
+ print("No data available for this period")
@command
def render(id, template=None, type=None, list_templates=None):