diff options
| author | jvoisin | 2011-07-26 04:55:59 +0200 |
|---|---|---|
| committer | jvoisin | 2011-07-26 04:55:59 +0200 |
| commit | f6e3d57173604dab7228c830e84415ead02e169b (patch) | |
| tree | c38b5e2f09b6aebff79a6786ce8d26d05c7c5845 /lib/mat.py | |
| parent | 342cbf4bd69e638f62319ea0e6660af5dc717131 (diff) | |
Tests are green for opendocument format
Diffstat (limited to 'lib/mat.py')
| -rw-r--r-- | lib/mat.py | 15 |
1 files changed, 7 insertions, 8 deletions
| @@ -18,8 +18,8 @@ import audio | |||
| 18 | import office | 18 | import office |
| 19 | import archive | 19 | import archive |
| 20 | 20 | ||
| 21 | __version__ = "0.1" | 21 | __version__ = '0.1' |
| 22 | __author__ = "jvoisin" | 22 | __author__ = 'jvoisin' |
| 23 | 23 | ||
| 24 | LOGGING_LEVEL = logging.DEBUG | 24 | LOGGING_LEVEL = logging.DEBUG |
| 25 | 25 | ||
| @@ -53,7 +53,7 @@ def is_secure(filename): | |||
| 53 | ''' | 53 | ''' |
| 54 | 54 | ||
| 55 | if not(os.path.isfile(filename)): #check if the file exist | 55 | if not(os.path.isfile(filename)): #check if the file exist |
| 56 | logging.error("Error: %s is not a valid file" % filename) | 56 | logging.error('Error: %s is not a valid file' % filename) |
| 57 | return False | 57 | return False |
| 58 | 58 | ||
| 59 | def create_class_file(name, backup, add2archive): | 59 | def create_class_file(name, backup, add2archive): |
| @@ -64,7 +64,7 @@ def create_class_file(name, backup, add2archive): | |||
| 64 | if is_secure(name): | 64 | if is_secure(name): |
| 65 | return | 65 | return |
| 66 | 66 | ||
| 67 | filename = "" | 67 | filename = '' |
| 68 | realname = name | 68 | realname = name |
| 69 | try: | 69 | try: |
| 70 | filename = hachoir_core.cmd_line.unicodeFilename(name) | 70 | filename = hachoir_core.cmd_line.unicodeFilename(name) |
| @@ -72,7 +72,7 @@ def create_class_file(name, backup, add2archive): | |||
| 72 | filename = name | 72 | filename = name |
| 73 | parser = hachoir_parser.createParser(filename) | 73 | parser = hachoir_parser.createParser(filename) |
| 74 | if not parser: | 74 | if not parser: |
| 75 | logging.error("Unable to parse %s" % filename) | 75 | logging.info('Unable to parse %s' % filename) |
| 76 | return | 76 | return |
| 77 | 77 | ||
| 78 | editor = hachoir_editor.createEditor(parser) | 78 | editor = hachoir_editor.createEditor(parser) |
| @@ -85,7 +85,7 @@ def create_class_file(name, backup, add2archive): | |||
| 85 | stripper_class = strippers[editor.input.__class__] | 85 | stripper_class = strippers[editor.input.__class__] |
| 86 | except KeyError: | 86 | except KeyError: |
| 87 | #Place for another lib than hachoir | 87 | #Place for another lib than hachoir |
| 88 | logging.error("Don't have stripper for format %s" % editor.description) | 88 | logging.info('Don\'t have stripper for format %s' % editor.description) |
| 89 | return | 89 | return |
| 90 | 90 | ||
| 91 | if editor.input.__class__ == hachoir_parser.misc.PDFDocument:#pdf | 91 | if editor.input.__class__ == hachoir_parser.misc.PDFDocument:#pdf |
| @@ -95,8 +95,7 @@ def create_class_file(name, backup, add2archive): | |||
| 95 | #zip based format | 95 | #zip based format |
| 96 | mime = mimetypes.guess_type(filename)[0] | 96 | mime = mimetypes.guess_type(filename)[0] |
| 97 | try:#Ugly workaround, cleaning open document delete mime (wtf?) | 97 | try:#Ugly workaround, cleaning open document delete mime (wtf?) |
| 98 | if mime.startswith(#Open document format | 98 | if mime.startswith('application/vnd.oasis.opendocument'): |
| 99 | 'application/vnd.oasis.opendocument'): | ||
| 100 | return office.OpenDocumentStripper(realname, filename, parser, | 99 | return office.OpenDocumentStripper(realname, filename, parser, |
| 101 | editor, backup, add2archive) | 100 | editor, backup, add2archive) |
| 102 | else:#normal zip | 101 | else:#normal zip |
