diff --git a/cli/pyproject.toml b/cli/pyproject.toml index 8e27589..a234745 100644 --- a/cli/pyproject.toml +++ b/cli/pyproject.toml @@ -23,9 +23,5 @@ only-include = [ "src", ] -[tool.hatch.build.targets.wheel] -packages = ["zshell"] -include = ["src/zshell/assets/**/*"] - [tool.ruff] line-length = 120 diff --git a/cli/src/zshell/subcommands/scheme.py b/cli/src/zshell/subcommands/scheme.py index 7b048e9..9f7d7dd 100644 --- a/cli/src/zshell/subcommands/scheme.py +++ b/cli/src/zshell/subcommands/scheme.py @@ -2,7 +2,6 @@ from typing import Annotated, Optional import typer import json -from importlib import resources from pathlib import Path from PIL import Image from materialyoucolor.quantize import QuantizeCelebi @@ -66,7 +65,7 @@ def generate( f"Invalid hex color '{s}' (expected 6 hex digits, optionally prefixed with '#').") return f"#{s.upper()}" - def parse_preset_file(file_path) -> dict: + def parse_preset_file(file_path: Path) -> dict: """ Parse a preset scheme file with lines like: primary_paletteKeyColor 6a73ac @@ -169,12 +168,19 @@ def generate( try: if preset: # try local presets directory: presets//.txt or presets/-.txt - base = resources.files("zshell.assets.schemes") - preset_path = base / preset / flavour / f"{mode}.txt" + base1 = Path("zshell") / "assets" / "schemes" / \ + preset / flavour / f"{mode}.txt" + if base1.exists(): + preset_path = base1 + else: + raise FileNotFoundError( + f"Preset file not found. Looked for: {base1.resolve()}. " + "You can also pass --preset-file directly." + ) mapping = parse_preset_file(preset_path) generate_color_scheme_from_preset( - mapping, output, preset, flavour) + mapping, output, preset or preset_path.stem, flavour) typer.echo(f"Wrote preset-based scheme to {output}") raise typer.Exit()