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
d9b8dc27
Kaydet (Commit)
d9b8dc27
authored
Eki 30, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Sade Fark
Merge heads
üst
4659cc07
2b2852b1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
9 deletions
+22
-9
pathlib.py
Lib/pathlib.py
+9
-9
test_pathlib.py
Lib/test/test_pathlib.py
+10
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/pathlib.py
Dosyayı görüntüle @
d9b8dc27
...
...
@@ -8,7 +8,7 @@ import re
import
sys
from
collections
import
Sequence
from
contextlib
import
contextmanager
from
errno
import
EINVAL
,
ENOENT
from
errno
import
EINVAL
,
ENOENT
,
ENOTDIR
from
operator
import
attrgetter
from
stat
import
S_ISDIR
,
S_ISLNK
,
S_ISREG
,
S_ISSOCK
,
S_ISBLK
,
S_ISCHR
,
S_ISFIFO
from
urllib.parse
import
quote_from_bytes
as
urlquote_from_bytes
...
...
@@ -1187,7 +1187,7 @@ class Path(PurePath):
try
:
self
.
stat
()
except
OSError
as
e
:
if
e
.
errno
!=
ENOENT
:
if
e
.
errno
not
in
(
ENOENT
,
ENOTDIR
)
:
raise
return
False
return
True
...
...
@@ -1199,7 +1199,7 @@ class Path(PurePath):
try
:
return
S_ISDIR
(
self
.
stat
()
.
st_mode
)
except
OSError
as
e
:
if
e
.
errno
!=
ENOENT
:
if
e
.
errno
not
in
(
ENOENT
,
ENOTDIR
)
:
raise
# Path doesn't exist or is a broken symlink
# (see https://bitbucket.org/pitrou/pathlib/issue/12/)
...
...
@@ -1213,7 +1213,7 @@ class Path(PurePath):
try
:
return
S_ISREG
(
self
.
stat
()
.
st_mode
)
except
OSError
as
e
:
if
e
.
errno
!=
ENOENT
:
if
e
.
errno
not
in
(
ENOENT
,
ENOTDIR
)
:
raise
# Path doesn't exist or is a broken symlink
# (see https://bitbucket.org/pitrou/pathlib/issue/12/)
...
...
@@ -1226,7 +1226,7 @@ class Path(PurePath):
try
:
return
S_ISLNK
(
self
.
lstat
()
.
st_mode
)
except
OSError
as
e
:
if
e
.
errno
!=
ENOENT
:
if
e
.
errno
not
in
(
ENOENT
,
ENOTDIR
)
:
raise
# Path doesn't exist
return
False
...
...
@@ -1238,7 +1238,7 @@ class Path(PurePath):
try
:
return
S_ISBLK
(
self
.
stat
()
.
st_mode
)
except
OSError
as
e
:
if
e
.
errno
!=
ENOENT
:
if
e
.
errno
not
in
(
ENOENT
,
ENOTDIR
)
:
raise
# Path doesn't exist or is a broken symlink
# (see https://bitbucket.org/pitrou/pathlib/issue/12/)
...
...
@@ -1251,7 +1251,7 @@ class Path(PurePath):
try
:
return
S_ISCHR
(
self
.
stat
()
.
st_mode
)
except
OSError
as
e
:
if
e
.
errno
!=
ENOENT
:
if
e
.
errno
not
in
(
ENOENT
,
ENOTDIR
)
:
raise
# Path doesn't exist or is a broken symlink
# (see https://bitbucket.org/pitrou/pathlib/issue/12/)
...
...
@@ -1264,7 +1264,7 @@ class Path(PurePath):
try
:
return
S_ISFIFO
(
self
.
stat
()
.
st_mode
)
except
OSError
as
e
:
if
e
.
errno
!=
ENOENT
:
if
e
.
errno
not
in
(
ENOENT
,
ENOTDIR
)
:
raise
# Path doesn't exist or is a broken symlink
# (see https://bitbucket.org/pitrou/pathlib/issue/12/)
...
...
@@ -1277,7 +1277,7 @@ class Path(PurePath):
try
:
return
S_ISSOCK
(
self
.
stat
()
.
st_mode
)
except
OSError
as
e
:
if
e
.
errno
!=
ENOENT
:
if
e
.
errno
not
in
(
ENOENT
,
ENOTDIR
)
:
raise
# Path doesn't exist or is a broken symlink
# (see https://bitbucket.org/pitrou/pathlib/issue/12/)
...
...
Lib/test/test_pathlib.py
Dosyayı görüntüle @
d9b8dc27
...
...
@@ -1276,9 +1276,12 @@ class _BasePathTest(object):
self
.
assertIs
(
True
,
p
.
exists
())
self
.
assertIs
(
True
,
(
p
/
'dirA'
)
.
exists
())
self
.
assertIs
(
True
,
(
p
/
'fileA'
)
.
exists
())
self
.
assertIs
(
False
,
(
p
/
'fileA'
/
'bah'
)
.
exists
())
if
not
symlink_skip_reason
:
self
.
assertIs
(
True
,
(
p
/
'linkA'
)
.
exists
())
self
.
assertIs
(
True
,
(
p
/
'linkB'
)
.
exists
())
self
.
assertIs
(
True
,
(
p
/
'linkB'
/
'fileB'
)
.
exists
())
self
.
assertIs
(
False
,
(
p
/
'linkA'
/
'bah'
)
.
exists
())
self
.
assertIs
(
False
,
(
p
/
'foo'
)
.
exists
())
self
.
assertIs
(
False
,
P
(
'/xyzzy'
)
.
exists
())
...
...
@@ -1626,6 +1629,7 @@ class _BasePathTest(object):
self
.
assertTrue
((
P
/
'dirA'
)
.
is_dir
())
self
.
assertFalse
((
P
/
'fileA'
)
.
is_dir
())
self
.
assertFalse
((
P
/
'non-existing'
)
.
is_dir
())
self
.
assertFalse
((
P
/
'fileA'
/
'bah'
)
.
is_dir
())
if
not
symlink_skip_reason
:
self
.
assertFalse
((
P
/
'linkA'
)
.
is_dir
())
self
.
assertTrue
((
P
/
'linkB'
)
.
is_dir
())
...
...
@@ -1636,6 +1640,7 @@ class _BasePathTest(object):
self
.
assertTrue
((
P
/
'fileA'
)
.
is_file
())
self
.
assertFalse
((
P
/
'dirA'
)
.
is_file
())
self
.
assertFalse
((
P
/
'non-existing'
)
.
is_file
())
self
.
assertFalse
((
P
/
'fileA'
/
'bah'
)
.
is_file
())
if
not
symlink_skip_reason
:
self
.
assertTrue
((
P
/
'linkA'
)
.
is_file
())
self
.
assertFalse
((
P
/
'linkB'
)
.
is_file
())
...
...
@@ -1646,6 +1651,7 @@ class _BasePathTest(object):
self
.
assertFalse
((
P
/
'fileA'
)
.
is_symlink
())
self
.
assertFalse
((
P
/
'dirA'
)
.
is_symlink
())
self
.
assertFalse
((
P
/
'non-existing'
)
.
is_symlink
())
self
.
assertFalse
((
P
/
'fileA'
/
'bah'
)
.
is_symlink
())
if
not
symlink_skip_reason
:
self
.
assertTrue
((
P
/
'linkA'
)
.
is_symlink
())
self
.
assertTrue
((
P
/
'linkB'
)
.
is_symlink
())
...
...
@@ -1656,6 +1662,7 @@ class _BasePathTest(object):
self
.
assertFalse
((
P
/
'fileA'
)
.
is_fifo
())
self
.
assertFalse
((
P
/
'dirA'
)
.
is_fifo
())
self
.
assertFalse
((
P
/
'non-existing'
)
.
is_fifo
())
self
.
assertFalse
((
P
/
'fileA'
/
'bah'
)
.
is_fifo
())
@unittest.skipUnless
(
hasattr
(
os
,
"mkfifo"
),
"os.mkfifo() required"
)
def
test_is_fifo_true
(
self
):
...
...
@@ -1670,6 +1677,7 @@ class _BasePathTest(object):
self
.
assertFalse
((
P
/
'fileA'
)
.
is_socket
())
self
.
assertFalse
((
P
/
'dirA'
)
.
is_socket
())
self
.
assertFalse
((
P
/
'non-existing'
)
.
is_socket
())
self
.
assertFalse
((
P
/
'fileA'
/
'bah'
)
.
is_socket
())
@unittest.skipUnless
(
hasattr
(
socket
,
"AF_UNIX"
),
"Unix sockets required"
)
def
test_is_socket_true
(
self
):
...
...
@@ -1690,12 +1698,14 @@ class _BasePathTest(object):
self
.
assertFalse
((
P
/
'fileA'
)
.
is_block_device
())
self
.
assertFalse
((
P
/
'dirA'
)
.
is_block_device
())
self
.
assertFalse
((
P
/
'non-existing'
)
.
is_block_device
())
self
.
assertFalse
((
P
/
'fileA'
/
'bah'
)
.
is_block_device
())
def
test_is_char_device_false
(
self
):
P
=
self
.
cls
(
BASE
)
self
.
assertFalse
((
P
/
'fileA'
)
.
is_char_device
())
self
.
assertFalse
((
P
/
'dirA'
)
.
is_char_device
())
self
.
assertFalse
((
P
/
'non-existing'
)
.
is_char_device
())
self
.
assertFalse
((
P
/
'fileA'
/
'bah'
)
.
is_char_device
())
def
test_is_char_device_true
(
self
):
# Under Unix, /dev/null should generally be a char device
...
...
Misc/NEWS
Dosyayı görüntüle @
d9b8dc27
...
...
@@ -36,6 +36,9 @@ Library
- Issue #22410: Module level functions in the re module now cache compiled
locale-dependent regular expressions taking into account the locale.
- Issue #22759: Query methods on pathlib.Path() (exists(), is_dir(), etc.)
now return False when the underlying stat call raises NotADirectoryError.
- Issue #8876: distutils now falls back to copying files when hard linking
doesn'
t
work
.
This
allows
use
with
special
filesystems
such
as
VirtualBox
shared
folders
.
...
...
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