From 207847cee737a9a7e227f8e10f8a8477b191f383 Mon Sep 17 00:00:00 2001 From: ianb Date: Sun, 22 May 2005 06:24:33 +0000 Subject: Only find files that are valid Python module names --- paste/docsupport/findmodules.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'paste/docsupport') diff --git a/paste/docsupport/findmodules.py b/paste/docsupport/findmodules.py index 4797310..15a48f3 100644 --- a/paste/docsupport/findmodules.py +++ b/paste/docsupport/findmodules.py @@ -3,8 +3,11 @@ Finds all modules in a packages, loads them, and returns them. """ import os +import re from paste.util.import_string import import_module +module_name = re.compile(r'^[a-zA-Z][a-zA-Z0-9_]*$') + def find_modules(package): pkg_name = package.__name__ modules = [] @@ -15,6 +18,8 @@ def find_modules(package): for module_fn in os.listdir(base): base, ext = os.path.splitext(module_fn) full = os.path.join(base, module_fn) + if not module_name.search(base): + continue if (os.path.isdir(full) and os.path.exists(os.path.join(full, '__ini__.py'))): modules.extend(import_module(pkg_name + '.' + base)) -- cgit v1.2.1