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
7b998e9f
Kaydet (Commit)
7b998e9f
authored
Eki 04, 2010
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
GzipFile.peek improvements, suggested by Nir Aides.
üst
977c707b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
6 deletions
+16
-6
gzip.rst
Doc/library/gzip.rst
+11
-3
gzip.py
Lib/gzip.py
+5
-3
No files found.
Doc/library/gzip.rst
Dosyayı görüntüle @
7b998e9f
...
...
@@ -70,6 +70,17 @@ The module defines the following items:
including iteration and the :keyword:`with` statement. Only the
:meth:`truncate` method isn't implemented.
:class:`GzipFile` also provides the following method:
.. method:: peek([n])
Read *n* uncompressed bytes without advancing the file position.
At most one single read on the compressed stream is done to satisfy
the call. The number of bytes returned may be more or less than
requested.
.. versionadded:: 3.2
.. versionchanged:: 3.1
Support for the :keyword:`with` statement was added.
...
...
@@ -79,9 +90,6 @@ The module defines the following items:
.. versionchanged:: 3.2
Support for unseekable files was added.
.. versionchanged:: 3.2
The :meth:`peek` method was implemented.
.. function:: open(filename, mode='rb', compresslevel=9)
...
...
Lib/gzip.py
Dosyayı görüntüle @
7b998e9f
...
...
@@ -342,16 +342,18 @@ class GzipFile(io.BufferedIOBase):
def
peek
(
self
,
n
):
if
self
.
mode
!=
READ
:
import
errno
raise
IOError
(
errno
.
EBADF
,
"
read
() on write-only GzipFile object"
)
raise
IOError
(
errno
.
EBADF
,
"
peek
() on write-only GzipFile object"
)
# Do not return ridiculously small buffers
# Do not return ridiculously small buffers, for one common idiom
# is to call peek(1) and expect more bytes in return.
if
n
<
100
:
n
=
100
if
self
.
extrasize
==
0
:
if
self
.
fileobj
is
None
:
return
b
''
try
:
self
.
_read
(
max
(
self
.
max_read_chunk
,
n
))
# 1024 is the same buffering heuristic used in read()
self
.
_read
(
max
(
n
,
1024
))
except
EOFError
:
pass
offset
=
self
.
offset
-
self
.
extrastart
...
...
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