Skip to content

Commit 6aed859

Browse files
committed
Add remove() and repack() to ZipFile
1 parent 7b1010a commit 6aed859

File tree

4 files changed

+1251
-0
lines changed

4 files changed

+1251
-0
lines changed

Doc/library/zipfile.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,29 @@ ZipFile Objects
518518
.. versionadded:: 3.11
519519

520520

521+
.. method:: ZipFile.remove(zinfo_or_arcname)
522+
523+
Removes a member from the archive. *zinfo_or_arcname* is either the full
524+
path of the member, or a :class:`ZipInfo` instance.
525+
526+
The archive must be opened with mode ``'w'``, ``'x'`` or ``'a'``.
527+
528+
Calling :meth:`remove` on a closed ZipFile will raise a :exc:`ValueError`.
529+
530+
.. versionadded:: next
531+
532+
533+
.. method:: ZipFile.repack()
534+
535+
Repack a zip file and physically remove non-referenced file entries.
536+
537+
The archive must be opened with mode ``'a'``.
538+
539+
Calling :meth:`repack` on a closed ZipFile will raise a :exc:`ValueError`.
540+
541+
.. versionadded:: next
542+
543+
521544
The following data attributes are also available:
522545

523546
.. attribute:: ZipFile.filename

0 commit comments

Comments
 (0)