get_parse needs to explore subclasses recusively
This commit is contained in:
parent
04a0032e9f
commit
76f25212d1
@ -18,7 +18,10 @@ for module_loader, name, ispkg in pkgutil.walk_packages('.src'):
|
|||||||
|
|
||||||
def get_parser(filename: str) -> (T, str):
|
def get_parser(filename: str) -> (T, str):
|
||||||
mtype, _ = mimetypes.guess_type(filename)
|
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:
|
if mtype in c.mimetypes:
|
||||||
return c(filename), mtype
|
return c(filename), mtype
|
||||||
return None, mtype
|
return None, mtype
|
||||||
|
Loading…
Reference in New Issue
Block a user