From cbf8a2a65928694202e19b6bcf56ec84bcbf613c Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 8 Dec 2012 02:02:25 +0100 Subject: Reorganize source tree and files installation location, cleanup setup.py (Closes: #689409) --- MAT/strippers.py | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 MAT/strippers.py (limited to 'MAT/strippers.py') diff --git a/MAT/strippers.py b/MAT/strippers.py new file mode 100644 index 0000000..61030a7 --- /dev/null +++ b/MAT/strippers.py @@ -0,0 +1,67 @@ +''' + 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, +} + + +# PDF support +pdfSupport = True +try: + import poppler +except ImportError: + print('Unable to import python-poppler: not PDF support') + pdfSupport = False + +try: + import cairo +except ImportError: + print('Unable to import python-cairo: no PDF support') + pdfSupport = False + +try: + import pdfrw +except ImportError: + print('Unable to import python-pdfrw: no PDf support') + pdfSupport = False + +if pdfSupport: + STRIPPERS['application/x-pdf'] = office.PdfStripper + STRIPPERS['application/pdf'] = office.PdfStripper + + +# audio format support with mutagen-python +try: + 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') + +# exiftool +try: + 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