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

15 statements  

« prev     ^ index     » next       coverage.py v7.14.3, created at 2026-07-04 11:22 +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 typing import Any 

14 

15from .._types import InstallerPort 

16from ..shared.exceptions import InstallerTypeError 

17from ._innosetup_installer import InnoSetupInstaller 

18 

19# /////////////////////////////////////////////////////////////// 

20# CLASSES 

21# /////////////////////////////////////////////////////////////// 

22 

23 

24class InstallerFactory: 

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

26 

27 # ------------------------------------------------ 

28 # FACTORY METHODS 

29 # ------------------------------------------------ 

30 

31 @staticmethod 

32 def create_installer( 

33 installer_type: str, config: dict[str, Any] | None = None 

34 ) -> InstallerPort: 

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

36 

37 Args: 

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

39 config: Configuration dictionary for the installer adapter 

40 

41 Returns: 

42 InstallerPort: Configured installer instance (satisfies the Port) 

43 

44 Raises: 

45 InstallerTypeError: If installer type is not supported 

46 """ 

47 normalized = installer_type.lower() 

48 if normalized == "innosetup": 

49 return InnoSetupInstaller(config) 

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

51 

52 @staticmethod 

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

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

55 return ["innosetup"]