summaryrefslogtreecommitdiff
path: root/libmat/mat.py
diff options
context:
space:
mode:
authorjvoisin2015-12-02 17:07:19 +0100
committerjvoisin2015-12-02 17:22:45 +0100
commit80ece3001895ea13d50915a5215fd47e313bab4c (patch)
treec5ede43867c5d7fe2af4178b34b0e6dc219f6aac /libmat/mat.py
parent3cf80e8b5d6faf410e9ad3aad77f23cf6418a587 (diff)
Remove hachoir from MAT.
This (huge) commit removes completely hachoir from MAT. Audio files are now processed with mutagen, and images with exiftool, since the main python imaging library (PIL) isn't super-great to deal with metadata (and damaged/non-standard files). Package maintainer should change the dependencies to reflect this.
Diffstat (limited to 'libmat/mat.py')
-rw-r--r--libmat/mat.py21
1 files changed, 2 insertions, 19 deletions
diff --git a/libmat/mat.py b/libmat/mat.py
index 42357d6..2634cc3 100644
--- a/libmat/mat.py
+++ b/libmat/mat.py
@@ -10,9 +10,6 @@ import platform
10import subprocess 10import subprocess
11import xml.sax 11import xml.sax
12 12
13import hachoir_core.cmd_line
14import hachoir_parser
15
16import libmat.exceptions 13import libmat.exceptions
17 14
18__version__ = '0.5.4' 15__version__ = '0.5.4'
@@ -20,12 +17,10 @@ __author__ = 'jvoisin'
20 17
21# Silence 18# Silence
22LOGGING_LEVEL = logging.CRITICAL 19LOGGING_LEVEL = logging.CRITICAL
23hachoir_core.config.quiet = True
24fname = '' 20fname = ''
25 21
26# Verbose 22# Verbose
27# LOGGING_LEVEL = logging.DEBUG 23# LOGGING_LEVEL = logging.DEBUG
28# hachoir_core.config.quiet = False
29# logname = 'report.log' 24# logname = 'report.log'
30 25
31logging.basicConfig(filename=fname, level=LOGGING_LEVEL) 26logging.basicConfig(filename=fname, level=LOGGING_LEVEL)
@@ -155,22 +150,10 @@ def create_class_file(name, backup, **kwargs):
155 elif not os.access(name, os.R_OK): # check read permissions 150 elif not os.access(name, os.R_OK): # check read permissions
156 logging.error('%s is is not readable', name) 151 logging.error('%s is is not readable', name)
157 return None 152 return None
158 elif not os.path.getsize(name): # check if the file is not empty (hachoir crash on empty files)
159 logging.error('%s is empty', name)
160 return None
161
162 try:
163 filename = hachoir_core.cmd_line.unicodeFilename(name)
164 except TypeError: # get rid of "decoding Unicode is not supported"
165 filename = name
166
167 parser = hachoir_parser.createParser(filename)
168 if not parser:
169 logging.info('Unable to parse %s with hachoir', filename)
170 153
171 mime = mimetypes.guess_type(name)[0] 154 mime = mimetypes.guess_type(name)[0]
172 if not mime: 155 if not mime:
173 logging.info('Unable to find mimetype of %s', filename) 156 logging.info('Unable to find mimetype of %s', name)
174 return None 157 return None
175 158
176 if mime.startswith('application/vnd.oasis.opendocument'): 159 if mime.startswith('application/vnd.oasis.opendocument'):
@@ -186,4 +169,4 @@ def create_class_file(name, backup, **kwargs):
186 logging.info('Don\'t have stripper for %s format', mime) 169 logging.info('Don\'t have stripper for %s format', mime)
187 return None 170 return None
188 171
189 return stripper_class(filename, parser, mime, backup, is_writable, **kwargs) 172 return stripper_class(name, mime, backup, is_writable, **kwargs)