mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Issue #26039: Document ZipInfo.is_dir() and make force_zip64 keyword-only.
Patch by Thomas Kluyver.
This commit is contained in:
parent
3d3f7e8b41
commit
f47fc5553b
2 changed files with 12 additions and 3 deletions
|
@ -207,7 +207,7 @@ ZipFile Objects
|
||||||
.. index::
|
.. index::
|
||||||
single: universal newlines; zipfile.ZipFile.open method
|
single: universal newlines; zipfile.ZipFile.open method
|
||||||
|
|
||||||
.. method:: ZipFile.open(name, mode='r', pwd=None, force_zip64=False)
|
.. method:: ZipFile.open(name, mode='r', pwd=None, *, force_zip64=False)
|
||||||
|
|
||||||
Access a member of the archive as a file-like object. *name*
|
Access a member of the archive as a file-like object. *name*
|
||||||
is the name of the file in the archive, or a :class:`ZipInfo` object. The
|
is the name of the file in the archive, or a :class:`ZipInfo` object. The
|
||||||
|
@ -490,7 +490,15 @@ file:
|
||||||
|
|
||||||
.. versionadded:: 3.6
|
.. versionadded:: 3.6
|
||||||
|
|
||||||
Instances have the following attributes:
|
Instances have the following methods and attributes:
|
||||||
|
|
||||||
|
.. method:: ZipInfo.is_dir()
|
||||||
|
|
||||||
|
Return True if this archive member is a directory.
|
||||||
|
|
||||||
|
This uses the entry's name: directories should always end with ``/``.
|
||||||
|
|
||||||
|
.. versionadded:: 3.6
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: ZipInfo.filename
|
.. attribute:: ZipInfo.filename
|
||||||
|
|
|
@ -502,6 +502,7 @@ class ZipInfo (object):
|
||||||
return zinfo
|
return zinfo
|
||||||
|
|
||||||
def is_dir(self):
|
def is_dir(self):
|
||||||
|
"""Return True if this archive member is a directory."""
|
||||||
return self.filename[-1] == '/'
|
return self.filename[-1] == '/'
|
||||||
|
|
||||||
|
|
||||||
|
@ -1343,7 +1344,7 @@ class ZipFile:
|
||||||
with self.open(name, "r", pwd) as fp:
|
with self.open(name, "r", pwd) as fp:
|
||||||
return fp.read()
|
return fp.read()
|
||||||
|
|
||||||
def open(self, name, mode="r", pwd=None, force_zip64=False):
|
def open(self, name, mode="r", pwd=None, *, force_zip64=False):
|
||||||
"""Return file-like object for 'name'.
|
"""Return file-like object for 'name'.
|
||||||
|
|
||||||
name is a string for the file name within the ZIP file, or a ZipInfo
|
name is a string for the file name within the ZIP file, or a ZipInfo
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue