diff options
Diffstat (limited to 'libmat/mat.py')
| -rw-r--r-- | libmat/mat.py | 21 |
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 | |||
| 10 | import subprocess | 10 | import subprocess |
| 11 | import xml.sax | 11 | import xml.sax |
| 12 | 12 | ||
| 13 | import hachoir_core.cmd_line | ||
| 14 | import hachoir_parser | ||
| 15 | |||
| 16 | import libmat.exceptions | 13 | import 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 |
| 22 | LOGGING_LEVEL = logging.CRITICAL | 19 | LOGGING_LEVEL = logging.CRITICAL |
| 23 | hachoir_core.config.quiet = True | ||
| 24 | fname = '' | 20 | fname = '' |
| 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 | ||
| 31 | logging.basicConfig(filename=fname, level=LOGGING_LEVEL) | 26 | logging.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) |
