MCPcopy Index your code
hub / github.com/RustPython/RustPython / read

Method read

Lib/tarfile.py:684–713  ·  view source on GitHub ↗

Read data from the file.

(self, size=None)

Source from the content-addressed store, hash-verified

682 return self.position
683
684 def read(self, size=None):
685 """Read data from the file.
686 """
687 if size is None:
688 size = self.size - self.position
689 else:
690 size = min(size, self.size - self.position)
691
692 buf = b""
693 while size > 0:
694 while True:
695 data, start, stop, offset = self.map[self.map_index]
696 if start <= self.position < stop:
697 break
698 else:
699 self.map_index += 1
700 if self.map_index == len(self.map):
701 self.map_index = 0
702 length = min(size, stop - self.position)
703 if data:
704 self.fileobj.seek(offset + (self.position - start))
705 b = self.fileobj.read(length)
706 if len(b) != length:
707 raise ReadError("unexpected end of data")
708 buf += b
709 else:
710 buf += NUL * length
711 size -= length
712 self.position += length
713 return buf
714
715 def readinto(self, b):
716 buf = self.read(len(b))

Callers 1

readintoMethod · 0.95

Calls 5

minFunction · 0.85
lenFunction · 0.85
ReadErrorClass · 0.70
seekMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected