Commit 50f98edc authored by Jason R. Coombs's avatar Jason R. Coombs

Extract _looks_like_package

parent 8679c5fa
......@@ -53,22 +53,24 @@ def find_packages(where='.', exclude=(), include=('*',)):
dirs = _dirs(where)
suitable = filterfalse(lambda n: '.' in n, dirs)
paths = (os.path.join(where, name) for name in suitable)
for path in paths:
packages = filter(_looks_like_package, paths)
for path in packages:
name = os.path.basename(path)
looks_like_package = (
os.path.isfile(os.path.join(path, '__init__.py'))
or sys.version_info[:2] >= (3, 3) # PEP 420
)
if looks_like_package:
pkg_name = prefix + name
out.append(pkg_name)
stack.append((path, pkg_name + '.'))
pkg_name = prefix + name
out.append(pkg_name)
stack.append((path, pkg_name + '.'))
includes = _build_filter(*include)
excludes = _build_filter('ez_setup', '*__pycache__', *exclude)
out = filter(includes, out)
out = filterfalse(excludes, out)
return list(out)
def _looks_like_package(path):
return (
os.path.isfile(os.path.join(path, '__init__.py'))
or sys.version_info[:2] >= (3, 3) # PEP 420
)
def _dirs(target):
"""
Return all directories in target
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment