diff options
| author | jvoisin | 2011-06-23 19:00:44 +0200 |
|---|---|---|
| committer | jvoisin | 2011-06-23 19:00:44 +0200 |
| commit | e163520a130145496ceeeeeb94d950f17e7fd76e (patch) | |
| tree | 19d9bcfbc997f5884ea798f8edeaaad8da18915d /cli.py | |
| parent | 9e69adbe1b065707f8be4f146cc3c05660cef711 (diff) | |
Implementation of the --backup option, to keep a backup of the treated file (disabled by default)
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 | ||
