From 544fe9bf1782a027b3f31bf4c10a050d783e32ac Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 1 Feb 2012 22:56:04 +0100 Subject: Rename mat-cli to mat-gui --- lib/strippers.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 lib/strippers.py (limited to 'lib/strippers.py') diff --git a/lib/strippers.py b/lib/strippers.py new file mode 100644 index 0000000..7d27874 --- /dev/null +++ b/lib/strippers.py @@ -0,0 +1,48 @@ +''' + Manage which fileformat can be processed +''' + +import images +import audio +import office +import archive +import misc +import subprocess + +STRIPPERS = { + 'application/x-tar': archive.TarStripper, + 'application/x-gzip': archive.GzipStripper, + 'application/x-bzip2': archive.Bzip2Stripper, + 'application/zip': archive.ZipStripper, + 'audio/mpeg': audio.MpegAudioStripper, + 'application/x-bittorrent': misc.TorrentStripper, + 'application/opendocument': office.OpenDocumentStripper, + 'application/officeopenxml': office.OpenXmlStripper, +} + +try: # PDF support + import poppler + import cairo + STRIPPERS['application/x-pdf'] = office.PdfStripper + STRIPPERS['application/pdf'] = office.PdfStripper +except ImportError: + print('Unable to import python-poppler and/or python-cairo: no PDF \ + support') + +try: # mutangen-python : audio format support + import mutagen + STRIPPERS['audio/x-flac'] = audio.FlacStripper + STRIPPERS['audio/vorbis'] = audio.OggStripper +except ImportError: + print('Unable to import python-mutagen: limited audio format support') + +try: # check if exiftool is installed on the system + subprocess.Popen('exiftool', stdout=open('/dev/null')) + import exiftool + STRIPPERS['image/jpeg'] = exiftool.JpegStripper + STRIPPERS['image/png'] = exiftool.PngStripper +except: # if exiftool is not installed, use hachoir + print('Unable to find exiftool: limited images support') + STRIPPERS['image/jpeg'] = images.JpegStripper + STRIPPERS['image/png'] = images.PngStripper + -- cgit v1.3