Make compatible again with py2
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 1 Dec 2017 15:26:34 +0000 (16:26 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 1 Dec 2017 15:29:56 +0000 (16:29 +0100)
src/log_read.py
src/type_helpers.py

index 43bda89..e9d47a0 100644 (file)
@@ -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:
index 2972536..ae4e0ce 100644 (file)
@@ -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():