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
51a43703
Kaydet (Commit)
51a43703
authored
Eki 29, 2014
tarafından
Serhiy Storchaka
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #22217: Implemented reprs of classes in the zipfile module.
üst
659dd625
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
0 deletions
+83
-0
test_zipfile.py
Lib/test/test_zipfile.py
+31
-0
zipfile.py
Lib/zipfile.py
+50
-0
NEWS
Misc/NEWS
+2
-0
No files found.
Lib/test/test_zipfile.py
Dosyayı görüntüle @
51a43703
...
@@ -326,6 +326,37 @@ class AbstractTestsWithSourceFile:
...
@@ -326,6 +326,37 @@ class AbstractTestsWithSourceFile:
while
zipopen
.
read1
(
100
):
while
zipopen
.
read1
(
100
):
pass
pass
def
test_repr
(
self
):
fname
=
'file.name'
for
f
in
get_files
(
self
):
with
zipfile
.
ZipFile
(
f
,
'w'
,
self
.
compression
)
as
zipfp
:
zipfp
.
write
(
TESTFN
,
fname
)
r
=
repr
(
zipfp
)
self
.
assertIn
(
"mode='w'"
,
r
)
with
zipfile
.
ZipFile
(
f
,
'r'
)
as
zipfp
:
r
=
repr
(
zipfp
)
if
isinstance
(
f
,
str
):
self
.
assertIn
(
'filename=
%
r'
%
f
,
r
)
else
:
self
.
assertIn
(
'file=
%
r'
%
f
,
r
)
self
.
assertIn
(
"mode='r'"
,
r
)
r
=
repr
(
zipfp
.
getinfo
(
fname
))
self
.
assertIn
(
'filename=
%
r'
%
fname
,
r
)
self
.
assertIn
(
'filemode='
,
r
)
self
.
assertIn
(
'file_size='
,
r
)
if
self
.
compression
!=
zipfile
.
ZIP_STORED
:
self
.
assertIn
(
'compress_type='
,
r
)
self
.
assertIn
(
'compress_size='
,
r
)
with
zipfp
.
open
(
fname
)
as
zipopen
:
r
=
repr
(
zipopen
)
self
.
assertIn
(
'name=
%
r'
%
fname
,
r
)
self
.
assertIn
(
"mode='r'"
,
r
)
if
self
.
compression
!=
zipfile
.
ZIP_STORED
:
self
.
assertIn
(
'compress_type='
,
r
)
self
.
assertIn
(
'[closed]'
,
repr
(
zipopen
))
self
.
assertIn
(
'[closed]'
,
repr
(
zipfp
))
def
tearDown
(
self
):
def
tearDown
(
self
):
unlink
(
TESTFN
)
unlink
(
TESTFN
)
unlink
(
TESTFN2
)
unlink
(
TESTFN2
)
...
...
Lib/zipfile.py
Dosyayı görüntüle @
51a43703
...
@@ -355,6 +355,28 @@ class ZipInfo (object):
...
@@ -355,6 +355,28 @@ class ZipInfo (object):
# compress_size Size of the compressed file
# compress_size Size of the compressed file
# file_size Size of the uncompressed file
# file_size Size of the uncompressed file
def
__repr__
(
self
):
result
=
[
'<
%
s filename=
%
r'
%
(
self
.
__class__
.
__name__
,
self
.
filename
)]
if
self
.
compress_type
!=
ZIP_STORED
:
result
.
append
(
' compress_type=
%
s'
%
compressor_names
.
get
(
self
.
compress_type
,
self
.
compress_type
))
hi
=
self
.
external_attr
>>
16
lo
=
self
.
external_attr
&
0xFFFF
if
hi
:
result
.
append
(
' filemode=
%
r'
%
stat
.
filemode
(
hi
))
if
lo
:
result
.
append
(
' external_attr=
%#
x'
%
lo
)
isdir
=
self
.
filename
[
-
1
:]
==
'/'
if
not
isdir
or
self
.
file_size
:
result
.
append
(
' file_size=
%
r'
%
self
.
file_size
)
if
((
not
isdir
or
self
.
compress_size
)
and
(
self
.
compress_type
!=
ZIP_STORED
or
self
.
file_size
!=
self
.
compress_size
)):
result
.
append
(
' compress_size=
%
r'
%
self
.
compress_size
)
result
.
append
(
'>'
)
return
''
.
join
(
result
)
def
FileHeader
(
self
,
zip64
=
None
):
def
FileHeader
(
self
,
zip64
=
None
):
"""Return the per-file header as a string."""
"""Return the per-file header as a string."""
dt
=
self
.
date_time
dt
=
self
.
date_time
...
@@ -671,6 +693,20 @@ class ZipExtFile(io.BufferedIOBase):
...
@@ -671,6 +693,20 @@ class ZipExtFile(io.BufferedIOBase):
else
:
else
:
self
.
_expected_crc
=
None
self
.
_expected_crc
=
None
def
__repr__
(
self
):
result
=
[
'<
%
s.
%
s'
%
(
self
.
__class__
.
__module__
,
self
.
__class__
.
__qualname__
)]
if
not
self
.
closed
:
result
.
append
(
' name=
%
r mode=
%
r'
%
(
self
.
name
,
self
.
mode
))
if
self
.
_compress_type
!=
ZIP_STORED
:
result
.
append
(
' compress_type=
%
s'
%
compressor_names
.
get
(
self
.
_compress_type
,
self
.
_compress_type
))
else
:
result
.
append
(
' [closed]'
)
result
.
append
(
'>'
)
return
''
.
join
(
result
)
def
readline
(
self
,
limit
=-
1
):
def
readline
(
self
,
limit
=-
1
):
"""Read and return a line from the stream.
"""Read and return a line from the stream.
...
@@ -967,6 +1003,20 @@ class ZipFile:
...
@@ -967,6 +1003,20 @@ class ZipFile:
def
__exit__
(
self
,
type
,
value
,
traceback
):
def
__exit__
(
self
,
type
,
value
,
traceback
):
self
.
close
()
self
.
close
()
def
__repr__
(
self
):
result
=
[
'<
%
s.
%
s'
%
(
self
.
__class__
.
__module__
,
self
.
__class__
.
__qualname__
)]
if
self
.
fp
is
not
None
:
if
self
.
_filePassed
:
result
.
append
(
' file=
%
r'
%
self
.
fp
)
elif
self
.
filename
is
not
None
:
result
.
append
(
' filename=
%
r'
%
self
.
filename
)
result
.
append
(
' mode=
%
r'
%
self
.
mode
)
else
:
result
.
append
(
' [closed]'
)
result
.
append
(
'>'
)
return
''
.
join
(
result
)
def
_RealGetContents
(
self
):
def
_RealGetContents
(
self
):
"""Read in the table of contents for the ZIP file."""
"""Read in the table of contents for the ZIP file."""
fp
=
self
.
fp
fp
=
self
.
fp
...
...
Misc/NEWS
Dosyayı görüntüle @
51a43703
...
@@ -181,6 +181,8 @@ Core and Builtins
...
@@ -181,6 +181,8 @@ Core and Builtins
Library
Library
-------
-------
-
Issue
#
22217
:
Implemented
reprs
of
classes
in
the
zipfile
module
.
-
Issue
#
18216
:
gettext
now
raises
an
error
when
a
.
mo
file
has
an
-
Issue
#
18216
:
gettext
now
raises
an
error
when
a
.
mo
file
has
an
unsupported
major
version
number
.
Patch
by
Aaron
Hill
.
unsupported
major
version
number
.
Patch
by
Aaron
Hill
.
...
...
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