diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2013-05-13 10:35:38 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2013-05-13 10:35:38 -0700 |
commit | eb0832e3795e751b64f813f11b3a3ac03631b0bc (patch) | |
tree | 52cd53c137944c1ce4f654c4ae09886f08d2eac7 /lib | |
parent | b2f78ef78ebf926605a3fcf194b72f405b16a8b0 (diff) | |
download | spack-eb0832e3795e751b64f813f11b3a3ac03631b0bc.tar.gz spack-eb0832e3795e751b64f813f11b3a3ac03631b0bc.tar.bz2 spack-eb0832e3795e751b64f813f11b3a3ac03631b0bc.tar.xz spack-eb0832e3795e751b64f813f11b3a3ac03631b0bc.zip |
list_modules will now find directories.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/utils.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/spack/spack/utils.py b/lib/spack/spack/utils.py index 465c83caf9..2781262b5a 100644 --- a/lib/spack/spack/utils.py +++ b/lib/spack/spack/utils.py @@ -1,7 +1,6 @@ import os import re import errno -import glob import shutil import subprocess import multiprocessing @@ -39,9 +38,17 @@ def install(src, dest): def list_modules(directory): """Lists all of the modules, excluding __init__.py, in a particular directory.""" - os.chdir(directory) - for name in glob.glob("*.py"): - if name != '__init__.py': + for name in os.listdir(directory): + if name == '__init__.py': + continue + + path = new_path(directory, name) + if os.path.isdir(path): + init_py = new_path(path, '__init__.py') + if os.path.isfile(init_py): + yield name + + elif name.endswith('.py'): yield re.sub('.py$', '', name) |