Source code for armpicom.setup.factory

# -*- coding: UTF-8 -*-

'''
Module
    factory.py
Copyright
    Copyright (C) 2026 Vladimir Roncevic <elektron.ronca@gmail.com>
    armpicom is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
    Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
    armpicom is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    See the GNU General Public License for more details.
    You should have received a copy of the GNU General Public License along
    with this program. If not, see <http://www.gnu.org/licenses/>.
Info
    Factory for creating the armpicom bundle.
'''

from __future__ import annotations

from ats_utilities.base.setup.factory import BaseBundleFactory
from ats_utilities.base.setup.bundle import BaseBundle
from ats_utilities.base.setup.options import BaseBundleOptions
from ats_utilities.context.bundle import ContextBundle
from ats_utilities.context.factory import ContextBundleFactory

from armpicom.setup.bundle import ARMPicomBundle
from armpicom.setup.options import ARMPicomBundleOptions
from armpicom.setup.registry import ARMPicomBundleRegistry
from armpicom.setup.dependencies import ARMPicomBundleDependencies
from armpicom.setup.opt_validator import ARMPicomBundleOptionsValidator
from armpicom.setup.keys import ARMPicomBundleKeys
from armpicom.core.service.engine import Service
from armpicom.infrastructure.subprocessor import SubProcessor
from armpicom.infrastructure.cli.engine import CLI
from armpicom.infrastructure.cli.setup.bundle import CLIBundle
from armpicom.infrastructure.cli.setup.dependencies import CLIBundleDependencies
from armpicom.infrastructure.cli.setup.registry import CLIBundleRegistry
from armpicom.infrastructure.command.command import CommandBundle
from armpicom.infrastructure.command.gen_picom_command_definition import GenPicomCommandDefinition
from armpicom.infrastructure.command.gen_picom_command_executor import GenPicomCommandExecutor

__author__ = 'Vladimir Roncevic'
__copyright__ = '(C) 2026, https://vroncevic.github.io/armpicom'
__credits__ = ['Vladimir Roncevic', 'Python Software Foundation']
__license__ = 'https://github.com/vroncevic/armpicom/blob/dev/LICENSE'
__version__ = '2.0.3'
__maintainer__ = 'Vladimir Roncevic'
__email__ = 'elektron.ronca@gmail.com'
__status__ = 'Updated'


[docs] class ARMPicomBundleFactory: ''' Factory for creating the armpicom bundle. It defines: :attributes: | _info_file - Path to the armpicom info file. :methods: | create_bundle - Creates the armpicom bundle with optional pre-configured options. | get_version - Returns the factory version. ''' _info_file: str = 'armpicom/infrastructure/config/armpicom.cfg'
[docs] @classmethod def create_bundle(cls, options: ARMPicomBundleOptions | None = None) -> ARMPicomBundle: ''' Creates the armpicom bundle with optional pre-configured options. :param options: The pre-configured options for the armpicom bundle. :return: The armpicom bundle. :exceptions: | ATSValueError: The armpicom bundle options must be provided and have proper values. | ATSTypeError: The armpicom bundle options must be an instance of Mapping and its | attributes must be instances of their respective types. | ATSValueError: The armpicom bundle dependencies must be provided and have proper values. | ATSTypeError: The armpicom bundle dependencies must be an instance of Mapping and its | attributes must be instances of their respective types. | ATSValueError: The armpicom bundle must be provided and have proper values. | ATSTypeError: The armpicom bundle must be an instance of ARMPicomBundle and | its attributes must be instances of their respective types. ''' if options is not None: ARMPicomBundleOptionsValidator.validate(options) info_file = options.get(ARMPicomBundleKeys.OPTION_INFO_FILE) if options else cls._info_file context_bundle: ContextBundle = ContextBundleFactory.create_bundle() base_bundle: BaseBundle = BaseBundleFactory.create_bundle( options=BaseBundleOptions( info_file=info_file, use_generator=True, context_bundle=context_bundle ) ) subprocessor: SubProcessor = SubProcessor(generator=base_bundle.generation_manager) service: Service = Service(subprocessor=subprocessor) gen_picom_definition: GenPicomCommandDefinition = GenPicomCommandDefinition() gen_picom_bundle: CommandBundle = CommandBundle( definition=gen_picom_definition, executor=GenPicomCommandExecutor(gen_picom_definition) ) cli_bundle: CLIBundle = CLIBundleRegistry.create_bundle( dependencies=CLIBundleDependencies( service=service, parser=base_bundle.option_manager, commands=[gen_picom_bundle] ) ) cli: CLI = CLI(cli_bundle) return ARMPicomBundleRegistry.create_bundle( dependencies=ARMPicomBundleDependencies( base=base_bundle, service=service, subprocessor=subprocessor, cli=cli ) )
[docs] @classmethod def get_version(cls) -> str: ''' Returns the factory version. :return: The factory version. :exceptions: None. ''' return __version__