Show More
@@ -968,13 +968,15 b' class chunkbuffer(object):' | |||||
968 | self.iter = splitbig(in_iter) |
|
968 | self.iter = splitbig(in_iter) | |
969 | self._queue = deque() |
|
969 | self._queue = deque() | |
970 |
|
970 | |||
971 | def read(self, l): |
|
971 | def read(self, l=None): | |
972 | """Read L bytes of data from the iterator of chunks of data. |
|
972 | """Read L bytes of data from the iterator of chunks of data. | |
973 |
Returns less than L bytes if the iterator runs dry. |
|
973 | Returns less than L bytes if the iterator runs dry. | |
|
974 | ||||
|
975 | If size parameter is ommited, read everything""" | |||
974 | left = l |
|
976 | left = l | |
975 | buf = [] |
|
977 | buf = [] | |
976 | queue = self._queue |
|
978 | queue = self._queue | |
977 | while left > 0: |
|
979 | while left is None or left > 0: | |
978 | # refill the queue |
|
980 | # refill the queue | |
979 | if not queue: |
|
981 | if not queue: | |
980 | target = 2**18 |
|
982 | target = 2**18 | |
@@ -987,8 +989,9 b' class chunkbuffer(object):' | |||||
987 | break |
|
989 | break | |
988 |
|
990 | |||
989 | chunk = queue.popleft() |
|
991 | chunk = queue.popleft() | |
990 |
left |
|
992 | if left is not None: | |
991 |
|
|
993 | left -= len(chunk) | |
|
994 | if left is not None and left < 0: | |||
992 | queue.appendleft(chunk[left:]) |
|
995 | queue.appendleft(chunk[left:]) | |
993 | buf.append(chunk[:left]) |
|
996 | buf.append(chunk[:left]) | |
994 | else: |
|
997 | else: |
General Comments 0
You need to be logged in to leave comments.
Login now