Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9a577c98
Commit
9a577c98
authored
Sep 19, 2015
by
Jason R. Coombs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #12285: Replace implementation of findall with implementation from Setuptools 7ce820d524db.
parent
c073f121
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
27 deletions
+21
-27
Lib/distutils/filelist.py
Lib/distutils/filelist.py
+21
-27
No files found.
Lib/distutils/filelist.py
View file @
9a577c98
...
...
@@ -6,6 +6,7 @@ and building lists of files.
import
os
,
re
import
fnmatch
import
functools
from
distutils.util
import
convert_path
from
distutils.errors
import
DistutilsTemplateError
,
DistutilsInternalError
from
distutils
import
log
...
...
@@ -242,35 +243,28 @@ class FileList:
# ----------------------------------------------------------------------
# Utility functions
def
_find_all_simple
(
path
):
"""
Find all files under 'path'
"""
results
=
(
os
.
path
.
join
(
base
,
file
)
for
base
,
dirs
,
files
in
os
.
walk
(
path
,
followlinks
=
True
)
for
file
in
files
)
return
filter
(
os
.
path
.
isfile
,
results
)
def
findall
(
dir
=
os
.
curdir
):
"""Find all files under 'dir' and return the list of full filenames
(relative to 'dir').
"""
from
stat
import
ST_MODE
,
S_ISREG
,
S_ISDIR
,
S_ISLNK
list
=
[]
stack
=
[
dir
]
pop
=
stack
.
pop
push
=
stack
.
append
while
stack
:
dir
=
pop
()
names
=
os
.
listdir
(
dir
)
for
name
in
names
:
if
dir
!=
os
.
curdir
:
# avoid the dreaded "./" syndrome
fullname
=
os
.
path
.
join
(
dir
,
name
)
else
:
fullname
=
name
# Avoid excess stat calls -- just one will do, thank you!
stat
=
os
.
stat
(
fullname
)
mode
=
stat
[
ST_MODE
]
if
S_ISREG
(
mode
):
list
.
append
(
fullname
)
elif
S_ISDIR
(
mode
)
and
not
S_ISLNK
(
mode
):
push
(
fullname
)
return
list
Find all files under 'dir' and return the list of full filenames.
Unless dir is '.', return full filenames with dir prepended.
"""
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
)
def
glob_to_re
(
pattern
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment