Skip to content

Commit

Permalink
Implement writestr
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
allanlei committed Sep 29, 2015
1 parent 8c043b0 commit 3d0d364
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions zipstream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,14 @@ def write_iter(self, arcname, iterable, compress_type=None):
kwargs = {'arcname': arcname, 'iterable': iterable, 'compress_type': compress_type}
self.paths_to_write.append(kwargs)

def writestr(self, arcname, data, compress_type=None):
"""
Writes a str into ZipFile by wrapping data as a generator
"""
def _iterable():
yield data
return self.write_iter(arcname, _iterable(), compress_type=compress_type)

def __write(self, filename=None, iterable=None, arcname=None, compress_type=None):
"""Put the bytes from filename into the archive under the name
`arcname`."""
Expand Down

0 comments on commit 3d0d364

Please sign in to comment.