From 76f25212d1eef99c360b0a50cd5b88c117acf278 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Tue, 3 Apr 2018 00:05:03 +0200 Subject: [PATCH] get_parse needs to explore subclasses recusively --- src/parser_factory.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/parser_factory.py b/src/parser_factory.py index 7fd42d7..770f17c 100644 --- a/src/parser_factory.py +++ b/src/parser_factory.py @@ -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