From effe68f08f19ff26c37ede5a7a92d5d4452434fe Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 16 May 2018 22:00:37 +0200 Subject: The CLI shouldn't display unsupported file extensions --- src/__init__.py | 6 +++++- src/parser_factory.py | 7 ++----- 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/__init__.py b/src/__init__.py index 7557381..3f5c478 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -1 +1,5 @@ -#!/bin/env python3 \ No newline at end of file +#!/bin/env python3 + +# A set of extension that aren't supported, despite matching a supported mimetype +unsupported_extensions = set(['bat', 'c', 'h', 'ksh', 'pl', 'txt', 'asc', + 'text', 'pot', 'brf', 'srt', 'rdf', 'wsdl', 'xpdl', 'xsl', 'xsd']) diff --git a/src/parser_factory.py b/src/parser_factory.py index a2ff384..2c30659 100644 --- a/src/parser_factory.py +++ b/src/parser_factory.py @@ -3,7 +3,7 @@ import mimetypes import importlib import pkgutil -from . import abstract +from . import abstract, unsupported_extensions from typing import TypeVar @@ -27,13 +27,10 @@ def _get_parsers() -> list: def get_parser(filename: str) -> (T, str): - # A set of extension that aren't supported, despite matching a known mimetype - unknown_extensions = set(['bat', 'c', 'h', 'ksh', 'pl', 'txt', 'asc', - 'text', 'pot', 'brf', 'srt', 'rdf', 'wsdl', 'xpdl', 'xsl', 'xsd']) mtype, _ = mimetypes.guess_type(filename) _, extension = os.path.splitext(filename) - if extension in unknown_extensions: + if extension in unsupported_extensions: return None, mtype for c in _get_parsers(): -- cgit v1.3