list_modules will now find directories.

This commit is contained in:
Todd Gamblin 2013-05-13 10:35:38 -07:00
parent b2f78ef78e
commit eb0832e379

View file

@ -1,7 +1,6 @@
import os import os
import re import re
import errno import errno
import glob
import shutil import shutil
import subprocess import subprocess
import multiprocessing import multiprocessing
@ -39,9 +38,17 @@ def install(src, dest):
def list_modules(directory): def list_modules(directory):
"""Lists all of the modules, excluding __init__.py, in """Lists all of the modules, excluding __init__.py, in
a particular directory.""" a particular directory."""
os.chdir(directory) for name in os.listdir(directory):
for name in glob.glob("*.py"): if name == '__init__.py':
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) yield re.sub('.py$', '', name)