MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / is_tarfile

Function is_tarfile

tools/python-3.11.9-amd64/Lib/tarfile.py:2781–2797  ·  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

2779#--------------------
2780
2781def is_tarfile(name):
2782 """Return True if name points to a tar archive that we
2783 are able to handle, else return False.
2784
2785 'name' should be a string, file, or file-like object.
2786 """
2787 try:
2788 if hasattr(name, "read"):
2789 pos = name.tell()
2790 t = open(fileobj=name)
2791 name.seek(pos)
2792 else:
2793 t = open(name)
2794 t.close()
2795 return True
2796 except TarError:
2797 return False
2798
2799open = TarFile.open
2800

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