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
c4a70fbb
Kaydet (Commit)
c4a70fbb
authored
Eyl 05, 2006
tarafından
Tim Peters
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add missing svn:eol-style property to text files.
üst
dd5e7b9a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
77 deletions
+77
-77
genericpath.py
Lib/genericpath.py
+77
-77
No files found.
Lib/genericpath.py
Dosyayı görüntüle @
c4a70fbb
"""
"""
Path operations common to more than one OS
Path operations common to more than one OS
Do not use directly. The OS specific modules import the appropriate
Do not use directly. The OS specific modules import the appropriate
functions from this module themselves.
functions from this module themselves.
"""
"""
import
os
import
os
import
stat
import
stat
__all__
=
[
'commonprefix'
,
'exists'
,
'getatime'
,
'getctime'
,
'getmtime'
,
__all__
=
[
'commonprefix'
,
'exists'
,
'getatime'
,
'getctime'
,
'getmtime'
,
'getsize'
,
'isdir'
,
'isfile'
]
'getsize'
,
'isdir'
,
'isfile'
]
# Does a path exist?
# Does a path exist?
# This is false for dangling symbolic links on systems that support them.
# This is false for dangling symbolic links on systems that support them.
def
exists
(
path
):
def
exists
(
path
):
"""Test whether a path exists. Returns False for broken symbolic links"""
"""Test whether a path exists. Returns False for broken symbolic links"""
try
:
try
:
st
=
os
.
stat
(
path
)
st
=
os
.
stat
(
path
)
except
os
.
error
:
except
os
.
error
:
return
False
return
False
return
True
return
True
# 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 ono systems that support symlinks
# for the same path ono systems that support symlinks
def
isfile
(
path
):
def
isfile
(
path
):
"""Test whether a path is a regular file"""
"""Test whether a path is a regular file"""
try
:
try
:
st
=
os
.
stat
(
path
)
st
=
os
.
stat
(
path
)
except
os
.
error
:
except
os
.
error
:
return
False
return
False
return
stat
.
S_ISREG
(
st
.
st_mode
)
return
stat
.
S_ISREG
(
st
.
st_mode
)
# Is a path a directory?
# Is a path a directory?
# This follows symbolic links, so both islink() and isdir()
# This follows symbolic links, so both islink() and isdir()
# can be true for the same path on systems that support symlinks
# can be true for the same path on systems that support symlinks
def
isdir
(
s
):
def
isdir
(
s
):
"""Return true if the pathname refers to an existing directory."""
"""Return true if the pathname refers to an existing directory."""
try
:
try
:
st
=
os
.
stat
(
s
)
st
=
os
.
stat
(
s
)
except
os
.
error
:
except
os
.
error
:
return
False
return
False
return
stat
.
S_ISDIR
(
st
.
st_mode
)
return
stat
.
S_ISDIR
(
st
.
st_mode
)
def
getsize
(
filename
):
def
getsize
(
filename
):
"""Return the size of a file, reported by os.stat()."""
"""Return the size of a file, reported by os.stat()."""
return
os
.
stat
(
filename
)
.
st_size
return
os
.
stat
(
filename
)
.
st_size
def
getmtime
(
filename
):
def
getmtime
(
filename
):
"""Return the last modification time of a file, reported by os.stat()."""
"""Return the last modification time of a file, reported by os.stat()."""
return
os
.
stat
(
filename
)
.
st_mtime
return
os
.
stat
(
filename
)
.
st_mtime
def
getatime
(
filename
):
def
getatime
(
filename
):
"""Return the last access time of a file, reported by os.stat()."""
"""Return the last access time of a file, reported by os.stat()."""
return
os
.
stat
(
filename
)
.
st_atime
return
os
.
stat
(
filename
)
.
st_atime
def
getctime
(
filename
):
def
getctime
(
filename
):
"""Return the metadata change time of a file, reported by os.stat()."""
"""Return the metadata change time of a file, reported by os.stat()."""
return
os
.
stat
(
filename
)
.
st_ctime
return
os
.
stat
(
filename
)
.
st_ctime
# Return the longest prefix of all list elements.
# Return the longest prefix of all list elements.
def
commonprefix
(
m
):
def
commonprefix
(
m
):
"Given a list of pathnames, returns the longest common leading component"
"Given a list of pathnames, returns the longest common leading component"
if
not
m
:
return
''
if
not
m
:
return
''
s1
=
min
(
m
)
s1
=
min
(
m
)
s2
=
max
(
m
)
s2
=
max
(
m
)
n
=
min
(
len
(
s1
),
len
(
s2
))
n
=
min
(
len
(
s1
),
len
(
s2
))
for
i
in
xrange
(
n
):
for
i
in
xrange
(
n
):
if
s1
[
i
]
!=
s2
[
i
]:
if
s1
[
i
]
!=
s2
[
i
]:
return
s1
[:
i
]
return
s1
[:
i
]
return
s1
[:
n
]
return
s1
[:
n
]
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