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

Function from_file

magic/__init__.py:169–179  ·  view source on GitHub ↗

Accepts a filename and returns the detected filetype. Return value is the mimetype if mime=True, otherwise a human readable name. >>> magic.from_file("testdata/test.pdf", mime=True) 'application/pdf'

(filename, mime=False)

Source from the content-addressed store, hash-verified

167
168
169def from_file(filename, mime=False):
170 """"
171 Accepts a filename and returns the detected filetype. Return
172 value is the mimetype if mime=True, otherwise a human readable
173 name.
174
175 >>> magic.from_file("testdata/test.pdf", mime=True)
176 'application/pdf'
177 """
178 m = _get_magic_type(mime)
179 return m.from_file(filename)
180
181
182def from_buffer(buffer, mime=False):

Callers

nothing calls this directly

Calls 2

_get_magic_typeFunction · 0.85
from_fileMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…