Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
f47fc555
Commit
f47fc555
authored
May 15, 2016
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #26039: Document ZipInfo.is_dir() and make force_zip64 keyword-only.
Patch by Thomas Kluyver.
parent
3d3f7e8b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
3 deletions
+12
-3
Doc/library/zipfile.rst
Doc/library/zipfile.rst
+10
-2
Lib/zipfile.py
Lib/zipfile.py
+2
-1
No files found.
Doc/library/zipfile.rst
View file @
f47fc555
...
@@ -207,7 +207,7 @@ ZipFile Objects
...
@@ -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:
...
@@ -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
...
...
Lib/zipfile.py
View file @
f47fc555
...
@@ -502,6 +502,7 @@ class ZipInfo (object):
...
@@ -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:
...
@@ -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
...
...
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