diff options
| author | ianb <devnull@localhost> | 2005-05-22 06:24:33 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2005-05-22 06:24:33 +0000 |
| commit | 207847cee737a9a7e227f8e10f8a8477b191f383 (patch) | |
| tree | e5c4ae619aedcacdfef77702b9661059769efdf1 /paste/docsupport | |
| parent | f794ebdee56b5a293b6c5fa3e4128b3d2648449b (diff) | |
| download | paste-207847cee737a9a7e227f8e10f8a8477b191f383.tar.gz | |
Only find files that are valid Python module names
Diffstat (limited to 'paste/docsupport')
| -rw-r--r-- | paste/docsupport/findmodules.py | 5 |
1 files changed, 5 insertions, 0 deletions
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)) |
