diff options
Diffstat (limited to 'parse/tuple_table.py')
-rw-r--r-- | parse/tuple_table.py | 19 |
1 files changed, 14 insertions, 5 deletions
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() |