Skip to main content

Python bindings to libmagic

Project description

# python-libmagic

![magic.h](http://i.imgur.com/GbN8szC.jpg)

# Usage

```python
import magic
import magic.flags

magic = magic.Magic(mimetype=True)

mimetype = magic.from_buffer("\x89\x50\x4E\x47\x0D\x0A\x1A\x0A")
print mimetype # => "image/png"

mimetype = magic.from_filepath("/etc/passwd")
print mimetype # => "text/plain"

updated = magic.set_flags(magic.flags.MAGIC_NONE)
print updated # => True
mimetype = magic.from_filepath("demo.docx")
print mimetype # => "Microsoft Word 2007+"
```

# Installation

```bash
$ apt-get install libmagic-dev
$ pip install python-libmagic
```

# License

Licensed under MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for python-libmagic, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size python-libmagic-0.3.0.tar.gz (3.2 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page