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

Function what

tools/python-3.11.9-amd64/Lib/imghdr.py:16–33  ·  view source on GitHub ↗
(file, h=None)

Source from the content-addressed store, hash-verified

14#-------------------------#
15
16def what(file, h=None):
17 f = None
18 try:
19 if h is None:
20 if isinstance(file, (str, PathLike)):
21 f = open(file, 'rb')
22 h = f.read(32)
23 else:
24 location = file.tell()
25 h = file.read(32)
26 file.seek(location)
27 for tf in tests:
28 res = tf(h, f)
29 if res:
30 return res
31 finally:
32 if f: f.close()
33 return None
34
35
36#---------------------------------#

Callers 1

testallFunction · 0.70

Calls 5

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

Tested by

no test coverage detected