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
88bc0d26
Kaydet (Commit)
88bc0d26
authored
Haz 23, 2012
tarafından
Philip Jenvey
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
small refactor and PEP8 line width/docstring
üst
66a3a7ed
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
9 deletions
+13
-9
shutil.py
Lib/shutil.py
+13
-9
No files found.
Lib/shutil.py
Dosyayı görüntüle @
88bc0d26
...
@@ -1037,17 +1037,20 @@ def get_terminal_size(fallback=(80, 24)):
...
@@ -1037,17 +1037,20 @@ def get_terminal_size(fallback=(80, 24)):
def
which
(
cmd
,
mode
=
os
.
F_OK
|
os
.
X_OK
,
path
=
None
):
def
which
(
cmd
,
mode
=
os
.
F_OK
|
os
.
X_OK
,
path
=
None
):
"""Given a command, mode, and a PATH string, return the path which
"""Given a command, mode, and a PATH string, return the path which
conforms to the given mode on the PATH, or None if there is no such file.
conforms to the given mode on the PATH, or None if there is no such
`mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of
file.
os.environ.get("PATH"), or can be overridden with a custom search path."""
`mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result
of os.environ.get("PATH"), or can be overridden with a custom search
path.
"""
# Check that a given file can be accessed with the correct mode.
# Check that a given file can be accessed with the correct mode.
# Additionally check that `file` is not a directory, as on Windows
# Additionally check that `file` is not a directory, as on Windows
# directories pass the os.access check.
# directories pass the os.access check.
def
_access_check
(
fn
,
mode
):
def
_access_check
(
fn
,
mode
):
if
(
os
.
path
.
exists
(
fn
)
and
os
.
access
(
fn
,
mode
)
return
(
os
.
path
.
exists
(
fn
)
and
os
.
access
(
fn
,
mode
)
and
not
os
.
path
.
isdir
(
fn
)):
and
not
os
.
path
.
isdir
(
fn
))
return
True
return
False
# Short circuit. If we're given a full path which matches the mode
# Short circuit. If we're given a full path which matches the mode
# and it exists, we're done here.
# and it exists, we're done here.
...
@@ -1066,8 +1069,9 @@ def which(cmd, mode=os.F_OK | os.X_OK, path=None):
...
@@ -1066,8 +1069,9 @@ def which(cmd, mode=os.F_OK | os.X_OK, path=None):
# See if the given file matches any of the expected path extensions.
# See if the given file matches any of the expected path extensions.
# This will allow us to short circuit when given "python.exe".
# This will allow us to short circuit when given "python.exe".
matches
=
[
cmd
for
ext
in
pathext
if
cmd
.
lower
()
.
endswith
(
ext
.
lower
())]
matches
=
[
cmd
for
ext
in
pathext
if
cmd
.
lower
()
.
endswith
(
ext
.
lower
())]
# If it does match, only test that one, otherwise we have to try others.
# If it does match, only test that one, otherwise we have to try
files
=
[
cmd
+
ext
.
lower
()
for
ext
in
pathext
]
if
not
matches
else
[
cmd
]
# others.
files
=
[
cmd
]
if
matches
else
[
cmd
+
ext
.
lower
()
for
ext
in
pathext
]
else
:
else
:
# On other platforms you don't have things like PATHEXT to tell you
# On other platforms you don't have things like PATHEXT to tell you
# what file suffixes are executable, so just pass on cmd as-is.
# what file suffixes are executable, so just pass on cmd as-is.
...
...
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