Coverage for src/ezcompiler/adapters/installer_factory.py: 100.00%

15 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-16 16:37 +0000

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

2# INSTALLER_FACTORY - Factory for installer instances 

3# Project: ezcompiler 

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

5 

6"""Installer factory - Centralized creation of installer instances by type.""" 

7 

8from __future__ import annotations 

9 

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

11# IMPORTS 

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

13from .._types import InstallerPort 

14from ..shared import InstallerConfig 

15from ..shared.exceptions import InstallerTypeError 

16from ._innosetup_installer import InnoSetupInstaller 

17 

18# /////////////////////////////////////////////////////////////// 

19# CLASSES 

20# /////////////////////////////////////////////////////////////// 

21 

22 

23class InstallerFactory: 

24 """Factory class for creating installer instances.""" 

25 

26 # ------------------------------------------------ 

27 # FACTORY METHODS 

28 # ------------------------------------------------ 

29 

30 @staticmethod 

31 def create_installer( 

32 installer_type: str, config: InstallerConfig | None = None 

33 ) -> InstallerPort: 

34 """Create an installer instance for the given type. 

35 

36 Args: 

37 installer_type: Type of installer builder ("innosetup") 

38 config: Configuration for the installer adapter 

39 

40 Returns: 

41 InstallerPort: Configured installer instance (satisfies the Port) 

42 

43 Raises: 

44 InstallerTypeError: If installer type is not supported 

45 """ 

46 normalized = installer_type.lower() 

47 if normalized == "innosetup": 

48 return InnoSetupInstaller(config or InstallerConfig()) 

49 raise InstallerTypeError(f"Unsupported installer type: {installer_type}") 

50 

51 @staticmethod 

52 def get_supported_types() -> list[str]: 

53 """Return the list of supported installer backend names.""" 

54 return ["innosetup"]