]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
teuthology-tree: support multiple lines with the same prefix
authorJosh Durgin <jdurgin@redhat.com>
Fri, 20 Nov 2015 20:57:57 +0000 (12:57 -0800)
committerJosh Durgin <jdurgin@redhat.com>
Wed, 9 Dec 2015 21:04:53 +0000 (13:04 -0800)
Signed-off-by: Josh Durgin <jdurgin@redhat.com>
teuthology/tree.py

index dddd82bcd85a2c78115fd2756f4319d5b311d80a..e4655829c8780ce1b3017555c9a41fe9a4872c46 100644 (file)
@@ -16,7 +16,7 @@ def main(args):
     print(table)
 
 def extract_info(file_name, filters):
-    result = {}
+    result = {f: '' for f in filters}
     if os.path.isdir(file_name):
         return result
     with file(file_name, 'r') as f:
@@ -24,7 +24,9 @@ def extract_info(file_name, filters):
             for filt in filters:
                 prefix = '# ' + filt + ':'
                 if line.startswith(prefix):
-                    result[filt] = line[len(prefix):].rstrip('\n')
+                    if result[filt]:
+                        result[filt] += '\n'
+                    result[filt] += line[len(prefix):].rstrip('\n')
     return result
 
 def tree_with_info(cur_dir, filters, prefix, rows):
@@ -39,7 +41,7 @@ def tree_with_info(cur_dir, filters, prefix, rows):
             dir_pad = '│   '
         info = extract_info(path, filters)
         tree_node = prefix + file_pad + f
-        meta = [info.get(f, '') for f in filters]
+        meta = [info[f] for f in filters]
         rows.append([tree_node] + meta)
         if os.path.isdir(path):
             tree_with_info(path, filters, prefix + dir_pad, rows)