aboutsummaryrefslogtreecommitdiffstats
path: root/setuptools
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2015-09-07 01:16:14 -0400
committerJason R. Coombs <jaraco@jaraco.com>2015-09-07 01:16:14 -0400
commit38a40150670a18742a85435ed2baba422c002a68 (patch)
tree8c534a94fe2b154744ee5ad5b453221b22bcdef8 /setuptools
parent32a47417750420524e1270cc5e3fc749eb9e5a89 (diff)
downloadexternal_python_setuptools-38a40150670a18742a85435ed2baba422c002a68.tar.gz
external_python_setuptools-38a40150670a18742a85435ed2baba422c002a68.tar.bz2
external_python_setuptools-38a40150670a18742a85435ed2baba422c002a68.zip
Another refactor of findall, this time separating the simple walk / join operation from the conditional relative path.
Diffstat (limited to 'setuptools')
-rw-r--r--setuptools/__init__.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/setuptools/__init__.py b/setuptools/__init__.py
index 49002619..a7d75ed4 100644
--- a/setuptools/__init__.py
+++ b/setuptools/__init__.py
@@ -139,22 +139,29 @@ class Command(_Command):
# we can't patch distutils.cmd, alas
distutils.core.Command = Command
+
+def _find_all_simple(path):
+ """
+ Find all files under 'path'
+ """
+ return (
+ os.path.join(base, file)
+ for base, dirs, files in os.walk(path, followlinks=True)
+ for file in files
+ )
+
+
def findall(dir=os.curdir):
"""
Find all files under 'dir' and return the list of full filenames.
Unless dir is '.', return full filenames with dir prepended.
"""
- def _prepend(base):
- if base == os.curdir or base.startswith(os.curdir + os.sep):
- base = base[2:]
- return functools.partial(os.path.join, base)
-
- return [
- file
- for base, dirs, files in os.walk(dir, followlinks=True)
- for file in map(_prepend(base), files)
- if os.path.isfile(file)
- ]
+ files = _find_all_simple(dir)
+ if dir == os.curdir:
+ make_rel = functools.partial(os.path.relpath, start=dir)
+ files = map(make_rel, files)
+ return list(files)
+
# fix findall bug in distutils (http://bugs.python.org/issue12885)
distutils.filelist.findall = findall