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
c341c62e
Kaydet (Commit)
c341c62e
authored
Mar 27, 1992
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Search through the module search path.
Add a warning to the top that this is the case.
üst
b5a40dca
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
11 deletions
+30
-11
linecache.py
Lib/linecache.py
+30
-11
No files found.
Lib/linecache.py
Dosyayı görüntüle @
c341c62e
# Cache lines from files.
# Cache lines from files.
# This is intended to read lines from modules imported -- hence if a filename
# is not found, it will look down the module search path for a file by
# that name.
import
sys
import
os
import
os
from
stat
import
*
from
stat
import
*
...
@@ -34,12 +38,13 @@ def getlines(filename):
...
@@ -34,12 +38,13 @@ def getlines(filename):
# Discard cache entries that are out of date.
# Discard cache entries that are out of date.
# (This is not checked upon each call
# (This is not checked upon each call
!)
def
checkcache
():
def
checkcache
():
for
filename
in
cache
.
keys
():
for
filename
in
cache
.
keys
():
size
,
mtime
,
lines
=
cache
[
filename
]
size
,
mtime
,
lines
,
fullname
=
cache
[
filename
]
try
:
stat
=
os
.
stat
(
filename
)
try
:
stat
=
os
.
stat
(
fullname
)
except
os
.
error
:
except
os
.
error
:
del
cache
[
filename
]
del
cache
[
filename
]
continue
continue
...
@@ -52,20 +57,34 @@ def checkcache():
...
@@ -52,20 +57,34 @@ def checkcache():
# and return an empty list.
# and return an empty list.
def
updatecache
(
filename
):
def
updatecache
(
filename
):
try
:
del
cache
[
filename
]
if
cache
.
has_key
(
filename
):
except
KeyError
:
pass
del
cache
[
filename
]
try
:
stat
=
os
.
stat
(
filename
)
if
filename
[
0
]
+
filename
[
-
1
]
==
'<>'
:
return
[]
fullname
=
filename
try
:
stat
=
os
.
stat
(
fullname
)
except
os
.
error
,
msg
:
except
os
.
error
,
msg
:
if
filename
[
0
]
+
filename
[
-
1
]
<>
'<>'
:
# Try looking through the module search path
basename
=
os
.
path
.
split
(
filename
)[
1
]
for
dirname
in
sys
.
path
:
fullname
=
os
.
path
.
join
(
dirname
,
basename
)
try
:
stat
=
os
.
stat
(
fullname
)
break
except
os
.
error
:
pass
else
:
# No luck
print
'*** Cannot stat'
,
filename
,
':'
,
msg
print
'*** Cannot stat'
,
filename
,
':'
,
msg
return
[]
return
[]
try
:
try
:
fp
=
open
(
f
ile
name
,
'r'
)
fp
=
open
(
f
ull
name
,
'r'
)
lines
=
fp
.
readlines
()
lines
=
fp
.
readlines
()
fp
.
close
()
fp
.
close
()
except
IOError
,
msg
:
except
IOError
,
msg
:
print
'*** Cannot open'
,
f
ile
name
,
':'
,
msg
print
'*** Cannot open'
,
f
ull
name
,
':'
,
msg
return
[]
return
[]
size
,
mtime
=
stat
[
ST_SIZE
],
stat
[
ST_MTIME
]
size
,
mtime
=
stat
[
ST_SIZE
],
stat
[
ST_MTIME
]
cache
[
filename
]
=
size
,
mtime
,
lines
cache
[
filename
]
=
size
,
mtime
,
lines
,
fullname
return
lines
return
lines
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