mirror of
https://github.com/caelestia-dots/cli.git
synced 2026-06-18 15:00:00 -05:00
internal: lazy import stuff
Lazy import material generators
This commit is contained in:
@@ -1,14 +1,12 @@
|
|||||||
import json
|
import json
|
||||||
from pathlib import Path
|
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
|
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"
|
cache = cache_base / "score.json"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -16,6 +14,8 @@ def get_score_for_image(image: Path | str, cache_base: Path) -> Hct:
|
|||||||
except (IOError, TypeError):
|
except (IOError, TypeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
from caelestia.utils.material.score import score
|
||||||
|
|
||||||
s = score(str(image))
|
s = score(str(image))
|
||||||
|
|
||||||
cache.parent.mkdir(parents=True, exist_ok=True)
|
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):
|
except (IOError, json.JSONDecodeError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
from caelestia.utils.material.generator import gen_scheme
|
||||||
|
|
||||||
primary = get_score_for_image(image, cache_base)
|
primary = get_score_for_image(image, cache_base)
|
||||||
scheme = gen_scheme(scheme, primary)
|
scheme = gen_scheme(scheme, primary)
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
|
|
||||||
from materialyoucolor.dislike.dislike_analyzer import DislikeAnalyzer
|
from materialyoucolor.dislike.dislike_analyzer import DislikeAnalyzer
|
||||||
from materialyoucolor.hct import Hct
|
from materialyoucolor.hct import Hct
|
||||||
from materialyoucolor.quantize import ImageQuantizeCelebi
|
from materialyoucolor.quantize import ImageQuantizeCelebi
|
||||||
|
|||||||
Reference in New Issue
Block a user