Skip to content

Commit

Permalink
Merge pull request #57 from chill17/master
Browse files Browse the repository at this point in the history
Added MonthsUsage type to allow dot access when iterating over month in a report rather than just index acesss
  • Loading branch information
Wooble committed Jan 12, 2018
2 parents 0e73754 + ea27841 commit 44eaed3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pycounter/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,9 @@ def _ensure_required_metrics(self):
))


MonthsUsage = collections.namedtuple('MonthsUsage', 'month metric usage')


class CounterEresource(six.Iterator):
"""
Base class for COUNTER statistics lines.
Expand Down Expand Up @@ -284,7 +287,7 @@ def __init__(self, period=None, metric=None, month_data=None,
def __iter__(self):
if self._full_data:
for item in self._full_data:
yield (item[0], self.metric, item[1])
yield MonthsUsage(item[0], self.metric, item[1])

def _fill_months(self):
"""Ensure each month in period represented and zero fill if not."""
Expand Down

0 comments on commit 44eaed3

Please sign in to comment.