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

Method next

Lib/tarfile.py:2817–2879  ·  view source on GitHub ↗

Return the next member of the archive as a TarInfo object, when TarFile is opened for reading. Return None if there is no more available.

(self)

Source from the content-addressed store, hash-verified

2815
2816 #--------------------------------------------------------------------------
2817 def next(self):
2818 """Return the next member of the archive as a TarInfo object, when
2819 TarFile is opened for reading. Return None if there is no more
2820 available.
2821 """
2822 self._check("ra")
2823 if self.firstmember is not None:
2824 m = self.firstmember
2825 self.firstmember = None
2826 return m
2827
2828 # Advance the file pointer.
2829 if self.offset != self.fileobj.tell():
2830 if self.offset == 0:
2831 return None
2832 self.fileobj.seek(self.offset - 1)
2833 if not self.fileobj.read(1):
2834 raise ReadError("unexpected end of data")
2835
2836 # Read the next block.
2837 tarinfo = None
2838 while True:
2839 try:
2840 tarinfo = self.tarinfo.fromtarfile(self)
2841 except EOFHeaderError as e:
2842 if self.ignore_zeros:
2843 self._dbg(2, "0x%X: %s" % (self.offset, e))
2844 self.offset += BLOCKSIZE
2845 continue
2846 except InvalidHeaderError as e:
2847 if self.ignore_zeros:
2848 self._dbg(2, "0x%X: %s" % (self.offset, e))
2849 self.offset += BLOCKSIZE
2850 continue
2851 elif self.offset == 0:
2852 raise ReadError(str(e)) from None
2853 except EmptyHeaderError:
2854 if self.offset == 0:
2855 raise ReadError("empty file") from None
2856 except TruncatedHeaderError as e:
2857 if self.offset == 0:
2858 raise ReadError(str(e)) from None
2859 except SubsequentHeaderError as e:
2860 raise ReadError(str(e)) from None
2861 except Exception as e:
2862 try:
2863 import zlib
2864 if isinstance(e, zlib.error):
2865 raise ReadError(f'zlib error: {e}') from None
2866 else:
2867 raise e
2868 except ImportError:
2869 raise e
2870 break
2871
2872 if tarinfo is not None:
2873 # if streaming the file we do not want to cache the tarinfo
2874 if not self.stream:

Callers 7

__init__Method · 0.95
_loadMethod · 0.95
__iter__Method · 0.95
shell_execFunction · 0.45
parse_argsFunction · 0.45
mainFunction · 0.45
py_mainFunction · 0.45

Calls 10

_checkMethod · 0.95
_dbgMethod · 0.95
strFunction · 0.85
isinstanceFunction · 0.85
fromtarfileMethod · 0.80
ReadErrorClass · 0.70
tellMethod · 0.45
seekMethod · 0.45
readMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected