Project

General

Profile

« Previous | Next » 

Revision 1964

streams.py: StreamIter: Define readline() as a separate method so it can be overridden, and all calls to self.next() will use the overridden readline(). This fixes a bug in ProgressInputStream where incremental counts would not be displayed and it would end with "not all input read" if the StreamIter interface was used instead of readline().

View differences:

lib/streams.py
29 29
    def __iter__(self): return self
30 30
    
31 31
    def curr(self):
32
        if self.line == None: self.line = self.stream.readline()
32
        if self.line == None: self.line = self.readline()
33 33
        if self.line == '': raise StopIteration
34 34
        return self.line
35 35
    
......
37 37
        line = self.curr()
38 38
        self.line = None
39 39
        return line
40
    
41
    # Define as a separate method so it can be overridden
42
    def readline(self): return self.stream.readline()
40 43

  
41 44
def copy(from_, to):
42 45
    for line in StreamIter(from_): to.write(line)
......
65 68
        StreamIter.__init__(self, stream)
66 69
        self.filter = filter_
67 70
    
68
    def readline(self): return self.filter(self.stream.readline())
71
    def readline(self): return self.filter(StreamIter.readline(self))
69 72
    
70 73
    def read(self, n): return self.readline() # forward all reads to readline()
71 74
    

Also available in: Unified diff