MCPcopy Index your code
hub / github.com/python/cpython / is_tarfile

Function is_tarfile

Lib/tarfile.py:3041–3057  ·  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

3039#--------------------
3040
3041def is_tarfile(name):
3042 """Return True if name points to a tar archive that we
3043 are able to handle, else return False.
3044
3045 'name' should be a string, file, or file-like object.
3046 """
3047 try:
3048 if hasattr(name, "read"):
3049 pos = name.tell()
3050 t = open(fileobj=name)
3051 name.seek(pos)
3052 else:
3053 t = open(name)
3054 t.close()
3055 return True
3056 except TarError:
3057 return False
3058
3059open = TarFile.open
3060

Callers 1

mainFunction · 0.85

Calls 4

openFunction · 0.70
tellMethod · 0.45
seekMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…