Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Return field type information from reader iterator

  • Loading branch information...
commit 1311a07e87ad63890c79595da9ef40c85e732385 1 parent 434c287
@schmichael authored
Showing with 11 additions and 11 deletions.
  1. +9 −9 mmstats/mmash.py
  2. +2 −2 mmstats/reader.py
View
18 mmstats/mmash.py
@@ -23,8 +23,8 @@ def iter_stats():
"""Yields a label at a time from every mmstats file in MMSTATS_DIR"""
for fn in glob.glob(GLOB):
try:
- for label, value in mmstats_reader.MmStatsReader.from_mmap(fn):
- yield fn, label, value
+ for field in mmstats_reader.MmStatsReader.from_mmap(fn):
+ yield fn, field
except Exception:
continue
@@ -32,8 +32,8 @@ def iter_stats():
def find_labels():
"""Returns a set of all available labels"""
labels = set()
- for fn, label, value in iter_stats():
- labels.add(label)
+ for fn, field in iter_stats():
+ labels.add(field.label)
return labels
@@ -55,11 +55,11 @@ def stats():
def getstat(statname):
stats = defaultdict(list)
exact = flask.request.args.get('exact')
- for _, label, value in iter_stats():
- if exact and label == statname:
- stats[label].append(value)
- elif label.startswith(statname):
- stats[label].append(value)
+ for _, field in iter_stats():
+ if exact and field.label == statname:
+ stats[field.label].append(field.value)
+ elif field.label.startswith(statname):
+ stats[field.label].append(field.value)
aggr = aggregators.get(flask.request.args.get('aggr'))
if aggr:
View
4 mmstats/reader.py
@@ -24,7 +24,7 @@ def wrapper(v):
read_ubyte = reader('B')
-Stat = namedtuple('Stat', ('label', 'value'))
+Stat = namedtuple('Stat', ('label', 'type', 'value'))
class InvalidMmStatsVersion(Exception):
@@ -81,7 +81,7 @@ def __iter__(self):
if isinstance(value, str):
# Special case strings as they're \x00 padded
value = value.split('\x00', 1)[0].decode('utf8', 'ignore')
- yield Stat(label, value)
+ yield Stat(label, type_, value)
try:
d.close()
Please sign in to comment.
Something went wrong with that request. Please try again.