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

Function is_tarfile

Lib/tarfile.py:3016–3032  ·  view source on GitHub ↗

Return True if name points to a tar archive that we are able to handle, else return False. 'name' should be a string, file, or file-like object.

(name)

Source from the content-addressed store, hash-verified

3014#--------------------
3015
3016def is_tarfile(name):
3017 """Return True if name points to a tar archive that we
3018 are able to handle, else return False.
3019
3020 'name' should be a string, file, or file-like object.
3021 """
3022 try:
3023 if hasattr(name, "read"):
3024 pos = name.tell()
3025 t = open(fileobj=name)
3026 name.seek(pos)
3027 else:
3028 t = open(name)
3029 t.close()
3030 return True
3031 except TarError:
3032 return False
3033
3034open = TarFile.open
3035

Callers 1

mainFunction · 0.85

Calls 5

hasattrFunction · 0.85
openFunction · 0.70
tellMethod · 0.45
seekMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected