A python module and command to try really hard to get a mime-type for a file
Project description
About
magic-identify implements a wrapper around both the python-magic module and the identify module to try and always return results, even if one fails. Finally, failing that it will try to guess some minimal shell script environments too (specifically looking at common keywords in malware droppers/downloaders that do not always have leading identification lines).
It returns two strings, one which may be a higher level text description and a second which should always be a mime-type identifier.
Example module use:
import magicidentify
c = magicidentify.MagicIdentify()
print(c.identify("/bin/ls"))
# ('application/x-pie-executable', 'application/x-pie-executable')
Example CLI use:
# magic-identify /bin/ls /sbin/ifup
/bin/ls: application/x-pie-executable, application/x-pie-executable
using magic: application/x-pie-executable, application/x-pie-executable
using identify: unknown, unknown
/sbin/ifup: inode/symlink, inode/symlink
using magic: inode/symlink, inode/symlink
using identify: bash/shell, text/x-bash
# magic-identify -q /bin/ls /sbin/ifup
application/x-pie-executable
inode/symlink
Todo
- Handle more boring cases from some outputs (text/inode)
- test suite
Acknowledgements
The following wonderful github accounts have contributed to the code base:
- @JakeRoggenbuck
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for magic_identify-0.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6bad7c36bbf667825ebf519db754e8e311c53fd21b5604a9194b03908e498b9 |
|
MD5 | 48dba436f03927b6b9d973b1c4175724 |
|
BLAKE2b-256 | f6e6d9423ad4e101dfe40f964ab1de34ba7e4d4fa90c1569dab2443acea94c2c |