diff options
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): |