Coverage for src / ezqt_app / main.py: 71.43%

33 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-26 07:07 +0000

1# /////////////////////////////////////////////////////////////// 

2# MAIN - Application initialization entry point 

3# Project: ezqt_app 

4# /////////////////////////////////////////////////////////////// 

5 

6"""Main module — initialization and bootstrap helpers for EzQt_App.""" 

7 

8from __future__ import annotations 

9 

10# /////////////////////////////////////////////////////////////// 

11# IMPORTS 

12# /////////////////////////////////////////////////////////////// 

13# Standard library imports 

14from pathlib import Path 

15from typing import TYPE_CHECKING 

16 

17# Local imports 

18from .services.bootstrap import init as init_app 

19from .utils.printer import get_printer 

20 

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 

25 

26# /////////////////////////////////////////////////////////////// 

27# FUNCTIONS 

28# /////////////////////////////////////////////////////////////// 

29 

30 

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. 

39 

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 

44 

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. 

51 

52 Returns: 

53 dict[str, object]: Initialization result dictionary. 

54 """ 

55 from ezqt_app.services.bootstrap.contracts import OverwritePolicy 

56 

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 

60 

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 ) 

68 

69 

70def setup_project(base_path: str | None = None) -> bool: 

71 """Setup a new EzQt_App project using the new modular system. 

72 

73 Args: 

74 base_path: Base path for the project. Defaults to current directory. 

75 

76 Returns: 

77 bool: True if setup was successful. 

78 """ 

79 from ezqt_app.services.bootstrap import setup_project as setup_project_app 

80 

81 return setup_project_app(base_path) 

82 

83 

84def generate_assets() -> bool: 

85 """Generate all required assets using the new modular system. 

86 

87 Returns: 

88 bool: True if generation was successful. 

89 """ 

90 from ezqt_app.services.bootstrap import generate_assets as generate_assets_app 

91 

92 return generate_assets_app() 

93 

94 

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 

98 

99 configure_startup_app() 

100 

101 

102# /////////////////////////////////////////////////////////////// 

103# UTILITY FUNCTIONS 

104# /////////////////////////////////////////////////////////////// 

105 

106 

107def get_initializer() -> Initializer: 

108 """Get the main initializer instance. 

109 

110 Returns: 

111 Initializer: The main initializer instance. 

112 """ 

113 from ezqt_app.services.bootstrap import Initializer 

114 

115 return Initializer() 

116 

117 

118def get_file_service(verbose: bool = False) -> FileService: 

119 """Get the file service instance. 

120 

121 Args: 

122 verbose: Enable verbose output mode. Defaults to False. 

123 

124 Returns: 

125 FileService: The file service instance. 

126 """ 

127 from ezqt_app.services.application import FileService 

128 

129 return FileService(verbose=verbose) 

130 

131 

132def get_startup_config() -> StartupConfig: 

133 """Get the startup configuration instance. 

134 

135 Returns: 

136 StartupConfig: The startup configuration instance. 

137 """ 

138 from ezqt_app.services.bootstrap import StartupConfig 

139 

140 return StartupConfig() 

141 

142 

143# /////////////////////////////////////////////////////////////// 

144# MAIN ENTRY POINT 

145# /////////////////////////////////////////////////////////////// 

146 

147if __name__ == "__main__": 

148 # Example usage of the new initialization system 

149 printer = get_printer() 

150 printer.section("EzQt_App - New Initialization System") 

151 

152 # Initialize the application 

153 init(mk_theme=True) 

154 

155 printer.success("Application initialized successfully!") 

156 printer.info("Ready to create your EzQt_App application!")