Skip to content
Merged

God #28

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions wimf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def save(path, image, **kwargs):
raw = encoder.encode(**encode_args)

try:
from . import wimf_cpp
from .wimf_cpp import c_save_file

wimf_cpp.c_save_file(path, raw)
c_save_file(path, raw)
except (ImportError, AttributeError):
with _builtins.open(path, "wb") as f:
f.write(raw)
Expand Down
4 changes: 3 additions & 1 deletion wimf/animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
try:
from . import wimf_cpp # type: ignore[attr-defined]
except ImportError:
pass
logging.getLogger(__name__).debug(
"Optional module '.wimf_cpp' could not be imported; using Python implementation."
)

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion wimf/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def render_terminal(wimf_img, width=None):
if width is None:
try:
width = os.get_terminal_size().columns
except:
except OSError:
width = 80

# Account for terminal character aspect ratio (~2:1)
Expand Down
2 changes: 0 additions & 2 deletions wimf/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
import numpy as np
from PIL import ExifTags, Image, ImageSequence

from wimf.io import loadImage, saveImage

logger = logging.getLogger(__name__)


Expand All @@ -39,7 +37,7 @@

if in_ext in [".wimf", ".wif", ".awif"]:
# open wimf and turn it back to pixels
w, h, pixels, loaded_meta = loadImage(input_path, roi=roi, mip_level=mip_level)

Check failure on line 40 in wimf/cli.py

View workflow job for this annotation

GitHub Actions / Code Quality

ruff (F821)

wimf/cli.py:40:41: F821 Undefined name `loadImage`

Check failure on line 40 in wimf/cli.py

View workflow job for this annotation

GitHub Actions / Code Quality

ruff (F821)

wimf/cli.py:40:41: F821 Undefined name `loadImage`

w, h = w >> mip_level, h >> mip_level
if roi:
Expand Down Expand Up @@ -172,7 +170,7 @@
w, h = img.size
p_bytes = pixels.tobytes() if isinstance(pixels, np.ndarray) else pixels

saveImage(

Check failure on line 173 in wimf/cli.py

View workflow job for this annotation

GitHub Actions / Code Quality

ruff (F821)

wimf/cli.py:173:13: F821 Undefined name `saveImage`

Check failure on line 173 in wimf/cli.py

View workflow job for this annotation

GitHub Actions / Code Quality

ruff (F821)

wimf/cli.py:173:13: F821 Undefined name `saveImage`
output_path, w, h, p_bytes, compression=compression, quality=quality, metadata=meta, preset=preset
)

Expand Down Expand Up @@ -263,7 +261,7 @@
meta["watermark_payload"] = args.embed_secret

if args.extract_secret:
_, _, _, loaded_meta = loadImage(args.input[0])

Check failure on line 264 in wimf/cli.py

View workflow job for this annotation

GitHub Actions / Code Quality

ruff (F821)

wimf/cli.py:264:32: F821 Undefined name `loadImage`

Check failure on line 264 in wimf/cli.py

View workflow job for this annotation

GitHub Actions / Code Quality

ruff (F821)

wimf/cli.py:264:32: F821 Undefined name `loadImage`
return

# wildcards are a pain
Expand Down
5 changes: 3 additions & 2 deletions wimf/codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

try:
from . import wimf_cpp # type: ignore[attr-defined]
except ImportError:
pass
except ImportError as exc:
# Optional C++ acceleration module is unavailable; fall back to Python implementation.
logger.debug("wimf_cpp extension not available, using Python codec path: %s", exc)

Check failure on line 13 in wimf/codec.py

View workflow job for this annotation

GitHub Actions / Code Quality

ruff (F821)

wimf/codec.py:13:5: F821 Undefined name `logger`

Check failure on line 13 in wimf/codec.py

View workflow job for this annotation

GitHub Actions / Code Quality

ruff (F821)

wimf/codec.py:13:5: F821 Undefined name `logger`
import multiprocessing
from concurrent.futures import ThreadPoolExecutor

Expand Down
2 changes: 0 additions & 2 deletions wimf/test_core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import os

import numpy as np
from PIL import Image

Expand Down
2 changes: 1 addition & 1 deletion wimf/viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def main():

if os.path.exists(p):
root = tk.Tk()
viewer = WIMFViewer(root, p)
WIMFViewer(root, p)
root.mainloop()
else:
print(f"File not found: {p}")
Expand Down
Loading