From 05b9fd801b64e521673718168a9a89d0ca64b11a Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 29 Mar 2021 09:21:58 +0200 Subject: [PATCH] Bugfixes --- src/cpl/dependency_injection/service_provider.py | 11 +++++------ src/cpl_cli/command/generate_service.py | 12 +++++------- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/cpl/dependency_injection/service_provider.py b/src/cpl/dependency_injection/service_provider.py index 86d0b478..e0de3984 100644 --- a/src/cpl/dependency_injection/service_provider.py +++ b/src/cpl/dependency_injection/service_provider.py @@ -25,18 +25,17 @@ class ServiceProvider(ServiceProviderABC): return None - def _get_service(self, service_type: type, parameter: Parameter) -> object: + def _get_service(self, parameter: Parameter) -> object: for descriptor in self._service_descriptors: - if descriptor.service_type == parameter.annotation or issubclass(descriptor.service_type, - parameter.annotation): + if descriptor.service_type == parameter.annotation or issubclass(descriptor.service_type, parameter.annotation): if descriptor.implementation is not None: return descriptor.implementation - implementation = self.build_service(service_type) + implementation = self.build_service(descriptor.service_type) if descriptor.lifetime == ServiceLifetimeEnum.singleton: descriptor.implementation = implementation - return descriptor.implementation + return implementation def build_service(self, service_type: type) -> object: for descriptor in self._service_descriptors: @@ -69,7 +68,7 @@ class ServiceProvider(ServiceProviderABC): params.append(self._configuration) else: - params.append(self._get_service(service_type, parameter)) + params.append(self._get_service(parameter)) return service_type(*params) diff --git a/src/cpl_cli/command/generate_service.py b/src/cpl_cli/command/generate_service.py index a83d2f1f..21c8b61a 100644 --- a/src/cpl_cli/command/generate_service.py +++ b/src/cpl_cli/command/generate_service.py @@ -1,7 +1,6 @@ import os from collections import Callable -from cpl.application.application_abc import ApplicationRuntimeABC from cpl.configuration.configuration_abc import ConfigurationABC from cpl.console.foreground_color_enum import ForegroundColorEnum from cpl.console.console import Console @@ -18,11 +17,10 @@ from cpl_cli.templates.template_file_abc import TemplateFileABC class GenerateService(CommandABC): - def __init__(self, configuration: ConfigurationABC, runtime: ApplicationRuntimeABC): + def __init__(self, configuration: ConfigurationABC): """ Service for the CLI command generate :param configuration: - :param runtime: """ CommandABC.__init__(self) @@ -54,7 +52,7 @@ class GenerateService(CommandABC): } self._config = configuration - self._runtime = runtime + self._env = self._config.environment @staticmethod def _help(message: str): @@ -105,7 +103,7 @@ class GenerateService(CommandABC): template = template(class_name, schematic, self._schematics[schematic]["Upper"], rel_path) - file_path = os.path.join(self._runtime.working_directory, template.path, template.name) + file_path = os.path.join(self._env.working_directory, template.path, template.name) if not os.path.isdir(os.path.dirname(file_path)): os.makedirs(os.path.dirname(file_path)) @@ -113,9 +111,9 @@ class GenerateService(CommandABC): Console.error(f'{String.first_to_upper(schematic)} already exists!') exit() - message = f'Creating {self._runtime.working_directory}/{template.path}/{template.name}' + message = f'Creating {self._env.working_directory}/{template.path}/{template.name}' if template.path == '': - message = f'Creating {self._runtime.working_directory}/{template.name}' + message = f'Creating {self._env.working_directory}/{template.name}' Console.spinner( message,