diff options
| -rwxr-xr-x | mat | 20 | ||||
| -rwxr-xr-x | mat-gui | 6 |
2 files changed, 11 insertions, 15 deletions
| @@ -6,7 +6,6 @@ | |||
| 6 | import sys | 6 | import sys |
| 7 | import xml.sax | 7 | import xml.sax |
| 8 | import optparse | 8 | import optparse |
| 9 | import os | ||
| 10 | 9 | ||
| 11 | import hachoir_core | 10 | import hachoir_core |
| 12 | 11 | ||
| @@ -41,11 +40,10 @@ The default behaviour is to clean files given in argument') | |||
| 41 | parser.add_option_group(info) | 40 | parser.add_option_group(info) |
| 42 | 41 | ||
| 43 | values, arguments = parser.parse_args() | 42 | values, arguments = parser.parse_args() |
| 44 | if not arguments and values.list is False: | 43 | if not arguments and not values.list: |
| 45 | # if no argument and no files are passed, | 44 | # if no argument and no files are passed, |
| 46 | # print help and exit | 45 | # print help and exit |
| 47 | parser.print_help() | 46 | parser.print_help() |
| 48 | sys.exit(0) | ||
| 49 | return values, arguments | 47 | return values, arguments |
| 50 | 48 | ||
| 51 | 49 | ||
| @@ -63,12 +61,12 @@ def list_meta(class_file, filename, force): | |||
| 63 | Print all the metadata of 'filename' on stdout | 61 | Print all the metadata of 'filename' on stdout |
| 64 | ''' | 62 | ''' |
| 65 | print('[+] File %s :' % filename) | 63 | print('[+] File %s :' % filename) |
| 66 | if force is False and class_file.is_clean(): | 64 | if not force and class_file.is_clean(): |
| 67 | print('No harmful metadata found') | 65 | print('No harmful metadata found') |
| 68 | else: | 66 | else: |
| 69 | meta = class_file.get_meta() | 67 | meta = class_file.get_meta() |
| 70 | print ('Harmful metadata found:') | 68 | print ('Harmful metadata found:') |
| 71 | if meta is not None: | 69 | if meta: |
| 72 | for key, value in class_file.get_meta().iteritems(): | 70 | for key, value in class_file.get_meta().iteritems(): |
| 73 | print('\t' + key + ' : ' + str(value)) | 71 | print('\t' + key + ' : ' + str(value)) |
| 74 | 72 | ||
| @@ -88,7 +86,7 @@ def clean_meta(class_file, filename, force): | |||
| 88 | Clean the file 'filename' | 86 | Clean the file 'filename' |
| 89 | ''' | 87 | ''' |
| 90 | print('[+] Cleaning %s' % filename) | 88 | print('[+] Cleaning %s' % filename) |
| 91 | if force is False and class_file.is_clean(): | 89 | if not force and class_file.is_clean(): |
| 92 | print('%s is already clean' % filename) | 90 | print('%s is already clean' % filename) |
| 93 | else: | 91 | else: |
| 94 | if class_file.remove_all(): | 92 | if class_file.remove_all(): |
| @@ -110,8 +108,6 @@ def list_supported(): | |||
| 110 | 108 | ||
| 111 | for item in handler.list: | 109 | for item in handler.list: |
| 112 | if strippers.STRIPPERS.has_key(item['mimetype'].split(',')[0]): | 110 | if strippers.STRIPPERS.has_key(item['mimetype'].split(',')[0]): |
| 113 | #on display localy supported formats | ||
| 114 | print 'ok' | ||
| 115 | print('%s (%s)' % (item['name'], item['extension'])) | 111 | print('%s (%s)' % (item['name'], item['extension'])) |
| 116 | print('\tsupport : ' + item['support']) | 112 | print('\tsupport : ' + item['support']) |
| 117 | print('\tmetadata : ' + item['metadata']) | 113 | print('\tmetadata : ' + item['metadata']) |
| @@ -128,11 +124,11 @@ def main(): | |||
| 128 | args, filenames = parse() | 124 | args, filenames = parse() |
| 129 | 125 | ||
| 130 | #func receive the function correponding to the options given as parameters | 126 | #func receive the function correponding to the options given as parameters |
| 131 | if args.display is True: # only print metadatas | 127 | if args.display: # only print metadatas |
| 132 | func = list_meta | 128 | func = list_meta |
| 133 | elif args.check is True: # only check if the file is clean | 129 | elif args.check: # only check if the file is clean |
| 134 | func = is_clean | 130 | func = is_clean |
| 135 | elif args.list is True: # print the list of all supported format | 131 | elif args.list: # print the list of all supported format |
| 136 | list_supported() | 132 | list_supported() |
| 137 | else: # clean the file | 133 | else: # clean the file |
| 138 | func = clean_meta | 134 | func = clean_meta |
| @@ -140,7 +136,7 @@ def main(): | |||
| 140 | for filename in filenames: | 136 | for filename in filenames: |
| 141 | class_file = mat.create_class_file(filename, args.backup, | 137 | class_file = mat.create_class_file(filename, args.backup, |
| 142 | args.add2archive) | 138 | args.add2archive) |
| 143 | if class_file is not None: | 139 | if class_file: |
| 144 | func(class_file, filename, args.force) | 140 | func(class_file, filename, args.force) |
| 145 | else: | 141 | else: |
| 146 | print('Unable to process %s' % filename) | 142 | print('Unable to process %s' % filename) |
| @@ -291,7 +291,7 @@ class GUI: | |||
| 291 | return False | 291 | return False |
| 292 | 292 | ||
| 293 | cf = CFile(filename, self.backup, self.add2archive) | 293 | cf = CFile(filename, self.backup, self.add2archive) |
| 294 | if cf.file is not None: # if the file is supported by the mat | 294 | if cf.file: # if the file is supported by the mat |
| 295 | self.liststore.append([cf, os.path.dirname(cf.file.filename) + os.path.sep, | 295 | self.liststore.append([cf, os.path.dirname(cf.file.filename) + os.path.sep, |
| 296 | cf.file.basename, cf.file.mime, _('unknow'), 'None']) | 296 | cf.file.basename, cf.file.mime, _('unknow'), 'None']) |
| 297 | return False | 297 | return False |
| @@ -538,7 +538,7 @@ non-anonymised) file to output archive')) | |||
| 538 | ''' | 538 | ''' |
| 539 | for line in iterator: # for each file in selection | 539 | for line in iterator: # for each file in selection |
| 540 | self.statusbar.push(0, _('Checking %s...') % self.liststore[line][1]) | 540 | self.statusbar.push(0, _('Checking %s...') % self.liststore[line][1]) |
| 541 | if self.force is True or self.liststore[line][4] != _('Clean'): | 541 | if self.force or self.liststore[line][4] != _('Clean'): |
| 542 | if self.liststore[line][0].file.is_clean(): | 542 | if self.liststore[line][0].file.is_clean(): |
| 543 | string = _('Clean') | 543 | string = _('Clean') |
| 544 | else: | 544 | else: |
| @@ -556,7 +556,7 @@ non-anonymised) file to output archive')) | |||
| 556 | for line in iterator: # for each file in selection | 556 | for line in iterator: # for each file in selection |
| 557 | logging.info('Cleaning %s' % self.liststore[line][1]) | 557 | logging.info('Cleaning %s' % self.liststore[line][1]) |
| 558 | self.statusbar.push(0, _('Cleaning %s...') % self.liststore[line][1]) | 558 | self.statusbar.push(0, _('Cleaning %s...') % self.liststore[line][1]) |
| 559 | if self.force is True or self.liststore[line][4] != _('Clean'): | 559 | if self.force or self.liststore[line][4] != _('Clean'): |
| 560 | if self.liststore[line][0].file.remove_all(): | 560 | if self.liststore[line][0].file.remove_all(): |
| 561 | self.liststore[line][4] = _('Clean') | 561 | self.liststore[line][4] = _('Clean') |
| 562 | if self.backup: # the backup copy state | 562 | if self.backup: # the backup copy state |
