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
914973a0
Kaydet (Commit)
914973a0
authored
Şub 24, 1994
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added __repr__ to addbase class; delete more objects
üst
d5b9ea1c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
6 deletions
+10
-6
urlopen.py
Lib/urlopen.py
+10
-6
No files found.
Lib/urlopen.py
Dosyayı görüntüle @
914973a0
...
...
@@ -48,8 +48,8 @@ class URLopener:
# Constructor
def
__init__
(
self
):
self
.
addheaders
=
[]
self
.
ftpcache
=
ftpcache
self
.
tempfiles
=
[]
self
.
ftpcache
=
ftpcache
# Undocumented feature: you can use a different
# ftp cache by assigning to the .ftpcache member;
# in case you want logically independent URL openers
...
...
@@ -84,9 +84,8 @@ class URLopener:
name
=
regsub
.
gsub
(
'-'
,
'_'
,
name
)
if
not
hasattr
(
self
,
name
):
raise
IOError
,
(
'url error'
,
'unknown url type'
,
type
)
meth
=
getattr
(
self
,
name
)
try
:
return
meth
(
url
)
return
getattr
(
self
,
name
)
(
url
)
except
socket
.
error
,
msg
:
raise
IOError
,
(
'socket error'
,
msg
)
...
...
@@ -98,6 +97,7 @@ class URLopener:
if
not
type
or
type
==
'file'
:
try
:
fp
=
self
.
open_local_file
(
url1
)
del
fp
return
splithost
(
url1
)[
1
],
None
except
IOError
,
msg
:
pass
...
...
@@ -112,8 +112,8 @@ class URLopener:
tfp
.
write
(
block
)
block
=
fp
.
read
(
bs
)
headers
=
fp
.
info
()
fp
.
close
()
tfp
.
close
()
del
fp
del
tfp
return
tfn
,
headers
# Each method named open_<type> knows how to open that type of URL
...
...
@@ -258,6 +258,9 @@ class addbase:
self
.
readline
=
self
.
fp
.
readline
self
.
readlines
=
self
.
fp
.
readlines
self
.
fileno
=
self
.
fp
.
fileno
def
__repr__
(
self
):
return
'<
%
s at
%
s whose fp =
%
s>'
%
(
self
.
__class__
.
__name__
,
`id(self)`
,
`self.fp`
)
def
__del__
(
self
):
self
.
close
()
def
close
(
self
):
...
...
@@ -265,7 +268,6 @@ class addbase:
self
.
readline
=
None
self
.
readlines
=
None
self
.
fileno
=
None
self
.
fp
.
close
()
self
.
fp
=
None
# Class to add a close hook to an open file
...
...
@@ -363,7 +365,9 @@ def test():
print
'======'
fp
=
open
(
fn
,
'r'
)
data
=
fp
.
read
()
del
fp
print
regsub
.
gsub
(
'
\r
'
,
''
,
data
)
fn
,
h
=
None
,
None
print
'-'
*
40
finally
:
_urlopener
.
cleanup
()
...
...
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