def read(self, size=None):
if size is None:<EOL><INDENT>size = self.size - self.position<EOL><DEDENT>else:<EOL><INDENT>size = min(size, self.size - self.position)<EOL><DEDENT>buf = b"<STR_LIT>"<EOL>while size > <NUM_LIT:0>:<EOL><INDENT>while True:<EOL><INDENT>data, start, stop, offset = self.map[self.map_index]<EOL>if start <= self.position < stop:<EOL><INDENT>break<EOL><DEDENT>else:<EOL><INDENT>self.map_index += <NUM_LIT:1><EOL>if self.map_index == len(self.map):<EOL><INDENT>self.map_index = <NUM_LIT:0><EOL><DEDENT><DEDENT><DEDENT>length = min(size, stop - self.position)<EOL>if data:<EOL><INDENT>self.fileobj.seek(offset + (self.position - start))<EOL>buf += self.fileobj.read(length)<EOL><DEDENT>else:<EOL><INDENT>buf += NUL * length<EOL><DEDENT>size -= length<EOL>self.position += length<EOL><DEDENT>return buf<EOL>
Read data from the file.