From afbfe94cf082d71f492b98e442441cc01f6271c2 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 24 Dec 2011 01:21:31 +0100 Subject: Rename "ugly" to ""strict" --- mat-cli | 21 +++++++++++---------- mat/archive.py | 12 ++++++------ mat/office.py | 6 +++--- mat/parser.py | 2 +- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/mat-cli b/mat-cli index 41ce335..2ee0637 100755 --- a/mat-cli +++ b/mat-cli @@ -25,7 +25,7 @@ The default behaviour is to clean files given in argument') help='Keep a backup copy') options.add_option('--force', '-f', action='store_true', default=False, help='Don\'t check if files are clean before cleaning') - options.add_option('--ugly', '-u', action='store_true', default=False, + options.add_option('--strict', '-u', action='store_true', default=False, help='Strict cleaning mode : loss can occur') info = optparse.OptionGroup(parser, 'Informations') @@ -42,6 +42,8 @@ The default behaviour is to clean files given in argument') values, arguments = parser.parse_args() if not arguments and values.list is False: + # if no argument and no files are passed, + # print help and exit parser.print_help() sys.exit(0) return values, arguments @@ -65,11 +67,10 @@ def list_meta(class_file, filename, force): print('No harmful metadata found') else: meta = class_file.get_meta() - if meta is None: - print('No harmful metadata found') - else: + print ('Harmful metadata found:') + if meta is not None: for key, value in class_file.get_meta().iteritems(): - print(key + ' : ' + str(value)) + print('\t' + key + ' : ' + str(value)) def is_clean(class_file, filename, force): @@ -95,15 +96,15 @@ def clean_meta(class_file, filename, force): else: print('Unable to clean %s', filename) -def clean_meta_ugly(class_file, filename, force): +def clean_meta_strict(class_file, filename, force): ''' - Clean the file 'filename', ugly way + Clean the file 'filename', strict way ''' print('[+] Cleaning %s' % filename) if force is False and class_file.is_clean(): print('%s is already clean' % filename) else: - class_file.remove_all_ugly() + class_file.remove_all_strict() print('%s cleaned' % filename) @@ -139,8 +140,8 @@ def main(): func = list_meta elif args.check is True: # only check if the file is clean func = is_clean - elif args.ugly is True: # destructive anonymisation method - func = clean_meta_ugly + elif args.strict is True: # destructive anonymisation method + func = clean_meta_strict elif args.list is True: # print the list of all supported format list_supported() else: # clean the file diff --git a/mat/archive.py b/mat/archive.py index 65527d2..9993102 100644 --- a/mat/archive.py +++ b/mat/archive.py @@ -41,16 +41,16 @@ class GenericArchiveStripper(parser.GenericParser): ''' return self._remove_all('normal') - def remove_all_ugly(self): + def remove_all_strict(self): ''' - call remove_all() with in argument : "ugly" + call remove_all() with in argument : "strict" ''' - return self._remove_all('ugly') + return self._remove_all('strict') def _remove_all(self, method): ''' Remove all meta, normal way if method is "normal", - else, use the ugly way (with possible data loss) + else, use the strict way (with possible data loss) ''' raise NotImplementedError @@ -146,7 +146,7 @@ harmless format' % item.filename) if method is 'normal': cfile.remove_all() else: - cfile.remove_all_ugly() + cfile.remove_all_strict() logging.debug('Processing %s from %s' % (item.filename, self.filename)) zipout.write(name, item.filename) @@ -193,7 +193,7 @@ class TarStripper(GenericArchiveStripper): if method is 'normal': cfile.remove_all() else: - cfile.remove_all_ugly() + cfile.remove_all_strict() tarout.add(name, item.name, filter=self._remove) except: logging.info('%s\' format is not supported or harmless' % diff --git a/mat/office.py b/mat/office.py index e3febba..e1d738e 100644 --- a/mat/office.py +++ b/mat/office.py @@ -87,7 +87,7 @@ class OpenDocumentStripper(archive.GenericArchiveStripper): if method == 'normal': cfile.remove_all() else: - cfile.remove_all_ugly() + cfile.remove_all_strict() logging.debug('Processing %s from %s' % (item, self.filename)) zipout.write(name, item) @@ -150,7 +150,7 @@ class PdfStripper(parser.GenericParser): return self._remove_meta() - def remove_all_ugly(self): + def remove_all_strict(self): ''' Opening the PDF with poppler, then doing a render on a cairo pdfsurface for each pages. @@ -261,7 +261,7 @@ class OpenXmlStripper(archive.GenericArchiveStripper): if method == 'normal': cfile.remove_all() else: - cfile.remove_all_ugly() + cfile.remove_all_strict() logging.debug('Processing %s from %s' % (item, self.filename)) zipout.write(name, item) diff --git a/mat/parser.py b/mat/parser.py index 651b244..6dc5d0b 100644 --- a/mat/parser.py +++ b/mat/parser.py @@ -78,7 +78,7 @@ class GenericParser(object): except: return False - def remove_all_ugly(self): + def remove_all_strict(self): ''' If the remove_all() is not efficient enough, this method is implemented : -- cgit v1.3