summaryrefslogtreecommitdiff
path: root/MAT/strippers.py
diff options
context:
space:
mode:
Diffstat (limited to 'MAT/strippers.py')
-rw-r--r--MAT/strippers.py67
1 files changed, 67 insertions, 0 deletions
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 @@
1'''
2 Manage which fileformat can be processed
3'''
4
5import images
6import audio
7import office
8import archive
9import misc
10import subprocess
11
12STRIPPERS = {
13 'application/x-tar': archive.TarStripper,
14 'application/x-gzip': archive.GzipStripper,
15 'application/x-bzip2': archive.Bzip2Stripper,
16 'application/zip': archive.ZipStripper,
17 'audio/mpeg': audio.MpegAudioStripper,
18 'application/x-bittorrent': misc.TorrentStripper,
19 'application/opendocument': office.OpenDocumentStripper,
20 'application/officeopenxml': office.OpenXmlStripper,
21}
22
23
24# PDF support
25pdfSupport = True
26try:
27 import poppler
28except ImportError:
29 print('Unable to import python-poppler: not PDF support')
30 pdfSupport = False
31
32try:
33 import cairo
34except ImportError:
35 print('Unable to import python-cairo: no PDF support')
36 pdfSupport = False
37
38try:
39 import pdfrw
40except ImportError:
41 print('Unable to import python-pdfrw: no PDf support')
42 pdfSupport = False
43
44if pdfSupport:
45 STRIPPERS['application/x-pdf'] = office.PdfStripper
46 STRIPPERS['application/pdf'] = office.PdfStripper
47
48
49# audio format support with mutagen-python
50try:
51 import mutagen
52 STRIPPERS['audio/x-flac'] = audio.FlacStripper
53 STRIPPERS['audio/vorbis'] = audio.OggStripper
54except ImportError:
55 print('Unable to import python-mutagen: limited audio format support')
56
57# exiftool
58try:
59 subprocess.Popen('exiftool', stdout=open('/dev/null'))
60 import exiftool
61 STRIPPERS['image/jpeg'] = exiftool.JpegStripper
62 STRIPPERS['image/png'] = exiftool.PngStripper
63except: # if exiftool is not installed, use hachoir
64 print('Unable to find exiftool: limited images support')
65 STRIPPERS['image/jpeg'] = images.JpegStripper
66 STRIPPERS['image/png'] = images.PngStripper
67