Skip to content
Snippets Groups Projects
Commit 76f25212 authored by Loïc Dachary's avatar Loïc Dachary Committed by jvoisin
Browse files

get_parse needs to explore subclasses recusively

parent 04a0032e
No related branches found
No related tags found
No related merge requests found
......@@ -18,7 +18,10 @@ for module_loader, name, ispkg in pkgutil.walk_packages('.src'):
def get_parser(filename: str) -> (T, str):
mtype, _ = mimetypes.guess_type(filename)
for c in abstract.AbstractParser.__subclasses__():
def get_subclasses(cls):
return cls.__subclasses__() + \
[g for s in cls.__subclasses__() for g in get_subclasses(s)]
for c in get_subclasses(abstract.AbstractParser):
if mtype in c.mimetypes:
return c(filename), mtype
return None, mtype
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