Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
79ae9671
Kaydet (Commit)
79ae9671
authored
Eyl 02, 2016
tarafından
Jason R. Coombs
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #12885: Revert commits in 3.4 branch which is security-only fixes.
üst
6f5d3fd4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
69 deletions
+29
-69
filelist.py
Lib/distutils/filelist.py
+27
-21
test_filelist.py
Lib/distutils/tests/test_filelist.py
+2
-46
NEWS
Misc/NEWS
+0
-2
No files found.
Lib/distutils/filelist.py
Dosyayı görüntüle @
79ae9671
...
...
@@ -6,7 +6,6 @@ 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
...
...
@@ -243,28 +242,35 @@ 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').
"""
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
)
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
def
glob_to_re
(
pattern
):
...
...
Lib/distutils/tests/test_filelist.py
Dosyayı görüntüle @
79ae9671
...
...
@@ -6,10 +6,8 @@ from distutils import debug
from
distutils.log
import
WARN
from
distutils.errors
import
DistutilsTemplateError
from
distutils.filelist
import
glob_to_re
,
translate_pattern
,
FileList
from
distutils
import
filelist
import
test.support
from
test.support
import
captured_stdout
,
run_unittest
from
test.support
import
captured_stdout
from
distutils.tests
import
support
MANIFEST_IN
=
"""
\
...
...
@@ -294,47 +292,5 @@ class FileListTestCase(support.LoggingSilencer,
self
.
assertWarnings
()
class
FindAllTestCase
(
unittest
.
TestCase
):
@test.support.skip_unless_symlink
def
test_missing_symlink
(
self
):
with
test
.
support
.
temp_cwd
():
os
.
symlink
(
'foo'
,
'bar'
)
self
.
assertEqual
(
filelist
.
findall
(),
[])
def
test_basic_discovery
(
self
):
"""
When findall is called with no parameters or with
'.' as the parameter, the dot should be omitted from
the results.
"""
with
test
.
support
.
temp_cwd
():
os
.
mkdir
(
'foo'
)
file1
=
os
.
path
.
join
(
'foo'
,
'file1.txt'
)
test
.
support
.
create_empty_file
(
file1
)
os
.
mkdir
(
'bar'
)
file2
=
os
.
path
.
join
(
'bar'
,
'file2.txt'
)
test
.
support
.
create_empty_file
(
file2
)
expected
=
[
file2
,
file1
]
self
.
assertEqual
(
sorted
(
filelist
.
findall
()),
expected
)
def
test_non_local_discovery
(
self
):
"""
When findall is called with another path, the full
path name should be returned.
"""
with
test
.
support
.
temp_dir
()
as
temp_dir
:
file1
=
os
.
path
.
join
(
temp_dir
,
'file1.txt'
)
test
.
support
.
create_empty_file
(
file1
)
expected
=
[
file1
]
self
.
assertEqual
(
filelist
.
findall
(
temp_dir
),
expected
)
def
test_suite
():
return
unittest
.
TestSuite
([
unittest
.
makeSuite
(
FileListTestCase
),
unittest
.
makeSuite
(
FindAllTestCase
),
])
if
__name__
==
"__main__"
:
run_unittest
(
test_suite
()
)
unittest
.
main
(
)
Misc/NEWS
Dosyayı görüntüle @
79ae9671
...
...
@@ -13,8 +13,6 @@ Core and Builtins
Library
-------
- Issue #12885: Fix error when distutils encounters symlink.
- In the curses module, raise an error if window.getstr() or window.instr() is
passed a negative value.
...
...
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