diff options
Diffstat (limited to 'cli.py')
| -rwxr-xr-x | cli.py | 21 |
1 files changed, 19 insertions, 2 deletions
| @@ -18,7 +18,10 @@ def parse(): | |||
| 18 | help='Check if a file is free of harmfull metadatas') | 18 | help='Check if a file is free of harmfull metadatas') |
| 19 | common.add_option('--version', action='callback', callback=displayVersion, | 19 | common.add_option('--version', action='callback', callback=displayVersion, |
| 20 | help='Display version and exit') | 20 | help='Display version and exit') |
| 21 | 21 | common.add_option('--backup', '-b', action='store_true', default=False, | |
| 22 | help='Keep a backup copy') | ||
| 23 | common.add_option('--ugly', '-u', action='store_true', default=False, | ||
| 24 | help='Remove harmful meta, but with loss') | ||
| 22 | parser.add_option_group(common) | 25 | parser.add_option_group(common) |
| 23 | 26 | ||
| 24 | values, arguments = parser.parse_args() | 27 | values, arguments = parser.parse_args() |
| @@ -60,6 +63,18 @@ def clean_meta(class_file, filename): | |||
| 60 | class_file.remove_all() | 63 | class_file.remove_all() |
| 61 | print('%s cleaned !' % filename) | 64 | print('%s cleaned !' % filename) |
| 62 | 65 | ||
| 66 | def clean_meta_ugly(class_file, filename): | ||
| 67 | ''' | ||
| 68 | Clean the file 'filename', ugly way | ||
| 69 | ''' | ||
| 70 | print('[+] Cleaning %s' % filename) | ||
| 71 | if class_file.is_clean(): | ||
| 72 | print('%s is already clean' % filename) | ||
| 73 | else: | ||
| 74 | class_file.remove_all_ugly() | ||
| 75 | print('%s cleaned !' % filename) | ||
| 76 | |||
| 77 | |||
| 63 | def main(): | 78 | def main(): |
| 64 | args, filenames = parse() | 79 | args, filenames = parse() |
| 65 | 80 | ||
| @@ -68,11 +83,13 @@ def main(): | |||
| 68 | func = list_meta | 83 | func = list_meta |
| 69 | elif args.check is True: #only check if the file is clean | 84 | elif args.check is True: #only check if the file is clean |
| 70 | func = is_clean | 85 | func = is_clean |
| 86 | elif args.ugly is True: | ||
| 87 | func = clean_meta_ugly | ||
| 71 | else: #clean the file | 88 | else: #clean the file |
| 72 | func = clean_meta | 89 | func = clean_meta |
| 73 | 90 | ||
| 74 | for filename in filenames: | 91 | for filename in filenames: |
| 75 | class_file = mat.create_class_file(filename) | 92 | class_file = mat.create_class_file(filename, args.backup) |
| 76 | func(class_file, filename) | 93 | func(class_file, filename) |
| 77 | print('\n') | 94 | print('\n') |
| 78 | 95 | ||
