Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A zip file which happens to let content overlay it's files. Use with a dash of StringIO for grand results.
import zipfile
class OverlayZipFile(zipfile.ZipFile):
""" Adds a method for overlaying a zip file with a given directory, or another
zip file. """
def overlay(self, content):
""" Overlays content over the zip file represented by 'self'.
Receives a zip file, and write's it's entire content over the zip file which
is represented by 'self' - overwriting any files in the current zip with the
any files of the same name which are within the provided content zip file.
"""
for filename in content.namelist():
self.writestr(filename, content.read(filename))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.