Coverage for src / ezqt_app / services / application / assets_service.py: 25.71%
27 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-26 07:07 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-03-26 07:07 +0000
1# ///////////////////////////////////////////////////////////////
2# SERVICES.APPLICATION.ASSETS_SERVICE - Assets orchestration service
3# Project: ezqt_app
4# ///////////////////////////////////////////////////////////////
6"""Orchestrates asset generation and requirements checks for EzQt_App projects."""
8from __future__ import annotations
10# ///////////////////////////////////////////////////////////////
11# IMPORTS
12# ///////////////////////////////////////////////////////////////
13# Standard library imports
14from pathlib import Path
16# Local imports
17from ..config.config_service import get_package_resource
18from .file_service import FileService
21# ///////////////////////////////////////////////////////////////
22# CLASSES
23# ///////////////////////////////////////////////////////////////
24class AssetsService:
25 """Orchestrates asset generation and requirement checks.
27 Delegates file-level operations to :class:`FileService` and exposes
28 higher-level workflows used during application initialisation.
29 """
31 @staticmethod
32 def check_assets_requirements(
33 base_path: Path | None = None,
34 bin_path: Path | None = None,
35 overwrite_policy: str = "ask",
36 ) -> None:
37 """Generate asset binaries, QRC and RC files at APP_PATH."""
38 maker = FileService(
39 base_path=base_path,
40 bin_path=bin_path,
41 overwrite_policy=overwrite_policy,
42 )
43 maker.make_assets_binaries()
44 res = maker.make_qrc()
45 if res:
46 maker.make_rc_py()
47 maker.make_app_icons_py()
48 else:
49 maker.purge_rc_py()
51 @staticmethod
52 def make_required_files(
53 mk_theme: bool = True,
54 mk_config: bool = True,
55 mk_translations: bool = True,
56 base_path: Path | None = None,
57 bin_path: Path | None = None,
58 overwrite_policy: str = "ask",
59 ) -> None:
60 """Copy YAML, QSS theme and translation files into ``cwd/bin/``.
62 Parameters
63 ----------
64 mk_theme:
65 When ``True`` (default) also copies the QSS theme file.
66 """
67 project_root = base_path or Path.cwd()
68 maker = FileService(
69 base_path=project_root,
70 bin_path=bin_path,
71 overwrite_policy=overwrite_policy,
72 )
74 if mk_config:
75 yaml_package = get_package_resource("resources/config/app.config.yaml")
76 maker.make_yaml_from_package(yaml_package)
78 if mk_theme:
79 theme_package = get_package_resource("resources/themes")
80 maker.make_qss_from_package(theme_package)
82 if mk_translations:
83 translations_package = get_package_resource("resources/translations")
84 maker.make_translations_from_package(translations_package)