Skip to content

Extension of pythons zipfile implementation to support rename and removal of files.

Notifications You must be signed in to change notification settings

gambl/zipextended

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zipextended - Zipfile Extension

Module provides class ZipFileExtended an extension of pythons zipfile implementation to support rename and removal of files from a zip archive.

ZipFileExtended: Class with methods to open, read, write, remove, rename, close and list Zip files.

    zip = ZipFileExtended(file,mode="r", compression=ZIP_STORED, allowZip64=True)

file: Either the path to the file, or a file-like object. If it is a path, the file will be opened and closed by UCF.

mode: The mode can be either read "r", write "w" or append "a".

compression: The compression type to be used for this archive. e.g. zipfile.ZIP_STORED (no compression), zipfile.ZIP_DEFLATED (requires zlib).

allowZip64: if True ZipFile will create files with ZIP64 extensions when needed, otherwise it will raise an exception when this would be necessary.

The main additional methods provided:

ZipFileExtended.remove(zinfo_or_arcname): Remove a member from the archive.

Args:

  • zinfo_or_arcname (ZipInfo, str) ZipInfo object or filename of the member.

Raises:

  • RuntimeError: If attempting to modify an Zip archive that is closed.

ZipFileExtended.rename(zinfo_or_arcname, filename): Rename a member in the archive.

Args:

  • zinfo_or_arcname (ZipInfo, str): ZipInfo object or filename of the member.
  • filename (str): the new name for the member.

Raises:

  • RuntimeError: If attempting to modify an Zip archive that is closed.

About

Extension of pythons zipfile implementation to support rename and removal of files.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages