kopia lustrzana https://github.com/micropython/micropython-lib
gzip: Implement decompress() function.
rodzic
caa1b279ac
commit
c89a9fd7b1
28
gzip/gzip.py
28
gzip/gzip.py
|
@ -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)
|
|
@ -1,3 +1,3 @@
|
||||||
srctype=dummy
|
srctype=micropython-lib
|
||||||
type=module
|
type=module
|
||||||
version=0.0.1
|
version=0.1
|
||||||
|
|
|
@ -6,9 +6,9 @@ from setuptools import setup
|
||||||
|
|
||||||
|
|
||||||
setup(name='micropython-gzip',
|
setup(name='micropython-gzip',
|
||||||
version='0.0.1',
|
version='0.1',
|
||||||
description='Dummy gzip module for MicroPython',
|
description='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.',
|
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',
|
url='https://github.com/micropython/micropython/issues/405',
|
||||||
author='MicroPython Developers',
|
author='MicroPython Developers',
|
||||||
author_email='micro-python@googlegroups.com',
|
author_email='micro-python@googlegroups.com',
|
||||||
|
|
Ładowanie…
Reference in New Issue