def summonMagic():
import magic
if hasattr(magic, 'from_file'):
# https://pypi.python.org/pypi/python-magic
return magic
elif hasattr(magic, 'open'):
# http://www.darwinsys.com/file/, in Debian as python3-magic
class WrapMagic:
def __init__(self):
self.magic = magic.open(magic.NONE)
self.magic.load()
def from_file(self, name):
return self.magic.file(name)
return WrapMagic()
else:
raise NotImplementedError("I do not understand your magic")
### directory copy ###
评论列表
文章目录