summaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/main.py b/main.py
index be2508e..2cb05ff 100755
--- a/main.py
+++ b/main.py
@@ -31,6 +31,8 @@ def create_arg_parser():
31 help='list all supported fileformats') 31 help='list all supported fileformats')
32 info.add_argument('-s', '--show', action='store_true', 32 info.add_argument('-s', '--show', action='store_true',
33 help='list all the harmful metadata of a file without removing them') 33 help='list all the harmful metadata of a file without removing them')
34 info.add_argument('-L', '--lightweight', action='store_true',
35 help='remove SOME metadata')
34 return parser 36 return parser
35 37
36 38
@@ -50,7 +52,7 @@ def show_meta(filename:str):
50 print(" %s: harmful content" % k) 52 print(" %s: harmful content" % k)
51 53
52 54
53def clean_meta(filename:str): 55def clean_meta(filename:str, is_lightweigth:bool):
54 if not __check_file(filename, os.R_OK|os.W_OK): 56 if not __check_file(filename, os.R_OK|os.W_OK):
55 return 57 return
56 58
@@ -58,7 +60,10 @@ def clean_meta(filename:str):
58 if p is None: 60 if p is None:
59 print("[-] %s's format (%s) is not supported" % (filename, mtype)) 61 print("[-] %s's format (%s) is not supported" % (filename, mtype))
60 return 62 return
61 p.remove_all() 63 if is_lightweigth:
64 p.remove_all_lightweight()
65 else:
66 p.remove_all()
62 67
63 68
64def show_parsers(): 69def show_parsers():
@@ -78,12 +83,12 @@ def __get_files_recursively(files):
78 for _f in _files: 83 for _f in _files:
79 yield os.path.join(path, _f) 84 yield os.path.join(path, _f)
80 85
81def __do_clean_async(q): 86def __do_clean_async(is_lightweigth, q):
82 while True: 87 while True:
83 f = q.get() 88 f = q.get()
84 if f is None: # nothing more to process 89 if f is None: # nothing more to process
85 return 90 return
86 clean_meta(f) 91 clean_meta(is_lightweigth, f)
87 q.task_done() 92 q.task_done()
88 93
89 94
@@ -109,7 +114,7 @@ def main():
109 q.put(f) 114 q.put(f)
110 115
111 for _ in range(multiprocessing.cpu_count()): 116 for _ in range(multiprocessing.cpu_count()):
112 worker = Thread(target=__do_clean_async, args=(q, )) 117 worker = Thread(target=__do_clean_async, args=(mode, q))
113 worker.start() 118 worker.start()
114 threads.append(worker) 119 threads.append(worker)
115 120