-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
20 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ jobs: | |
- macOS | ||
- Windows | ||
python-version: | ||
- '3.8' | ||
- '3.9' | ||
- '3.10' | ||
- '3.11' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,7 +30,7 @@ Installation | |
Requirements | ||
------------ | ||
|
||
- Python 3.8+ | ||
- Python 3.9+ | ||
|
||
|
||
Usage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
# | ||
# zopfli | ||
# | ||
# Copyright (c) 2015-2023 Akinori Hattori <[email protected]> | ||
# Copyright (c) 2015-2024 Akinori Hattori <[email protected]> | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
@@ -14,7 +14,7 @@ | |
import struct | ||
import sys | ||
import threading | ||
from typing import TYPE_CHECKING, cast, Any, AnyStr, IO, Literal, Optional, Tuple, Union | ||
from typing import cast, Any, AnyStr, IO, Literal, Optional, Union | ||
import zipfile | ||
import zlib | ||
|
||
|
@@ -31,11 +31,7 @@ | |
except ImportError: | ||
__version__ = 'unknown' | ||
|
||
if (TYPE_CHECKING | ||
or sys.version_info >= (3, 9)): | ||
P = Union[str, os.PathLike[str]] | ||
else: | ||
P = Union[str, os.PathLike] | ||
P = Union[str, os.PathLike[str]] | ||
|
||
|
||
class ZopfliDecompressor: | ||
|
@@ -101,9 +97,7 @@ def open(self, name: Union[str, zipfile.ZipInfo], mode: Literal['r', 'w'] = 'r', | |
if (mode == 'w' | ||
and self._zopflify(None) | ||
and fp._compressor): | ||
opts = self._options.copy() | ||
opts.update(kwargs) | ||
fp._compressor = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **opts) | ||
fp._compressor = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **self._options | kwargs) | ||
return fp | ||
|
||
def _open_to_write(self, zinfo: zipfile.ZipInfo, force_zip64: bool = False) -> IO[bytes]: | ||
|
@@ -115,9 +109,7 @@ def write(self, filename: P, arcname: Optional[P] = None, | |
z: Optional[ZopfliCompressor] = None | ||
if zopflify: | ||
compress_type = zipfile.ZIP_STORED | ||
opts = self._options.copy() | ||
opts.update(kwargs) | ||
z = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **opts) | ||
z = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **self._options | kwargs) | ||
with self._lock: | ||
fp = self.fp | ||
try: | ||
|
@@ -147,9 +139,7 @@ def writestr(self, zinfo_or_arcname: Union[str, zipfile.ZipInfo], data: AnyStr, | |
z: Optional[ZopfliCompressor] = None | ||
if zopflify: | ||
compress_type = zipfile.ZIP_STORED | ||
opts = self._options.copy() | ||
opts.update(kwargs) | ||
z = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **opts) | ||
z = ZopfliCompressor(ZOPFLI_FORMAT_DEFLATE, **self._options | kwargs) | ||
with self._lock: | ||
fp = self.fp | ||
try: | ||
|
@@ -268,7 +258,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: | |
super().__init__(*args, **kwargs) | ||
self.encoding = None | ||
|
||
def _encodeFilenameFlags(self) -> Tuple[bytes, int]: | ||
def _encodeFilenameFlags(self) -> tuple[bytes, int]: | ||
if isinstance(self.filename, bytes): | ||
return self.filename, self.flag_bits | ||
encoding = codecs.lookup(self.encoding).name if self.encoding else 'ascii' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
# | ||
# zopfli._zopfli | ||
# | ||
# Copyright (c) 2021 Akinori Hattori <[email protected]> | ||
# Copyright (c) 2021-2024 Akinori Hattori <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
# | ||
|
||
from typing import Optional, Sequence, Tuple | ||
from collections.abc import Sequence | ||
from typing import Optional | ||
|
||
|
||
ZOPFLI_FORMAT_GZIP: int | ||
|
@@ -38,7 +39,7 @@ class ZopfliPNG: | |
filter_strategies: str | ||
auto_filter_strategy: bool | ||
keep_color_type: bool | ||
keep_chunks: Tuple[str, ...] | ||
keep_chunks: tuple[str, ...] | ||
use_zopfli: bool | ||
iterations: int | ||
iterations_large: int | ||
|