diff options
Diffstat (limited to 'parse')
-rw-r--r-- | parse/point.py | 6 | ||||
-rw-r--r-- | parse/tuple_table.py | 19 |
2 files changed, 17 insertions, 8 deletions
diff --git a/parse/point.py b/parse/point.py index ce9cfb0..d577306 100644 --- a/parse/point.py +++ b/parse/point.py | |||
@@ -8,9 +8,9 @@ from enum import Enum | |||
8 | from collections import defaultdict | 8 | from collections import defaultdict |
9 | 9 | ||
10 | Type = Enum(['Min','Max','Avg','Var']) | 10 | Type = Enum(['Min','Max','Avg','Var']) |
11 | default_typemap = {Type.Max : {Type.Max : 1, Type.Min : 0, Type.Avg : 1, Type.Var : 1}, | 11 | default_typemap = {Type.Max : {Type.Max : 1, Type.Min : 1, Type.Avg : 1, Type.Var : 1}, |
12 | Type.Min : {Type.Max : 1, Type.Min : 0, Type.Avg : 1, Type.Var : 1}, | 12 | Type.Min : {Type.Max : 1, Type.Min : 1, Type.Avg : 1, Type.Var : 1}, |
13 | Type.Avg : {Type.Max : 1, Type.Min : 0, Type.Avg : 1, Type.Var : 1}} | 13 | Type.Avg : {Type.Max : 1, Type.Min : 1, Type.Avg : 1, Type.Var : 1}} |
14 | 14 | ||
15 | def make_typemap(): | 15 | def make_typemap(): |
16 | return copy.deepcopy(default_typemap) | 16 | return copy.deepcopy(default_typemap) |
diff --git a/parse/tuple_table.py b/parse/tuple_table.py index 105b786..86baa08 100644 --- a/parse/tuple_table.py +++ b/parse/tuple_table.py | |||
@@ -27,6 +27,9 @@ class TupleTable(object): | |||
27 | key = self.col_map.get_key(kv) | 27 | key = self.col_map.get_key(kv) |
28 | return key in self.table | 28 | return key in self.table |
29 | 29 | ||
30 | def __iter__(self): | ||
31 | return self.table.iteritems() | ||
32 | |||
30 | def reduce(self): | 33 | def reduce(self): |
31 | reduced = ReducedTupleTable(self.col_map) | 34 | reduced = ReducedTupleTable(self.col_map) |
32 | for key, value in self.table.iteritems(): | 35 | for key, value in self.table.iteritems(): |
@@ -92,21 +95,27 @@ class ReducedTupleTable(TupleTable): | |||
92 | def from_dir_map(dir_map): | 95 | def from_dir_map(dir_map): |
93 | Leaf = namedtuple('Leaf', ['stat', 'variable', 'base', | 96 | Leaf = namedtuple('Leaf', ['stat', 'variable', 'base', |
94 | 'summary', 'config', 'values']) | 97 | 'summary', 'config', 'values']) |
98 | |||
99 | def next_type(path): | ||
100 | return path.pop() if path[-1] in Type else Type.Avg | ||
101 | |||
95 | def leafs(): | 102 | def leafs(): |
96 | for path, node in dir_map.leafs(): | 103 | for path, node in dir_map.leafs(): |
97 | # The path will be of at least size 1: the filename | 104 | # The path will be of at least size 1: the filename |
98 | leaf = path.pop() | 105 | leaf = path.pop() |
99 | 106 | ||
100 | # Set acceptable defaults for the rest of the path | 107 | base = path.pop() if (path and path[-1] in Type) else Type.Avg |
101 | path += ['?', '?', 'Avg', 'Avg'][len(path):] | 108 | summ = path.pop() if (path and path[-1] in Type) else Type.Avg |
109 | |||
110 | path += ['?', '?'][len(path):] | ||
102 | 111 | ||
103 | [stat, variable, base_type, summary_type] = path | 112 | [stat, variable] = path |
104 | 113 | ||
105 | config_str = leaf[:leaf.index('.csv')] | 114 | config_str = leaf[:leaf.index('.csv')] |
106 | config = ColMap.decode(config_str) | 115 | config = ColMap.decode(config_str) |
107 | 116 | ||
108 | leaf = Leaf(stat, variable, base_type, | 117 | leaf = Leaf(stat, variable, base, summ, |
109 | summary_type, config, node.values) | 118 | config, node.values) |
110 | yield leaf | 119 | yield leaf |
111 | 120 | ||
112 | builder = ColMapBuilder() | 121 | builder = ColMapBuilder() |