summaryrefslogtreecommitdiff
path: root/cli.py
diff options
context:
space:
mode:
authorjvoisin2011-07-26 14:06:38 +0200
committerjvoisin2011-07-26 14:06:38 +0200
commite62ae6a87f630cbd389cf1b75672b06cd56973c8 (patch)
tree5433e5bde0d0448795626190f8014c61b38ac1c5 /cli.py
parentf6e3d57173604dab7228c830e84415ead02e169b (diff)
Pyflakes and pep8 validation
Diffstat (limited to 'cli.py')
-rwxr-xr-xcli.py27
1 files changed, 17 insertions, 10 deletions
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
10 10
11__version__ = '0.1' 11__version__ = '0.1'
12 12
13
13def parse(): 14def parse():
14 parser = optparse.OptionParser(usage='%prog [options] filename') 15 parser = optparse.OptionParser(usage='%prog [options] filename')
15 parser.add_option('--add2archive', '-a', action='store_true', default=False, 16 parser.add_option('--add2archive', '-a', action='store_true',
16 help='Add to outputed archive non-supported filetypes') 17 default=False, help='Add to outputed archive non-supported filetypes')
17 parser.add_option('--backup', '-b', action='store_true', default=False, 18 parser.add_option('--backup', '-b', action='store_true', default=False,
18 help='Keep a backup copy') 19 help='Keep a backup copy')
19 parser.add_option('--check', '-c', action='store_true', default=False, 20 parser.add_option('--check', '-c', action='store_true', default=False,
@@ -31,15 +32,17 @@ def parse():
31 sys.exit(0) 32 sys.exit(0)
32 return values, arguments 33 return values, arguments
33 34
35
34def display_version(*args): 36def display_version(*args):
35 print('Metadata Anonymisation Toolkit version %s') % mat.__version__ 37 print('Metadata Anonymisation Toolkit version %s') % mat.__version__
36 print('CLI version %s') % __version__ 38 print('CLI version %s') % __version__
37 print('Hachoir version %s') % hachoir_core.__version__ 39 print('Hachoir version %s') % hachoir_core.__version__
38 sys.exit(0) 40 sys.exit(0)
39 41
42
40def list_meta(class_file, filename): 43def list_meta(class_file, filename):
41 ''' 44 '''
42 Print all the meta of 'filename' on stdout 45 Print all the meta of 'filename' on stdout
43 ''' 46 '''
44 print('[+] File %s :' % filename) 47 print('[+] File %s :' % filename)
45 if class_file.is_clean(): 48 if class_file.is_clean():
@@ -48,18 +51,20 @@ def list_meta(class_file, filename):
48 for key, value in class_file.get_meta().iteritems(): 51 for key, value in class_file.get_meta().iteritems():
49 print(key + ' : ' + str(value)) 52 print(key + ' : ' + str(value))
50 53
54
51def is_clean(class_file, filename): 55def is_clean(class_file, filename):
52 ''' 56 '''
53 Say if 'filename' is clean or not 57 Say if 'filename' is clean or not
54 ''' 58 '''
55 if class_file.is_clean(): 59 if class_file.is_clean():
56 print('[+] %s is clean' % filename) 60 print('[+] %s is clean' % filename)
57 else: 61 else:
58 print('[+] %s is not clean' % filename) 62 print('[+] %s is not clean' % filename)
59 63
64
60def clean_meta(class_file, filename): 65def clean_meta(class_file, filename):
61 ''' 66 '''
62 Clean the file 'filename' 67 Clean the file 'filename'
63 ''' 68 '''
64 print('[+] Cleaning %s' % filename) 69 print('[+] Cleaning %s' % filename)
65 if class_file.is_clean(): 70 if class_file.is_clean():
@@ -68,9 +73,10 @@ def clean_meta(class_file, filename):
68 class_file.remove_all() 73 class_file.remove_all()
69 print('%s cleaned !' % filename) 74 print('%s cleaned !' % filename)
70 75
76
71def clean_meta_ugly(class_file, filename): 77def clean_meta_ugly(class_file, filename):
72 ''' 78 '''
73 Clean the file 'filename', ugly way 79 Clean the file 'filename', ugly way
74 ''' 80 '''
75 print('[+] Cleaning %s' % filename) 81 print('[+] Cleaning %s' % filename)
76 if class_file.is_clean(): 82 if class_file.is_clean():
@@ -79,17 +85,18 @@ def clean_meta_ugly(class_file, filename):
79 class_file.remove_all_ugly() 85 class_file.remove_all_ugly()
80 print('%s cleaned' % filename) 86 print('%s cleaned' % filename)
81 87
88
82def main(): 89def main():
83 args, filenames = parse() 90 args, filenames = parse()
84 91
85 #func receive the function correponding to the options given as parameters 92 #func receive the function correponding to the options given as parameters
86 if args.display is True: #only print metadatas 93 if args.display is True: # only print metadatas
87 func = list_meta 94 func = list_meta
88 elif args.check is True: #only check if the file is clean 95 elif args.check is True: # only check if the file is clean
89 func = is_clean 96 func = is_clean
90 elif args.ugly is True: #destructive anonymisation method 97 elif args.ugly is True: # destructive anonymisation method
91 func = clean_meta_ugly 98 func = clean_meta_ugly
92 else: #clean the file 99 else: # clean the file
93 func = clean_meta 100 func = clean_meta
94 101
95 for filename in filenames: 102 for filename in filenames: