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)