MCPcopy Create free account
hub / github.com/ahupp/python-magic / from_descriptor

Function from_descriptor

magic/__init__.py:195–206  ·  view source on GitHub ↗

Accepts a file descriptor and returns the detected filetype. Return value is the mimetype if mime=True, otherwise a human readable name. >>> f = open("testdata/test.pdf") >>> magic.from_descriptor(f.fileno()) 'PDF document, version 1.2'

(fd, mime=False)

Source from the content-addressed store, hash-verified

193
194
195def from_descriptor(fd, mime=False):
196 """
197 Accepts a file descriptor and returns the detected filetype. Return
198 value is the mimetype if mime=True, otherwise a human readable
199 name.
200
201 >>> f = open("testdata/test.pdf")
202 >>> magic.from_descriptor(f.fileno())
203 'PDF document, version 1.2'
204 """
205 m = _get_magic_type(mime)
206 return m.from_descriptor(fd)
207
208from . import loader
209libmagic = loader.load_lib()

Callers

nothing calls this directly

Calls 2

_get_magic_typeFunction · 0.85
from_descriptorMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…