Exemplo n.º 1
0
class Container(DeclarativeContainer):
    """The Container class wires all reusable components together."""
    logger = Singleton(Logger)

    platform_manager = Singleton(PlatformManager)
    task_manager = Singleton(TaskManager, logger)
    name_generator = Singleton(NameGenerator)
    path_manager = Singleton(PathManager, platform_manager)
    temp_manager = Singleton(TempManager)
    xml_manager = Singleton(XMLManager)
    http_client = Singleton(HTTPClient, logger)

    general_storage = Singleton(Storage, file=GENERAL_CONFIG_PATH)
    credentials_storage = Singleton(Storage, file=CREDENTIALS_CONFIG_PATH)
    cache_storage = Singleton(Storage, file=CACHE_PATH)

    cli_config_manager = Singleton(CLIConfigManager, general_storage,
                                   credentials_storage)

    api_client = Factory(
        APIClient,
        logger,
        http_client,
        user_id=cli_config_manager.provided.user_id.get_value()(),
        api_token=cli_config_manager.provided.api_token.get_value()())

    module_manager = Singleton(ModuleManager, logger, api_client, http_client)

    project_config_manager = Singleton(ProjectConfigManager, xml_manager)
    lean_config_manager = Singleton(LeanConfigManager, logger,
                                    cli_config_manager, project_config_manager,
                                    module_manager, cache_storage)
    output_config_manager = Singleton(OutputConfigManager, lean_config_manager)
    optimizer_config_manager = Singleton(OptimizerConfigManager, logger)

    project_manager = Singleton(ProjectManager, project_config_manager,
                                lean_config_manager, xml_manager,
                                platform_manager)

    cloud_runner = Singleton(CloudRunner, logger, api_client, task_manager)
    pull_manager = Singleton(PullManager, logger, api_client, project_manager,
                             project_config_manager, platform_manager)
    push_manager = Singleton(PushManager, logger, api_client, project_manager,
                             project_config_manager)
    data_downloader = Singleton(DataDownloader, logger, api_client,
                                lean_config_manager)
    cloud_project_manager = Singleton(CloudProjectManager, api_client,
                                      project_config_manager, pull_manager,
                                      push_manager, path_manager)

    docker_manager = Singleton(DockerManager, logger, temp_manager,
                               platform_manager)
    lean_runner = Singleton(LeanRunner, logger, project_config_manager,
                            lean_config_manager, output_config_manager,
                            docker_manager, module_manager, project_manager,
                            temp_manager, xml_manager)

    market_hours_database = Singleton(MarketHoursDatabase, lean_config_manager)

    shortcut_manager = Singleton(ShortcutManager, logger, lean_config_manager,
                                 platform_manager, cache_storage)
    update_manager = Singleton(UpdateManager, logger, http_client,
                               cache_storage, docker_manager)