main.py is now correctly handling folders
This commit is contained in:
parent
d3b1eabe07
commit
972de8469e
40
main.py
40
main.py
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import mimetypes
|
import mimetypes
|
||||||
@ -54,24 +55,39 @@ def clean_meta(filename:str):
|
|||||||
return
|
return
|
||||||
p.remove_all()
|
p.remove_all()
|
||||||
|
|
||||||
def main():
|
def show_parsers():
|
||||||
arg_parser = create_arg_parser()
|
|
||||||
args = arg_parser.parse_args()
|
|
||||||
|
|
||||||
if args.show:
|
|
||||||
for f in args.files:
|
|
||||||
show_meta(f)
|
|
||||||
elif args.list:
|
|
||||||
print('[+] Supported formats:')
|
print('[+] Supported formats:')
|
||||||
for parser in parser_factory._get_parsers():
|
for parser in parser_factory._get_parsers():
|
||||||
for mtype in parser.mimetypes:
|
for mtype in parser.mimetypes:
|
||||||
extensions = ', '.join(mimetypes.guess_all_extensions(mtype))
|
extensions = ', '.join(mimetypes.guess_all_extensions(mtype))
|
||||||
print(' - %s (%s)' % (mtype, extensions))
|
print(' - %s (%s)' % (mtype, extensions))
|
||||||
elif args.files:
|
|
||||||
for f in args.files:
|
def __get_files_recursively(files):
|
||||||
clean_meta(f)
|
for f in files:
|
||||||
|
if os.path.isfile(f):
|
||||||
|
yield f
|
||||||
else:
|
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__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user