1
0
mirror of synced 2024-11-22 09:14:23 +01:00

main.py is now correctly handling folders

This commit is contained in:
jvoisin 2018-04-04 23:15:00 +02:00
parent d3b1eabe07
commit 972de8469e

40
main.py
View File

@ -1,4 +1,5 @@
#!/usr/bin/python3
import os
import sys
import mimetypes
@ -54,24 +55,39 @@ def clean_meta(filename:str):
return
p.remove_all()
def main():
arg_parser = create_arg_parser()
args = arg_parser.parse_args()
if args.show:
for f in args.files:
show_meta(f)
elif args.list:
def show_parsers():
print('[+] Supported formats:')
for parser in parser_factory._get_parsers():
for mtype in parser.mimetypes:
extensions = ', '.join(mimetypes.guess_all_extensions(mtype))
print(' - %s (%s)' % (mtype, extensions))
elif args.files:
for f in args.files:
clean_meta(f)
def __get_files_recursively(files):
for f in files:
if os.path.isfile(f):
yield f
else:
arg_parser.print_help()
for path, _, _files in os.walk(f):
for _f in _files:
yield os.path.join(path, _f)
def main():
arg_parser = create_arg_parser()
args = arg_parser.parse_args()
if not args.files:
if not args.list:
return arg_parser.print_help()
show_parsers()
return
if args.show:
for f in get_files_recursively(args.files):
show_meta(f)
else:
for f in get_files_recursively(args.files):
clean_meta(f)
if __name__ == '__main__':