From e62ae6a87f630cbd389cf1b75672b06cd56973c8 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Tue, 26 Jul 2011 14:06:38 +0200 Subject: Pyflakes and pep8 validation --- cli.py | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) (limited to 'cli.py') diff --git a/cli.py b/cli.py index b9c8a5c..bfedbf6 100755 --- a/cli.py +++ b/cli.py @@ -10,10 +10,11 @@ import hachoir_core __version__ = '0.1' + def parse(): parser = optparse.OptionParser(usage='%prog [options] filename') - parser.add_option('--add2archive', '-a', action='store_true', default=False, - help='Add to outputed archive non-supported filetypes') + parser.add_option('--add2archive', '-a', action='store_true', + default=False, help='Add to outputed archive non-supported filetypes') parser.add_option('--backup', '-b', action='store_true', default=False, help='Keep a backup copy') parser.add_option('--check', '-c', action='store_true', default=False, @@ -31,15 +32,17 @@ def parse(): sys.exit(0) return values, arguments + def display_version(*args): print('Metadata Anonymisation Toolkit version %s') % mat.__version__ print('CLI version %s') % __version__ print('Hachoir version %s') % hachoir_core.__version__ sys.exit(0) + def list_meta(class_file, filename): ''' - Print all the meta of 'filename' on stdout + Print all the meta of 'filename' on stdout ''' print('[+] File %s :' % filename) if class_file.is_clean(): @@ -48,18 +51,20 @@ def list_meta(class_file, filename): for key, value in class_file.get_meta().iteritems(): print(key + ' : ' + str(value)) + def is_clean(class_file, filename): ''' - Say if 'filename' is clean or not + Say if 'filename' is clean or not ''' if class_file.is_clean(): print('[+] %s is clean' % filename) else: print('[+] %s is not clean' % filename) + def clean_meta(class_file, filename): ''' - Clean the file 'filename' + Clean the file 'filename' ''' print('[+] Cleaning %s' % filename) if class_file.is_clean(): @@ -68,9 +73,10 @@ def clean_meta(class_file, filename): class_file.remove_all() print('%s cleaned !' % filename) + def clean_meta_ugly(class_file, filename): ''' - Clean the file 'filename', ugly way + Clean the file 'filename', ugly way ''' print('[+] Cleaning %s' % filename) if class_file.is_clean(): @@ -79,17 +85,18 @@ def clean_meta_ugly(class_file, filename): class_file.remove_all_ugly() print('%s cleaned' % filename) + def main(): args, filenames = parse() #func receive the function correponding to the options given as parameters - if args.display is True: #only print metadatas + if args.display is True: # only print metadatas func = list_meta - elif args.check is True: #only check if the file is clean + elif args.check is True: # only check if the file is clean func = is_clean - elif args.ugly is True: #destructive anonymisation method + elif args.ugly is True: # destructive anonymisation method func = clean_meta_ugly - else: #clean the file + else: # clean the file func = clean_meta for filename in filenames: -- cgit v1.3