Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions magic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
'PDF document, version 1.2'
>>> magic.from_file("testdata/test.pdf", mime=True)
'application/pdf'
>>> magic.from_buffer(open("testdata/test.pdf").read(1024))
'PDF document, version 1.2'
>>> with open("testdata/test.pdf", "rb") as pdf:
... magic.from_buffer(pdf.read(2048), mime=True)
'application/pdf'
>>>

"""
Expand Down Expand Up @@ -223,8 +224,9 @@ def from_buffer(buffer, mime=False):
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'
>>> with open("testdata/test.pdf", "rb") as pdf:
... magic.from_buffer(pdf.read(2048), mime=True)
'application/pdf'
"""
m = _get_magic_type(mime)
return m.from_buffer(buffer)
Expand Down