0

I need to use a python library for identifying the file type, and after reading the posts on this subject, python-magic seems to be what I am looking for. However, I can't find in the documentation how can I add new types of files when using this library?

There is a default set of file types - such as pdf, text, etc, but I need to be able to identify much more types than that. Thanks!

Clara
  • 2,935
  • 6
  • 34
  • 49

1 Answers1

0

Since python-magic is a wrapper for libmagic you would need to extend libmagic if your file types are not already identified.

Steve Barnes
  • 27,618
  • 6
  • 63
  • 73
  • OK, could you please give me a code snippet example of how to do that? (I can't seem to find any documentation on libmagic itself...) – Clara Oct 31 '13 at 12:04
  • 2
    @Clara: libmagic is free software only in alpha. Its current `README` file says "It uses the same ''magic'' databases as Ian Darwin's file(1) command as of version 3.31." The `typedef` for `struct magicentry_t` in `magic.h` looks relatively straight-forward. – martineau Oct 31 '13 at 15:02