1
0
Fork 0
mirror of synced 2025-07-04 12:27:32 +02:00

Implement mimetype detection

This commit is contained in:
jvoisin 2018-03-19 23:43:49 +01:00
parent d262f780f7
commit 8f44616366
4 changed files with 23 additions and 10 deletions

10
src/parser_factory.py Normal file
View file

@ -0,0 +1,10 @@
import mimetypes
from .parsers import abstract
from .parsers import *
def get_parser(filename: str):
mtype, _ = mimetypes.guess_type(filename)
for c in abstract.AbstractParser.__subclasses__():
if mtype in c.mimetypes:
return c(filename)