Compare commits
2 Commits
6309d68b7b
...
608ec9a6c3
Author | SHA1 | Date |
---|---|---|
Nguyễn Gia Phong | 608ec9a6c3 | |
Nguyễn Gia Phong | a9ebcd79a0 |
9
lazip.py
9
lazip.py
|
@ -18,7 +18,7 @@
|
|||
|
||||
"""Lazy ZIP over HTTP"""
|
||||
|
||||
__version__ = '0.0.4'
|
||||
__version__ = '0.0.5'
|
||||
__all__ = ['Filazy', 'Lazip']
|
||||
|
||||
from abc import abstractmethod
|
||||
|
@ -46,7 +46,7 @@ class ReadOnlyBinaryIOWrapper(IO[bytes]):
|
|||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
"""File name."""
|
||||
"""Path to the underlying file."""
|
||||
return self.file.name
|
||||
|
||||
def close(self) -> None:
|
||||
|
@ -172,7 +172,7 @@ class Filazy(ReadOnlyBinaryIOWrapper):
|
|||
accept_ranges (bool): Whether range requests are supported
|
||||
"""
|
||||
|
||||
def __init__(self, session: Session, url: str,
|
||||
def __init__(self, url: str, session: Session,
|
||||
chunk_size: int = CONTENT_CHUNK_SIZE) -> None:
|
||||
response = session.head(url)
|
||||
response.raise_for_status()
|
||||
|
@ -229,6 +229,9 @@ class Filazy(ReadOnlyBinaryIOWrapper):
|
|||
|
||||
def ensure(self, start: int, end: int) -> None:
|
||||
"""Download bytes from start to end inclusively."""
|
||||
offset = self.chunk_size - 1
|
||||
start = max(0, min(start, end-offset))
|
||||
end = min(self.length-1, max(end, start+offset))
|
||||
with self.stay():
|
||||
i, j = bisect_left(self.right, start), bisect_right(self.left, end)
|
||||
for start, end in self.merge(start, end, i, j):
|
||||
|
|
|
@ -6,11 +6,11 @@ build-backend = 'flit_core.buildapi'
|
|||
module = 'lazip'
|
||||
author = 'Nguyễn Gia Phong'
|
||||
author-email = 'mcsinyx@disroot.org'
|
||||
home-page = 'https://github.com/McSinyx/lazip'
|
||||
home-page = 'https://git.disroot.org/McSinyx/lazip'
|
||||
requires = ['requests']
|
||||
description-file = 'README.md'
|
||||
classifiers = [
|
||||
'Development Status :: 1 - Planning',
|
||||
'Development Status :: 3 - Alpha',
|
||||
'Intended Audience :: Developers',
|
||||
'License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)',
|
||||
'Natural Language :: English',
|
||||
|
|
Loading…
Reference in New Issue