gzip: Implement decompress() function.

pull/20/merge
Paul Sokolovsky 2015-01-28 03:04:11 +02:00
rodzic caa1b279ac
commit c89a9fd7b1
3 zmienionych plików z 33 dodań i 5 usunięć

Wyświetl plik

@ -0,0 +1,28 @@
#import zlib
import uzlib as zlib
FTEXT = 1
FHCRC = 2
FEXTRA = 4
FNAME = 8
FCOMMENT = 16
def decompress(data):
assert data[0] == 0x1f and data[1] == 0x8b
assert data[2] == 8
flg = data[3]
assert flg & 0xe0 == 0
i = 10
if flg & FEXTRA:
i += data[11] << 8 + data[10] + 2
if flg & FNAME:
while data[i]:
i += 1
i += 1
if flg & FCOMMENT:
while data[i]:
i += 1
i += 1
if flg & FHCRC:
i += 2
return zlib.decompress(memoryview(data)[i:], -15)

Wyświetl plik

@ -1,3 +1,3 @@
srctype=dummy
srctype=micropython-lib
type=module
version=0.0.1
version=0.1

Wyświetl plik

@ -6,9 +6,9 @@ from setuptools import setup
setup(name='micropython-gzip',
version='0.0.1',
description='Dummy gzip module for MicroPython',
long_description='This is a dummy implementation of a module for MicroPython standard library.\nIt contains zero or very little functionality, and primarily intended to\navoid import errors (using idea that even if an application imports a\nmodule, it may be not using it onevery code path, so may work at least\npartially). It is expected that more complete implementation of the module\nwill be provided later. Please help with the development if you are\ninterested in this module.',
version='0.1',
description='gzip module for MicroPython',
long_description="This is a module reimplemented specifically for MicroPython standard library,\nwith efficient and lean design in mind. Note that this module is likely work\nin progress and likely supports just a subset of CPython's corresponding\nmodule. Please help with the development if you are interested in this\nmodule.",
url='https://github.com/micropython/micropython/issues/405',
author='MicroPython Developers',
author_email='micro-python@googlegroups.com',