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)
| 180 | |
| 181 | |
| 182 | def 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 | |
| 195 | def from_descriptor(fd, mime=False): |
nothing calls this directly
no test coverage detected
searching dependent graphs…