diff options
| author | Jason R. Coombs <jaraco@jaraco.com> | 2015-08-07 14:06:28 -0400 |
|---|---|---|
| committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-08-07 14:06:28 -0400 |
| commit | 504d4012293d09847e02d5aa5b495db730077f4f (patch) | |
| tree | 8b9f5aac7e9300cb8c6a529a4f4f2860a3cfe988 /setuptools/__init__.py | |
| parent | 565dd0699befdc1d27db05fc56c5215f3590567a (diff) | |
| download | python-setuptools-git-504d4012293d09847e02d5aa5b495db730077f4f.tar.gz | |
Remove unused _all_dirs. Prefer 'candidate' to 'suitable'. Update documentation.
Diffstat (limited to 'setuptools/__init__.py')
| -rw-r--r-- | setuptools/__init__.py | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py index f6536359..2c492446 100644 --- a/setuptools/__init__.py +++ b/setuptools/__init__.py @@ -73,31 +73,24 @@ class PackageFinder(object): yield pkg @staticmethod - def _all_dirs(base_path): + def _candidate_dirs(base_path): """ - Return all dirs in base_path, relative to base_path + Return all dirs in base_path that might be packages. """ + has_dot = lambda name: '.' in name for root, dirs, files in os.walk(base_path, followlinks=True): - for dir in dirs: - yield os.path.relpath(os.path.join(root, dir), base_path) - - @staticmethod - def _suitable_dirs(base_path): - """ - Return all suitable package dirs in base_path, relative to base_path - """ - for root, dirs, files in os.walk(base_path, followlinks=True): - # Mutate dirs to trim the search: - dirs[:] = filterfalse(lambda n: '.' in n, dirs) + # Exclude directories that contain a period, as they cannot be + # packages. Mutate the list to avoid traversal. + dirs[:] = filterfalse(has_dot, dirs) for dir in dirs: yield os.path.relpath(os.path.join(root, dir), base_path) @classmethod def _find_packages_iter(cls, base_path): - suitable = cls._suitable_dirs(base_path) + candidates = cls._candidate_dirs(base_path) return ( path.replace(os.path.sep, '.') - for path in suitable + for path in candidates if cls._looks_like_package(os.path.join(base_path, path)) ) |
