From: Christian Herdtweck Date: Fri, 1 Dec 2017 15:26:34 +0000 (+0100) Subject: Make compatible again with py2 X-Git-Tag: v1.2~10^2~2 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=879f0150e50235d0b6a38c7dec984703776525cc;p=pyi2ncommon Make compatible again with py2 --- diff --git a/src/log_read.py b/src/log_read.py index 43bda89..e9d47a0 100644 --- a/src/log_read.py +++ b/src/log_read.py @@ -94,7 +94,7 @@ _STR_ERR = 'not accepting file name "{0}" since cannot guarantee closing ' \ 'files --> use with open(file_name)!' -class IterativeReader: +class IterativeReader(object): """ reads from a given file Uses os.stat(file_obj.fileno()).st_size as measure whether file has changed @@ -298,7 +298,7 @@ class LineReader(IterativeReader): self.line_buffers[idx] = '' result = [] should_be_no_new_lines = False - for line in all_data.splitlines(keepends=True): + for line in all_data.splitlines(True): if line[-1] in LINE_SPLITTERS: result.append((description, line.rstrip(LINE_SPLITTERS))) elif should_be_no_new_lines: diff --git a/src/type_helpers.py b/src/type_helpers.py index 2972536..ae4e0ce 100644 --- a/src/type_helpers.py +++ b/src/type_helpers.py @@ -81,7 +81,7 @@ def is_file_obj(var): just checks whether given var is subclass of io.IOBase, which is also True for 'file-like objects' like StringIO """ - return isinstance(var, IOBase) + return isinstance(var, IOBase) or (PY2 and isinstance(var, file)) def main():