diff options
| -rwxr-xr-x | mat | 17 |
1 files changed, 8 insertions, 9 deletions
| @@ -40,11 +40,10 @@ The default behaviour is to clean files given in argument') | |||
| 40 | parser.add_option_group(info) | 40 | parser.add_option_group(info) |
| 41 | 41 | ||
| 42 | values, arguments = parser.parse_args() | 42 | values, arguments = parser.parse_args() |
| 43 | if not arguments and values.list is False: | 43 | if not arguments and not values.list: |
| 44 | # if no argument and no files are passed, | 44 | # if no argument and no files are passed, |
| 45 | # print help and exit | 45 | # print help and exit |
| 46 | parser.print_help() | 46 | parser.print_help() |
| 47 | sys.exit(0) | ||
| 48 | return values, arguments | 47 | return values, arguments |
| 49 | 48 | ||
| 50 | 49 | ||
| @@ -62,12 +61,12 @@ def list_meta(class_file, filename, force): | |||
| 62 | Print all the metadata of 'filename' on stdout | 61 | Print all the metadata of 'filename' on stdout |
| 63 | ''' | 62 | ''' |
| 64 | print('[+] File %s :' % filename) | 63 | print('[+] File %s :' % filename) |
| 65 | if force is False and class_file.is_clean(): | 64 | if not force and class_file.is_clean(): |
| 66 | print('No harmful metadata found') | 65 | print('No harmful metadata found') |
| 67 | else: | 66 | else: |
| 68 | meta = class_file.get_meta() | 67 | meta = class_file.get_meta() |
| 69 | print ('Harmful metadata found:') | 68 | print ('Harmful metadata found:') |
| 70 | if meta is not None: | 69 | if meta: |
| 71 | for key, value in class_file.get_meta().iteritems(): | 70 | for key, value in class_file.get_meta().iteritems(): |
| 72 | print('\t' + key + ' : ' + str(value)) | 71 | print('\t' + key + ' : ' + str(value)) |
| 73 | 72 | ||
| @@ -87,7 +86,7 @@ def clean_meta(class_file, filename, force): | |||
| 87 | Clean the file 'filename' | 86 | Clean the file 'filename' |
| 88 | ''' | 87 | ''' |
| 89 | print('[+] Cleaning %s' % filename) | 88 | print('[+] Cleaning %s' % filename) |
| 90 | if force is False and class_file.is_clean(): | 89 | if not force and class_file.is_clean(): |
| 91 | print('%s is already clean' % filename) | 90 | print('%s is already clean' % filename) |
| 92 | else: | 91 | else: |
| 93 | if class_file.remove_all(): | 92 | if class_file.remove_all(): |
| @@ -125,11 +124,11 @@ def main(): | |||
| 125 | args, filenames = parse() | 124 | args, filenames = parse() |
| 126 | 125 | ||
| 127 | #func receive the function correponding to the options given as parameters | 126 | #func receive the function correponding to the options given as parameters |
| 128 | if args.display is True: # only print metadatas | 127 | if args.display: # only print metadatas |
| 129 | func = list_meta | 128 | func = list_meta |
| 130 | elif args.check is True: # only check if the file is clean | 129 | elif args.check: # only check if the file is clean |
| 131 | func = is_clean | 130 | func = is_clean |
| 132 | elif args.list is True: # print the list of all supported format | 131 | elif args.list: # print the list of all supported format |
| 133 | list_supported() | 132 | list_supported() |
| 134 | else: # clean the file | 133 | else: # clean the file |
| 135 | func = clean_meta | 134 | func = clean_meta |
| @@ -137,7 +136,7 @@ def main(): | |||
| 137 | for filename in filenames: | 136 | for filename in filenames: |
| 138 | class_file = mat.create_class_file(filename, args.backup, | 137 | class_file = mat.create_class_file(filename, args.backup, |
| 139 | args.add2archive) | 138 | args.add2archive) |
| 140 | if class_file is not None: | 139 | if class_file: |
| 141 | func(class_file, filename, args.force) | 140 | func(class_file, filename, args.force) |
| 142 | else: | 141 | else: |
| 143 | print('Unable to process %s' % filename) | 142 | print('Unable to process %s' % filename) |
