MCPcopy Index your code
hub / github.com/ahupp/python-magic / from_buffer

Function from_buffer

magic/__init__.py:182–192  ·  view source on GitHub ↗

Accepts a binary string and returns the detected filetype. Return value is the mimetype if mime=True, otherwise a human readable name. >>> magic.from_buffer(open("testdata/test.pdf").read(1024)) 'PDF document, version 1.2'

(buffer, mime=False)

Source from the content-addressed store, hash-verified

180
181
182def from_buffer(buffer, mime=False):
183 """
184 Accepts a binary string and returns the detected filetype. Return
185 value is the mimetype if mime=True, otherwise a human readable
186 name.
187
188 >>> magic.from_buffer(open("testdata/test.pdf").read(1024))
189 'PDF document, version 1.2'
190 """
191 m = _get_magic_type(mime)
192 return m.from_buffer(buffer)
193
194
195def from_descriptor(fd, mime=False):

Callers

nothing calls this directly

Calls 2

_get_magic_typeFunction · 0.85
from_bufferMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…