.. 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.
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: