Coverage for src / ezqt_app / main.py: 71.43%
33 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-06 13:12 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-06 13:12 +0000
1# ///////////////////////////////////////////////////////////////
2# MAIN - Application initialization entry point
3# Project: ezqt_app
4# ///////////////////////////////////////////////////////////////
6"""Main module — initialization and bootstrap helpers for EzQt_App."""
8from __future__ import annotations
10# ///////////////////////////////////////////////////////////////
11# IMPORTS
12# ///////////////////////////////////////////////////////////////
13# Standard library imports
14from pathlib import Path
15from typing import TYPE_CHECKING
17# Local imports
18from .services.bootstrap import init as init_app
19from .utils.printer import get_printer
21if TYPE_CHECKING: 21 ↛ 22line 21 didn't jump to line 22 because the condition on line 21 was never true
22 from ezqt_app.services.application import FileService
23 from ezqt_app.services.bootstrap import Initializer, StartupConfig
24 from ezqt_app.services.bootstrap.contracts import OverwritePolicy
26# ///////////////////////////////////////////////////////////////
27# FUNCTIONS
28# ///////////////////////////////////////////////////////////////
31def init(
32 mk_theme: bool = True,
33 project_root: str | Path | None = None,
34 bin_path: str | Path | None = None,
35 overwrite_policy: OverwritePolicy | None = None,
36 verbose: bool = True,
37) -> dict[str, object]:
38 """Initialize the EzQt_App application using the new modular system.
40 This function uses the new initialization package to:
41 - Configure UTF-8 encoding at system level
42 - Load required resources and generate necessary files
43 - Setup the complete application environment
45 Args:
46 mk_theme: Generate theme file. Defaults to True.
47 project_root: Project root directory. Defaults to None.
48 bin_path: Binary path. Defaults to None.
49 overwrite_policy: Policy for overwriting existing files. Defaults to None.
50 verbose: Enable verbose output mode. Defaults to True.
52 Returns:
53 dict[str, object]: Initialization result dictionary.
54 """
55 from ezqt_app.services.bootstrap.contracts import OverwritePolicy
57 resolved_policy = overwrite_policy or OverwritePolicy.ASK
58 resolved_project_root = str(project_root) if project_root is not None else None
59 resolved_bin_path = str(bin_path) if bin_path is not None else None
61 return init_app(
62 mk_theme=mk_theme,
63 verbose=verbose,
64 project_root=resolved_project_root,
65 bin_path=resolved_bin_path,
66 overwrite_policy=resolved_policy,
67 )
70def setup_project(base_path: str | None = None) -> bool:
71 """Setup a new EzQt_App project using the new modular system.
73 Args:
74 base_path: Base path for the project. Defaults to current directory.
76 Returns:
77 bool: True if setup was successful.
78 """
79 from ezqt_app.services.bootstrap import setup_project as setup_project_app
81 return setup_project_app(base_path)
84def generate_assets() -> bool:
85 """Generate all required assets using the new modular system.
87 Returns:
88 bool: True if generation was successful.
89 """
90 from ezqt_app.services.bootstrap import generate_assets as generate_assets_app
92 return generate_assets_app()
95def configure_startup() -> None:
96 """Configure startup settings using the new modular system."""
97 from ezqt_app.services.bootstrap import configure_startup as configure_startup_app
99 configure_startup_app()
102# ///////////////////////////////////////////////////////////////
103# UTILITY FUNCTIONS
104# ///////////////////////////////////////////////////////////////
107def get_initializer() -> Initializer:
108 """Get the main initializer instance.
110 Returns:
111 Initializer: The main initializer instance.
112 """
113 from ezqt_app.services.bootstrap import Initializer
115 return Initializer()
118def get_file_service(verbose: bool = False) -> FileService:
119 """Get the file service instance.
121 Args:
122 verbose: Enable verbose output mode. Defaults to False.
124 Returns:
125 FileService: The file service instance.
126 """
127 from ezqt_app.services.application import FileService
129 return FileService(verbose=verbose)
132def get_startup_config() -> StartupConfig:
133 """Get the startup configuration instance.
135 Returns:
136 StartupConfig: The startup configuration instance.
137 """
138 from ezqt_app.services.bootstrap import StartupConfig
140 return StartupConfig()
143# ///////////////////////////////////////////////////////////////
144# MAIN ENTRY POINT
145# ///////////////////////////////////////////////////////////////
147if __name__ == "__main__":
148 # Example usage of the new initialization system
149 printer = get_printer()
150 printer.section("EzQt_App - New Initialization System")
152 # Initialize the application
153 init(mk_theme=True)
155 printer.success("Application initialized successfully!")
156 printer.info("Ready to create your EzQt_App application!")