Skip to content

Commit

Permalink
Merge branch 'release-1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlei committed May 10, 2015
2 parents 7342868 + 02c0892 commit 4f153ed
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ python:
- "2.7"
- "3.2"
- "3.3"
- "3.4"
- "pypy"
install:
- "pip install ."
Expand Down
5 changes: 1 addition & 4 deletions example.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# -*- coding: utf-8 -*-
import os
import zipstream
import zipfile


f = open('test.zip', 'wb')

with zipstream.ZipFile(mode='w', compression=zipstream.ZIP_DEFLATED) as z:
z.write('LICENSE')
z.write('LICENSE', arcname='stuff/LICENSE')
Expand All @@ -18,8 +17,6 @@
for chunk in z:
f.write(chunk)

f.close()


with zipfile.ZipFile('test.zip') as z:
z.testzip()
6 changes: 2 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
import zipstream


setup(
name='zipstream',
version=zipstream.__version__,
version='1.1.0',
description='Zipfile generator',
author='Allan Lei',
author_email='allanlei@helveticode.com',
url='https://github.com/allanlei/python-zipstream',
packages=find_packages(),
keywords='zip streaming',

test_suite='nose.collector',
tests_require = ['nose'],
tests_require=['nose'],
)
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py26, py27, py32, py33, pypy
envlist = py26, py27, py32, py33, py34, pypy

[testenv]
deps=nose
Expand Down
15 changes: 7 additions & 8 deletions zipstream/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""
from __future__ import unicode_literals, print_function, with_statement

__version__ = '1.0.4'
__version__ = '1.1.0'

import os
import sys
Expand All @@ -18,24 +18,23 @@
from .compat import (
str, bytes,
ZIP64_VERSION,
ZIP_BZIP2, BZIP2_VERSION,
ZIP_BZIP2, BZIP2_VERSION,
ZIP_LZMA, LZMA_VERSION)

from zipfile import (
ZIP_STORED, ZIP64_LIMIT, ZIP_FILECOUNT_LIMIT, ZIP_MAX_COMMENT,
ZIP_DEFLATED,
ZIP_STORED, ZIP64_LIMIT, ZIP_FILECOUNT_LIMIT, ZIP_MAX_COMMENT,
ZIP_DEFLATED,
structCentralDir, structEndArchive64, structEndArchive, structEndArchive64Locator,
stringCentralDir, stringEndArchive64, stringEndArchive, stringEndArchive64Locator,
structFileHeader, stringFileHeader,
zlib, crc32)

stringDataDescriptor = b'PK\x07\x08' # magic number for data descriptor
stringDataDescriptor = b'PK\x07\x08' # magic number for data descriptor


def _get_compressor(compress_type):
if compress_type == ZIP_DEFLATED:
return zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION,
zlib.DEFLATED, -15)
return zlib.compressobj(zlib.Z_DEFAULT_COMPRESSION, zlib.DEFLATED, -15)
elif compress_type == ZIP_BZIP2:
from zipfile import bz2
return bz2.BZ2Compressor()
Expand Down Expand Up @@ -328,7 +327,7 @@ def __close(self):
return

try:
if self.mode in ('w', 'a') and self._didModify: # write ending records
if self.mode in ('w', 'a') and self._didModify: # write ending records
count = 0
pos1 = self.fp.tell()
for zinfo in self.filelist: # write central directory
Expand Down

0 comments on commit 4f153ed

Please sign in to comment.