diff options
| author | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-10-29 09:59:35 -0400 |
|---|---|---|
| committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2012-10-29 09:59:35 -0400 |
| commit | 5b50c58ea4881dd185897dfa93860c60f551d815 (patch) | |
| tree | 1eee3271b5ab9fad7774a073110287b27e4d32fd /parse/point.py | |
| parent | f1e90e1a5f7b148cf8113fe463615bd95d5bf26d (diff) | |
Prettied up parse output.
Diffstat (limited to 'parse/point.py')
| -rw-r--r-- | parse/point.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/parse/point.py b/parse/point.py index 30fcd97..8fdd115 100644 --- a/parse/point.py +++ b/parse/point.py | |||
| @@ -16,7 +16,14 @@ def make_typemap(): | |||
| 16 | return copy.deepcopy(default_typemap) | 16 | return copy.deepcopy(default_typemap) |
| 17 | 17 | ||
| 18 | def dict_str(adict, sep = "\n"): | 18 | def dict_str(adict, sep = "\n"): |
| 19 | return sep.join(["%s: %s" % (k, str(v)) for (k,v) in sorted(adict.iteritems())]) | 19 | def num_str(v): |
| 20 | try: | ||
| 21 | float(v) | ||
| 22 | return "%6.3f" % v | ||
| 23 | except: | ||
| 24 | return v | ||
| 25 | size = 20 if sep == "\n" else 4 | ||
| 26 | return sep.join([("%" + str(size) + "s: %9s") % (k, num_str(v)) for (k,v) in sorted(adict.iteritems())]) | ||
| 20 | 27 | ||
| 21 | class Measurement(object): | 28 | class Measurement(object): |
| 22 | def __init__(self, id = None, kv = {}): | 29 | def __init__(self, id = None, kv = {}): |
| @@ -52,7 +59,7 @@ class Measurement(object): | |||
| 52 | self.stats[type] = value | 59 | self.stats[type] = value |
| 53 | 60 | ||
| 54 | def __str__(self): | 61 | def __str__(self): |
| 55 | return "<Measurement-%s> %s" % (self.id, dict_str(self.stats, " ")) | 62 | return "%s" % dict_str(self.stats, " ") |
| 56 | 63 | ||
| 57 | 64 | ||
| 58 | class Summary(Measurement): | 65 | class Summary(Measurement): |
