"""
@file
@defgroup rtctk_clients_configTool Config Tool
@ingroup rtctk_clients

@brief Configuration tool for viewing and manipulating RTC configuration data.

@copyright
  SPDX-FileCopyrightText: 2023-2026 European Southern Observatory (ESO) @n
  SPDX-License-Identifier: LGPL-3.0-only
"""

import os
from wtools.module import declare_pyqtprogram

if os.environ.get("DDT_COLORMAP_PATH", None) == None:
    ddt_root = os.environ.get("PREFIX", None)
    if ddt_root is None:
        ddt_root = os.environ.get("INTROOT", "/elt/ddt")
    os.environ["DDT_COLORMAP_PATH"] = f"{ddt_root}/resource/config/colourmaps"

declare_pyqtprogram(
    target="rtctkConfigTool",
    py_program="src/rtctk_config_tool.py",
    py_package="src/rtctk/",
    use=[
        "clients.common",
        "clients.grafanaWidgets",
        "componentFramework.services.common",
        "componentFramework.services.persistentRepo",
        "componentFramework.services.runtimeRepo",
        "componentFramework.services.populateConfig",
        "componentFramework.pybindings",
    ],
    depends="cut.widgets.widgets cut.widgets.bindings cut.widgets.taurus",
    ut_attrs=dict(
        use=lambda pkgs, _: pkgs
        + [
            # Note that clients.configTool.pkg is normally added implicitly when we do not override
            # the dependencies for unit tests with ut_attrs. But we must explicit add it in our
            # case since we override the dependency list.
            "clients.configTool.pkg",
            "componentFramework.services.testSupport.oldb",
            "componentFramework.services.testSupport.persistentRepo",
            "componentFramework.services.testSupport.runtimeRepo",
        ]
    ),
    with_unit_test=True,
    with_ut_lib="pytest",
    with_doctest=False,
)
