# Path: cpt/tools.py
# def split_colon_env(varname):
#     if os.getenv(varname) is None:
#         return None
#     if os.getenv(varname).strip() == "":
#         return []
#     return [a.strip() for a in list(filter(None, os.getenv(varname, "").split(",")))]
# 
# def transform_list_options_to_dict(list_options):
#     assert isinstance(list_options, list)
#     dict_options = {}
#     for option in list_options:
#         if '=' not in option:
#             raise RuntimeError("Option %s does not contain '='" % option)
#         option_obj = option.split('=')
#         dict_options[option_obj[0]] = option_obj[1]
#     return dict_options


import copy
import os
from collections import namedtuple
from conans.model.ref import ConanFileReference
from conans.model.version import Version
from cpt.tools import split_colon_env, transform_list_options_to_dict
default_visual_versions = ["14", "15", "16", "17"]
default_visual_runtimes = ["MT", "MD", "MTd", "MDd"]
default_msvc_versions = ["19.0", "19.10", "19.20", "19.30"]
default_msvc_runtimes = ["static", "dynamic"]
default_apple_clang_versions = ["9.0", "9.1", "10.0", "11.0", "12.0"]
default_archs = ["x86", "x86_64"]
default_build_types = ["Release", "Debug"]
default_cppstds = [None]


def get_mingw_package_reference():
    env_ref = os.getenv("CONAN_MINGW_INSTALLER_REFERENCE")
    return ConanFileReference.loads(env_ref or "mingw-w64/8.1")


def get_mingw_config_from_env():
    tmp = os.getenv("MINGW_CONFIGURATIONS", "")
    # 4.9@x86_64@seh@posix",4.9@x86_64@seh@win32"
    if not tmp:
        return []
    ret = []
    confs = tmp.split(",")
    for conf in confs:
        conf = conf.strip()
        ret.append(conf.split("@"))
    return ret


def get_env_visual_toolsets():
    ret = {}

# Path: cpt/tools.py
# def split_colon_env(varname):
#     if os.getenv(varname) is None:
#         return None
#     if os.getenv(varname).strip() == "":
#         return []
#     return [a.strip() for a in list(filter(None, os.getenv(varname, "").split(",")))]
# 
# def transform_list_options_to_dict(list_options):
#     assert isinstance(list_options, list)
#     dict_options = {}
#     for option in list_options:
#         if '=' not in option:
#             raise RuntimeError("Option %s does not contain '='" % option)
#         option_obj = option.split('=')
#         dict_options[option_obj[0]] = option_obj[1]
#     return dict_options


# Path: cpt/builds_generator.py
import copy
import os
from collections import namedtuple
from conans.model.ref import ConanFileReference
from conans.model.version import Version
from cpt.tools import split_colon_env, transform_list_options_to_dict

default_visual_versions = ["14", "15", "16", "17"]
default_visual_runtimes = ["MT", "MD", "MTd", "MDd"]
default_msvc_versions = ["19.0", "19.10", "19.20", "19.30"]
default_msvc_runtimes = ["static", "dynamic"]
default_apple_clang_versions = ["9.0", "9.1", "10.0", "11.0", "12.0"]
default_archs = ["x86", "x86_64"]
default_build_types = ["Release", "Debug"]
default_cppstds = [None]


def get_mingw_package_reference():
    env_ref = os.getenv("CONAN_MINGW_INSTALLER_REFERENCE")
    return ConanFileReference.loads(env_ref or "mingw-w64/8.1")


def get_mingw_config_from_env():
    tmp = os.getenv("MINGW_CONFIGURATIONS", "")
    # 4.9@x86_64@seh@posix",4.9@x86_64@seh@win32"
    if not tmp:
        return []
    ret = []
    confs = tmp.split(",")
    for conf in confs:
        conf = conf.strip()
        ret.append(conf.split("@"))
    return ret


def get_env_visual_toolsets():
    ret = {}

    var = split_colon_env("CONAN_VISUAL_TOOLSETS")