diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-24 23:30:28 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-06-24 23:30:28 +1000 |
| commit | 500e8014813996469557a21a199fb087d74e4d51 (patch) | |
| tree | 9628af02202da18d64ca8f0c7bb7bfb1d61acd40 /src/caelestia/utils | |
| parent | ci: fix emoji not running (diff) | |
| download | caelestia-cli-500e8014813996469557a21a199fb087d74e4d51.tar.gz caelestia-cli-500e8014813996469557a21a199fb087d74e4d51.tar.bz2 caelestia-cli-500e8014813996469557a21a199fb087d74e4d51.zip | |
internal: lazy import stuff
Lazy import material generators
Diffstat (limited to 'src/caelestia/utils')
| -rw-r--r-- | src/caelestia/utils/material/__init__.py | 12 | ||||
| -rw-r--r-- | src/caelestia/utils/material/score.py | 3 |
2 files changed, 7 insertions, 8 deletions
diff --git a/src/caelestia/utils/material/__init__.py b/src/caelestia/utils/material/__init__.py index b96849f..88e855f 100644 --- a/src/caelestia/utils/material/__init__.py +++ b/src/caelestia/utils/material/__init__.py @@ -1,14 +1,12 @@ import json from pathlib import Path -from materialyoucolor.hct import Hct - -from caelestia.utils.material.generator import gen_scheme -from caelestia.utils.material.score import score from caelestia.utils.paths import compute_hash, scheme_cache_dir, wallpaper_thumbnail_path -def get_score_for_image(image: Path | str, cache_base: Path) -> Hct: +def get_score_for_image(image: Path | str, cache_base: Path): + from materialyoucolor.hct import Hct + cache = cache_base / "score.json" try: @@ -16,6 +14,8 @@ def get_score_for_image(image: Path | str, cache_base: Path) -> Hct: except (IOError, TypeError): pass + from caelestia.utils.material.score import score + s = score(str(image)) cache.parent.mkdir(parents=True, exist_ok=True) @@ -39,6 +39,8 @@ def get_colours_for_image(image: Path | str = wallpaper_thumbnail_path, scheme=N except (IOError, json.JSONDecodeError): pass + from caelestia.utils.material.generator import gen_scheme + primary = get_score_for_image(image, cache_base) scheme = gen_scheme(scheme, primary) diff --git a/src/caelestia/utils/material/score.py b/src/caelestia/utils/material/score.py index a6126a6..be873f8 100644 --- a/src/caelestia/utils/material/score.py +++ b/src/caelestia/utils/material/score.py @@ -1,6 +1,3 @@ -#!/usr/bin/env python - - from materialyoucolor.dislike.dislike_analyzer import DislikeAnalyzer from materialyoucolor.hct import Hct from materialyoucolor.quantize import ImageQuantizeCelebi |