diff options
| author | jvoisin | 2014-02-03 01:27:07 +0000 |
|---|---|---|
| committer | jvoisin | 2014-02-03 01:27:07 +0000 |
| commit | 0fe03b09cd59fb80f59b9e77af1f950f2041e6ec (patch) | |
| tree | d67ba77a96bcb5e9fbcb926bc46bd1814209729a | |
| parent | 091a23c46f2bb74ba639f661552430ccd3045f72 (diff) | |
Remove the --force option, since it's pretty useless.
| -rwxr-xr-x | mat | 17 | ||||
| -rw-r--r-- | mat.1 | 3 |
2 files changed, 6 insertions, 14 deletions
| @@ -26,11 +26,8 @@ The default behaviour is to clean files given in argument') | |||
| 26 | default=False, help='Add to output archive non-supported filetypes (Off by default)') | 26 | default=False, help='Add to output archive non-supported filetypes (Off by default)') |
| 27 | options.add_option('--backup', '-b', action='store_true', default=False, | 27 | options.add_option('--backup', '-b', action='store_true', default=False, |
| 28 | help='Keep a backup copy') | 28 | help='Keep a backup copy') |
| 29 | options.add_option('--force', '-f', action='store_true', default=False, | ||
| 30 | help='Don\'t check if files are clean before cleaning') | ||
| 31 | options.add_option('--low-pdf-quality', '-L', action='store_true', default=False, | 29 | options.add_option('--low-pdf-quality', '-L', action='store_true', default=False, |
| 32 | help='Produces a lighter, but lower quality PDF') | 30 | help='Produces a lighter, but lower quality PDF') |
| 33 | |||
| 34 | info = optparse.OptionGroup(parser, 'Informations') | 31 | info = optparse.OptionGroup(parser, 'Informations') |
| 35 | info.add_option('--check', '-c', action='store_true', default=False, | 32 | info.add_option('--check', '-c', action='store_true', default=False, |
| 36 | help='Check if a file is free of harmful metadatas') | 33 | help='Check if a file is free of harmful metadatas') |
| @@ -60,12 +57,12 @@ def display_version(*_): | |||
| 60 | sys.exit(0) | 57 | sys.exit(0) |
| 61 | 58 | ||
| 62 | 59 | ||
| 63 | def list_meta(class_file, filename, force, add2archive): | 60 | def list_meta(class_file, filename, add2archive): |
| 64 | ''' | 61 | ''' |
| 65 | Print all the metadata of 'filename' on stdout | 62 | Print all the metadata of 'filename' on stdout |
| 66 | ''' | 63 | ''' |
| 67 | print('[+] File %s :' % filename) | 64 | print('[+] File %s :' % filename) |
| 68 | if not force and class_file.is_clean(): | 65 | if class_file.is_clean(): |
| 69 | print('No harmful metadata found') | 66 | print('No harmful metadata found') |
| 70 | else: | 67 | else: |
| 71 | meta = class_file.get_meta() | 68 | meta = class_file.get_meta() |
| @@ -76,7 +73,7 @@ def list_meta(class_file, filename, force, add2archive): | |||
| 76 | return 0 | 73 | return 0 |
| 77 | 74 | ||
| 78 | 75 | ||
| 79 | def is_clean(class_file, filename, force, add2archive): | 76 | def is_clean(class_file, filename, add2archive): |
| 80 | ''' | 77 | ''' |
| 81 | Say if 'filename' is clean or not | 78 | Say if 'filename' is clean or not |
| 82 | ''' | 79 | ''' |
| @@ -87,7 +84,7 @@ def is_clean(class_file, filename, force, add2archive): | |||
| 87 | return 0 | 84 | return 0 |
| 88 | 85 | ||
| 89 | 86 | ||
| 90 | def clean_meta(class_file, filename, force, add2archive): | 87 | def clean_meta(class_file, filename, add2archive): |
| 91 | ''' | 88 | ''' |
| 92 | Clean the file 'filename' | 89 | Clean the file 'filename' |
| 93 | ''' | 90 | ''' |
| @@ -95,9 +92,7 @@ def clean_meta(class_file, filename, force, add2archive): | |||
| 95 | print('[-] %s is not writable' % filename) | 92 | print('[-] %s is not writable' % filename) |
| 96 | return 1 | 93 | return 1 |
| 97 | print('[*] Cleaning %s' % filename) | 94 | print('[*] Cleaning %s' % filename) |
| 98 | if not force and class_file.is_clean(): | 95 | if not add2archive: |
| 99 | print('[+] %s is already clean' % filename) | ||
| 100 | elif not add2archive: | ||
| 101 | is_archive = isinstance(class_file, archive.GenericArchiveStripper) | 96 | is_archive = isinstance(class_file, archive.GenericArchiveStripper) |
| 102 | is_terminal = isinstance(class_file, archive.TerminalZipStripper) | 97 | is_terminal = isinstance(class_file, archive.TerminalZipStripper) |
| 103 | if is_archive and not is_terminal: | 98 | if is_archive and not is_terminal: |
| @@ -158,7 +153,7 @@ def main(): | |||
| 158 | class_file = mat.create_class_file(filename, args.backup, | 153 | class_file = mat.create_class_file(filename, args.backup, |
| 159 | add2archive=args.add2archive, low_pdf_quality=args.low_pdf_quality) | 154 | add2archive=args.add2archive, low_pdf_quality=args.low_pdf_quality) |
| 160 | if class_file: | 155 | if class_file: |
| 161 | ret += func(class_file, filename, args.force, args.add2archive) | 156 | ret += func(class_file, filename, args.add2archive) |
| 162 | else: | 157 | else: |
| 163 | ret = 1 | 158 | ret = 1 |
| 164 | print('[-] Unable to process %s' % filename) | 159 | print('[-] Unable to process %s' % filename) |
| @@ -35,9 +35,6 @@ Check if a file is free of harmful metadatas | |||
| 35 | \fB\-d\fR, \fB\-\-display\fR | 35 | \fB\-d\fR, \fB\-\-display\fR |
| 36 | List all the harmful meta of a file without removing them | 36 | List all the harmful meta of a file without removing them |
| 37 | .TP | 37 | .TP |
| 38 | \fB\-f\fR, \fB\-\-force\fR | ||
| 39 | Don't check if files are clean before cleaning | ||
| 40 | .TP | ||
| 41 | \fB\-l\fR, \fB\-\-list\fR | 38 | \fB\-l\fR, \fB\-\-list\fR |
| 42 | List all supported fileformat | 39 | List all supported fileformat |
| 43 | .TP | 40 | .TP |
