diff options
| author | jvoisin | 2011-07-03 15:01:06 +0200 |
|---|---|---|
| committer | jvoisin | 2011-07-03 15:01:06 +0200 |
| commit | 9fcc253ad66a002b708eef7ff2c0a379dac8f5ce (patch) | |
| tree | 966b365152fae7b23a7f247bfe6dd6db29b1d6c5 | |
| parent | b1570828209e133ea441cf49e09211048f9fc15a (diff) | |
Correct handling of unhandled files
| -rwxr-xr-x | cli.py | 3 | ||||
| -rw-r--r-- | lib/mat.py | 6 |
2 files changed, 5 insertions, 4 deletions
| @@ -92,7 +92,8 @@ def main(): | |||
| 92 | 92 | ||
| 93 | for filename in filenames: | 93 | for filename in filenames: |
| 94 | class_file = mat.create_class_file(filename, args.backup) | 94 | class_file = mat.create_class_file(filename, args.backup) |
| 95 | func(class_file, filename) | 95 | if class_file is not None: |
| 96 | func(class_file, filename) | ||
| 96 | 97 | ||
| 97 | if __name__ == '__main__': | 98 | if __name__ == '__main__': |
| 98 | main() | 99 | main() |
| @@ -61,8 +61,8 @@ def create_class_file(name, backup): | |||
| 61 | filename = hachoir_core.cmd_line.unicodeFilename(name) | 61 | filename = hachoir_core.cmd_line.unicodeFilename(name) |
| 62 | parser = hachoir_parser.createParser(filename) | 62 | parser = hachoir_parser.createParser(filename) |
| 63 | if not parser: | 63 | if not parser: |
| 64 | print("Unable to parse the file %s with hachoir-parser." % filename) | 64 | print("[+] Unable to parse %s" % filename) |
| 65 | sys.exit(1) | 65 | return |
| 66 | 66 | ||
| 67 | editor = hachoir_editor.createEditor(parser) | 67 | editor = hachoir_editor.createEditor(parser) |
| 68 | try: | 68 | try: |
| @@ -74,7 +74,7 @@ def create_class_file(name, backup): | |||
| 74 | stripper_class = strippers[editor.input.__class__] | 74 | stripper_class = strippers[editor.input.__class__] |
| 75 | except KeyError: | 75 | except KeyError: |
| 76 | #Place for another lib than hachoir | 76 | #Place for another lib than hachoir |
| 77 | print("Don't have stripper for file type: %s" % editor.description) | 77 | print("[+] Don't have stripper for file type %s" % editor.description) |
| 78 | sys.exit(1) | 78 | sys.exit(1) |
| 79 | if editor.input.__class__ == hachoir_parser.misc.PDFDocument: | 79 | if editor.input.__class__ == hachoir_parser.misc.PDFDocument: |
| 80 | return stripper_class(filename, realname, backup) | 80 | return stripper_class(filename, realname, backup) |
