fix a bug in text-parsing; clean up imports
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 14 Jan 2016 14:03:28 +0000 (15:03 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Thu, 14 Jan 2016 14:03:28 +0000 (15:03 +0100)
file_helpers.py

index 9fd7cb1..981cc80 100644 (file)
@@ -11,15 +11,18 @@ Featuring::
 .. codeauthor:: Christian Herdtweck, christian.herdtweck@intra2net.com
 """
 
-import contextlib
+from __future__ import print_function
+
+from contextlib import contextmanager
 import os
-from call_helpers import call_and_capture
 from warnings import warn
 from math import floor, ceil
 
+from call_helpers import call_and_capture
+from iter_helpers import pairwise
 
 
-@contextlib.contextmanager
+@contextmanager
 def cd(path):
     """A context manager which changes the working directory to the given
     path, and then changes it back to its previous value on exit.
@@ -84,6 +87,11 @@ def get_filesystem_fill_states():
     min_len = min(len(line) for line in out)
     separator_cols = [idx for idx in range(min_len) if \
                       all(line[idx] == ' ' for line in out)]
+    checked_cols = [separator_cols[0], ]
+    for prev_col, col in pairwise(separator_cols):
+        if col != prev_col+1:
+            checked_cols.append(col)
+    separator_cols = checked_cols
 
     # check columns and their header
     if len(separator_cols) != 5: