example.py 226 B

12345678910111213141516
  1. import magic
  2. ms = magic.open(magic.MAGIC_NONE)
  3. ms.load()
  4. type = ms.file("/path/to/some/file")
  5. print type
  6. f = file("/path/to/some/file", "r")
  7. buffer = f.read(4096)
  8. f.close()
  9. type = ms.buffer(buffer)
  10. print type
  11. ms.close()