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)
| 193 | |
| 194 | |
| 195 | def 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 | |
| 208 | from . import loader |
| 209 | libmagic = loader.load_lib() |
nothing calls this directly
no test coverage detected
searching dependent graphs…