Skip to content
Snippets Groups Projects
Commit 7b0a27ce authored by Julien (jvoisin) Voisin's avatar Julien (jvoisin) Voisin
Browse files

Don't process unsupported filenames with a known mimetype

parent 94afdd97
No related branches found
No related tags found
No related merge requests found
import os
import mimetypes import mimetypes
import importlib import importlib
import pkgutil import pkgutil
...@@ -26,8 +27,14 @@ def _get_parsers() -> list: ...@@ -26,8 +27,14 @@ def _get_parsers() -> list:
def get_parser(filename: str) -> (T, str): def get_parser(filename: str) -> (T, str):
mtype, _ = mimetypes.guess_type(filename) # 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'])
_, extension = os.path.splitext(filename)
if extension in unknown_extensions:
return None, mtype
mtype, _ = mimetypes.guess_type(filename)
for c in _get_parsers(): for c in _get_parsers():
if mtype in c.mimetypes: if mtype in c.mimetypes:
try: try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment