我们从Python开源项目中,提取了以下38个代码示例,用于说明如何使用werkzeug.utils.find_modules()。
def register_blueprints(root, app): """ ???? :param root: ???????? :param app: app?? :return: """ for name in find_modules(root, recursive=True): mod = import_string(name) if hasattr(mod, 'bp'): urls = name.split('.') if hasattr(mod, 'prefix'): prefix = mod.prefix else: prefix = '/{}'.format(urls[-1]) app.register_blueprint(mod.bp, url_prefix=prefix)
def iter_suites(): """Yields all testsuites.""" for module in find_modules(__name__): mod = import_string(module) if hasattr(mod, 'suite'): yield mod.suite()
def register_blueprints(): modules = find_modules('fastapi.api', recursive=True) for name in modules: module = import_string(name) if hasattr(module, 'bp'): app.register_blueprint(module.bp)
def test_find_modules(self): self.assert_equal(list(utils.find_modules('werkzeug.debug')), \ ['werkzeug.debug.console', 'werkzeug.debug.repr', 'werkzeug.debug.tbtools'])
def iter_suites(package): """Yields all testsuites.""" for module in find_modules(package, include_packages=True): mod = __import__(module, fromlist=['*']) if hasattr(mod, 'suite'): yield mod.suite()
def mount_sites(self, root): for name in find_modules(root, recursive=True): mod = import_string(name) site = name.split('.')[-1] if hasattr(mod, 'site') and site not in self.ignore_sites: mod.site.play_actions(target=self)
def register_blueprints(app): """Register all blueprint modules.""" for name in find_modules('raspweb.blueprints'): mod = import_string(name) if hasattr(mod, 'bp'): app.register_blueprint(mod.bp) return None