Package: python-magic
Version: 5.04-5+squeeze2
Severity: wishlist
Tags: upstream
I found the hard way that the API exported by the Python module ‘magic’ differs
among different versions of the module.
Impact:
A Python script, developed in a Debian Linux installation using the
provided python-magic package, won't work as is when transferred to a
different POSIX system, which uses the python-magic package installed
using the 'pip install python-magic' method.
The Debian package and its documentation should be modified to provide
also an API compatible with the other package.
The version installed when installing the Debian package ‘python-magic’ expects
the following API:
import magic
mymagic = magic.open(magic.MAGIC_MIME_TYPE)
mymagic.load()
mtype = mymagic.file(inpfname)
print(”The MIME type of the file %s is %s” % (inpfname,mtype))
The version installed using ‘pip install python-magic’ expects the following
API:
import magic
mymagic = magic.Magic(mime=True)
mtype = mymagic.from_file(inpfname)
print(”The MIME type of the file %s is %s” % (inpfname,mtype))
The following code allows the rest of the script to work the same way with
either version of ‘magic’:
import magic
def build_magic():
try:
mymagic = magic.open(magic.MAGIC_MIME_TYPE)
mymagic.load()
except AttributeError,e:
mymagic = magic.Magic(mime=True)
mymagic.file = mymagic.from_file
return(mymagic)
mymagic = build_magic()
mtype = mymagic.file(inpfname)
print(”The MIME type of the file %s is %s” % (inpfname,mtype))
-- System Information:
Debian Release: 6.0.7
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5-vserver-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages python-magic depends on:
ii libc6 2.11.3-4 Embedded GNU C Library: Shared lib
ii libmagic1 5.04-5+squeeze2 File type determination library us
ii python 2.6.6-3+squeeze7 interactive high-level object-orie
ii python-support 1.0.10 automated rebuilding support for P
python-magic recommends no packages.
Versions of packages python-magic suggests:
pn python-magic-dbg <none> (no description available)
-- no debconf information
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]