diff options
| author | jvoisin | 2018-05-16 22:00:37 +0200 |
|---|---|---|
| committer | jvoisin | 2018-05-16 22:00:37 +0200 |
| commit | effe68f08f19ff26c37ede5a7a92d5d4452434fe (patch) | |
| tree | dec62d6d94236380cf2597fc083ea3f450d56f46 /main.py | |
| parent | 7afff93e9c5f04b72725c0008cbf5657a0497be0 (diff) | |
The CLI shouldn't display unsupported file extensions
Diffstat (limited to 'main.py')
| -rwxr-xr-x | main.py | 13 |
1 files changed, 10 insertions, 3 deletions
| @@ -8,7 +8,7 @@ import mimetypes | |||
| 8 | import argparse | 8 | import argparse |
| 9 | import multiprocessing | 9 | import multiprocessing |
| 10 | 10 | ||
| 11 | from src import parser_factory | 11 | from src import parser_factory, unsupported_extensions |
| 12 | 12 | ||
| 13 | __version__ = '0.1.0' | 13 | __version__ = '0.1.0' |
| 14 | 14 | ||
| @@ -74,8 +74,15 @@ def show_parsers(): | |||
| 74 | print('[+] Supported formats:') | 74 | print('[+] Supported formats:') |
| 75 | for parser in parser_factory._get_parsers(): | 75 | for parser in parser_factory._get_parsers(): |
| 76 | for mtype in parser.mimetypes: | 76 | for mtype in parser.mimetypes: |
| 77 | extensions = ', '.join(mimetypes.guess_all_extensions(mtype)) | 77 | extensions = set() |
| 78 | print(' - %s (%s)' % (mtype, extensions)) | 78 | for extension in mimetypes.guess_all_extensions(mtype): |
| 79 | if extension[1:] not in unsupported_extensions: # skip the dot | ||
| 80 | extensions.add(extension) | ||
| 81 | if not extensions: | ||
| 82 | # we're not supporting a single extension in the current | ||
| 83 | # mimetype, so there is not point in showing the mimetype at all | ||
| 84 | continue | ||
| 85 | print(' - %s (%s)' % (mtype, ', '.join(extensions))) | ||
| 79 | 86 | ||
| 80 | 87 | ||
| 81 | def __get_files_recursively(files): | 88 | def __get_files_recursively(files): |
