diff options
Diffstat (limited to 'tools/functions.py')
-rw-r--r-- | tools/functions.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/tools/functions.py b/tools/functions.py index c0d1e5f7..d35f1f84 100644 --- a/tools/functions.py +++ b/tools/functions.py @@ -190,17 +190,15 @@ def filter_output(output, regex): """ result = [] if isinstance(output, str): - for line in output.split('\n'): + for line in output.splitlines(): result += re.findall(regex, line) - return result - elif isinstance(output, list) or isinstance(output, tuple): - tmp_res = [] + elif isinstance(output, (list, tuple)): for item in output: - tmp_res.append(filter_output(item, regex)) - return tmp_res + result.append(filter_output(item, regex)) else: raise RuntimeError('Only strings and lists are supported by filter_output(), ' 'but output has type {}'.format(type(output))) + return result def format_description(desc, length): """ Split description into multiple lines based on given line length. |