From 75a6e6215188246a3666d9e5e8952a4b266f365d Mon Sep 17 00:00:00 2001 From: Jeffrey Marvin Forones Date: Fri, 19 Oct 2018 10:25:09 +0800 Subject: [PATCH] ignore_names parameter feed with paths, added path serializer that returns expected paths required --- flask_blueprint/package_extractor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/flask_blueprint/package_extractor.py b/flask_blueprint/package_extractor.py index 577dec1..65bc2f3 100644 --- a/flask_blueprint/package_extractor.py +++ b/flask_blueprint/package_extractor.py @@ -51,8 +51,10 @@ def __extract_packages(self, packages): else: raise TypeError("package should be a generator type") - """ extract modules from the package""" + def __serialize_module_paths(self): + return list(set([path.split("/")[-1:][0] for path in self.paths])) + """ extract modules from the package""" def __extract_modules(self, loader, name, is_pkg): """ if module found load module and save all attributes in the module found """ @@ -62,7 +64,7 @@ def __extract_modules(self, loader, name, is_pkg): if hasattr(mod, '__method__'): """ register to the blueprint if method attribute found """ - module_router = ModuleRouter(mod).register_route(app=self.application, name=name) + module_router = ModuleRouter(mod, ignore_names=self.__serialize_module_paths()).register_route(app=self.application, name=name) self.__routers.extend(module_router.routers) self.__modules.append(mod)