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
d3876d33
Kaydet (Commit)
d3876d33
authored
Tem 23, 1996
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Renamed all occurrences of posix to os.
üst
773ab27f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
28 deletions
+33
-28
posixpath.py
Lib/posixpath.py
+33
-28
No files found.
Lib/posixpath.py
Dosyayı görüntüle @
d3876d33
# Module 'posixpath' -- common operations on POSIX pathnames
# Module 'posixpath' -- common operations on Posix pathnames.
# Some of this can actually be useful on non-Posix systems too, e.g.
import
posix
# for manipulation of the pathname component of URLs.
# The "os.path" name is an alias for this module on Posix systems;
# on other systems (e.g. Mac, Windows), os.path provides the same
# operations in a manner specific to that platform, and is an alias
# to another module (e.g. macpath, ntpath).
import
os
import
stat
import
stat
...
@@ -102,12 +108,12 @@ def commonprefix(m):
...
@@ -102,12 +108,12 @@ def commonprefix(m):
# Is a path a symbolic link?
# Is a path a symbolic link?
# This will always return false on systems where
posix
.lstat doesn't exist.
# This will always return false on systems where
os
.lstat doesn't exist.
def
islink
(
path
):
def
islink
(
path
):
try
:
try
:
st
=
posix
.
lstat
(
path
)
st
=
os
.
lstat
(
path
)
except
(
posix
.
error
,
AttributeError
):
except
(
os
.
error
,
AttributeError
):
return
0
return
0
return
stat
.
S_ISLNK
(
st
[
stat
.
ST_MODE
])
return
stat
.
S_ISLNK
(
st
[
stat
.
ST_MODE
])
...
@@ -117,20 +123,20 @@ def islink(path):
...
@@ -117,20 +123,20 @@ def islink(path):
def
exists
(
path
):
def
exists
(
path
):
try
:
try
:
st
=
posix
.
stat
(
path
)
st
=
os
.
stat
(
path
)
except
posix
.
error
:
except
os
.
error
:
return
0
return
0
return
1
return
1
# Is a path a
posix
directory?
# Is a path a directory?
# This follows symbolic links, so both islink() and isdir() can be true
# This follows symbolic links, so both islink() and isdir() can be true
# for the same path.
# for the same path.
def
isdir
(
path
):
def
isdir
(
path
):
try
:
try
:
st
=
posix
.
stat
(
path
)
st
=
os
.
stat
(
path
)
except
posix
.
error
:
except
os
.
error
:
return
0
return
0
return
stat
.
S_ISDIR
(
st
[
stat
.
ST_MODE
])
return
stat
.
S_ISDIR
(
st
[
stat
.
ST_MODE
])
...
@@ -141,8 +147,8 @@ def isdir(path):
...
@@ -141,8 +147,8 @@ def isdir(path):
def
isfile
(
path
):
def
isfile
(
path
):
try
:
try
:
st
=
posix
.
stat
(
path
)
st
=
os
.
stat
(
path
)
except
posix
.
error
:
except
os
.
error
:
return
0
return
0
return
stat
.
S_ISREG
(
st
[
stat
.
ST_MODE
])
return
stat
.
S_ISREG
(
st
[
stat
.
ST_MODE
])
...
@@ -150,18 +156,17 @@ def isfile(path):
...
@@ -150,18 +156,17 @@ def isfile(path):
# Are two filenames really pointing to the same file?
# Are two filenames really pointing to the same file?
def
samefile
(
f1
,
f2
):
def
samefile
(
f1
,
f2
):
s1
=
posix
.
stat
(
f1
)
s1
=
os
.
stat
(
f1
)
s2
=
posix
.
stat
(
f2
)
s2
=
os
.
stat
(
f2
)
return
samestat
(
s1
,
s2
)
return
samestat
(
s1
,
s2
)
# Are two open files really referencing the same file?
# Are two open files really referencing the same file?
# (Not necessarily the same file descriptor!)
# (Not necessarily the same file descriptor!)
# XXX Oops, posix.fstat() doesn't exist yet!
def
sameopenfile
(
fp1
,
fp2
):
def
sameopenfile
(
fp1
,
fp2
):
s1
=
posix
.
fstat
(
fp1
)
s1
=
os
.
fstat
(
fp1
)
s2
=
posix
.
fstat
(
fp2
)
s2
=
os
.
fstat
(
fp2
)
return
samestat
(
s1
,
s2
)
return
samestat
(
s1
,
s2
)
...
@@ -174,13 +179,13 @@ def samestat(s1, s2):
...
@@ -174,13 +179,13 @@ def samestat(s1, s2):
# Is a path a mount point?
# Is a path a mount point?
# (Does this work for all UNIXes? Is it even guaranteed to work by P
OSIX
?)
# (Does this work for all UNIXes? Is it even guaranteed to work by P
osix
?)
def
ismount
(
path
):
def
ismount
(
path
):
try
:
try
:
s1
=
posix
.
stat
(
path
)
s1
=
os
.
stat
(
path
)
s2
=
posix
.
stat
(
join
(
path
,
'..'
))
s2
=
os
.
stat
(
join
(
path
,
'..'
))
except
posix
.
error
:
except
os
.
error
:
return
0
# It doesn't exist -- so not a mount point :-)
return
0
# It doesn't exist -- so not a mount point :-)
dev1
=
s1
[
stat
.
ST_DEV
]
dev1
=
s1
[
stat
.
ST_DEV
]
dev2
=
s2
[
stat
.
ST_DEV
]
dev2
=
s2
[
stat
.
ST_DEV
]
...
@@ -203,8 +208,8 @@ def ismount(path):
...
@@ -203,8 +208,8 @@ def ismount(path):
def
walk
(
top
,
func
,
arg
):
def
walk
(
top
,
func
,
arg
):
try
:
try
:
names
=
posix
.
listdir
(
top
)
names
=
os
.
listdir
(
top
)
except
posix
.
error
:
except
os
.
error
:
return
return
func
(
arg
,
top
,
names
)
func
(
arg
,
top
,
names
)
exceptions
=
(
'.'
,
'..'
)
exceptions
=
(
'.'
,
'..'
)
...
@@ -231,9 +236,9 @@ def expanduser(path):
...
@@ -231,9 +236,9 @@ def expanduser(path):
while
i
<
n
and
path
[
i
]
<>
'/'
:
while
i
<
n
and
path
[
i
]
<>
'/'
:
i
=
i
+
1
i
=
i
+
1
if
i
==
1
:
if
i
==
1
:
if
not
posix
.
environ
.
has_key
(
'HOME'
):
if
not
os
.
environ
.
has_key
(
'HOME'
):
return
path
return
path
userhome
=
posix
.
environ
[
'HOME'
]
userhome
=
os
.
environ
[
'HOME'
]
else
:
else
:
import
pwd
import
pwd
try
:
try
:
...
@@ -267,9 +272,9 @@ def expandvars(path):
...
@@ -267,9 +272,9 @@ def expandvars(path):
j
=
i
+
len
(
_varprog
.
group
(
0
))
j
=
i
+
len
(
_varprog
.
group
(
0
))
if
name
[:
1
]
==
'{'
and
name
[
-
1
:]
==
'}'
:
if
name
[:
1
]
==
'{'
and
name
[
-
1
:]
==
'}'
:
name
=
name
[
1
:
-
1
]
name
=
name
[
1
:
-
1
]
if
posix
.
environ
.
has_key
(
name
):
if
os
.
environ
.
has_key
(
name
):
tail
=
path
[
j
:]
tail
=
path
[
j
:]
path
=
path
[:
i
]
+
posix
.
environ
[
name
]
path
=
path
[:
i
]
+
os
.
environ
[
name
]
i
=
len
(
path
)
i
=
len
(
path
)
path
=
path
+
tail
path
=
path
+
tail
else
:
else
:
...
...
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