From 801d57af4c87e0cb994c8001c5aaa393015f65fa Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 7 Oct 2015 01:03:26 +0000 Subject: [PATCH] fixed buggy behavior caused by assigning string instead of single-item list to readBuffer. --- lib/damask/asciitable.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/damask/asciitable.py b/lib/damask/asciitable.py index f2164a5f3..08cb6b3a7 100644 --- a/lib/damask/asciitable.py +++ b/lib/damask/asciitable.py @@ -167,7 +167,7 @@ class ASCIItable(): try: self.__IO__['in'].seek(0) # try to rewind except: - self.__IO__['readBuffer'] = firstline # or at least save data in buffer + self.__IO__['readBuffer'] = [firstline] # or at least save data in buffer try: self.__IO__['dataStart'] = self.__IO__['in'].tell() # current file position is at start of data except IOError: @@ -405,13 +405,8 @@ class ASCIItable(): ''' read next line (possibly buffered) and parse it into data array ''' - if not isinstance(self.__IO__['readBuffer'], (str, unicode)): - if len(self.__IO__['readBuffer']) > 0: - self.line = self.__IO__['readBuffer'].pop(0) # take buffered content - else: - self.line = self.__IO__['in'].readline() # get next data row from file - else: - self.line=self.__IO__['readBuffer'] + self.line = self.__IO__['readBuffer'].pop(0) if len(self.__IO__['readBuffer']) > 0 \ + else self.__IO__['in'].readline() # take buffered content or get next data row from file if not advance: self.__IO__['readBuffer'].append(self.line) # keep line just read in buffer