# Path: toolbox/config/common.py
# BUTTON_CONFIG_KEYS = {'text', 'hidden'}
# 
# CRP_TYPES = {'docker', 'gce', 'static'}
# 
# CURRENT_MAX_VERSION = 'v3.2'
# 
# CURRENT_MIN_VERSION = 'v3.1'
# 
# PROTOCOLS = {'udp', 'tcp', 'ssh', 'http', 'ws', CONTROLLER_PROTOCOL}
# 
# Path: toolbox/utils/utils.py
# def counted_error(*args, **kwargs) -> None:
#     """
#     Wrapper for logging.error that will increase the error_counter
#     """
#     global _error_counter  # pylint: disable=global-statement
#     _error_counter += 1
#     logging.error(*args, **kwargs)
# 
# def fatal_error(*args, **kwargs) -> None:
#     """
#     Abort execution with a fatal error
#     """
#     counted_error(*args, **kwargs)
#     counted_error_at_exit()


import os
import re
import yaml
    from packaging.version import parse as parse_version
    from pkg_resources import parse_version
from toolbox.config.common import BUTTON_CONFIG_KEYS, CRP_TYPES, CURRENT_MAX_VERSION, CURRENT_MIN_VERSION, PROTOCOLS
from .utils import counted_error, fatal_error
    """
    Read the config.yml file

    :param path: path to the file or the base directory
    :param pre_validate: check version and crp_type fields
    :return: dict
    """
    if os.path.isdir(path):
        path = os.path.join(path, 'config.yml')

    try:
        with open(path, 'r') as f:
            config = yaml.safe_load(f)

        if pre_validate:
            validate_version(config)
            get_crp_type(config)

        return config

    except Exception as e:
        fatal_error('%s(%s)', type(e).__name__, e)


def parse_bool(value) -> bool:
    return str(value).lower() in ('true', '1')


def validate_bool(key, value):
    if str(value).lower() not in ('true', 'false', '1', '0'):

# Path: toolbox/config/common.py
# BUTTON_CONFIG_KEYS = {'text', 'hidden'}
# 
# CRP_TYPES = {'docker', 'gce', 'static'}
# 
# CURRENT_MAX_VERSION = 'v3.2'
# 
# CURRENT_MIN_VERSION = 'v3.1'
# 
# PROTOCOLS = {'udp', 'tcp', 'ssh', 'http', 'ws', CONTROLLER_PROTOCOL}
# 
# Path: toolbox/utils/utils.py
# def counted_error(*args, **kwargs) -> None:
#     """
#     Wrapper for logging.error that will increase the error_counter
#     """
#     global _error_counter  # pylint: disable=global-statement
#     _error_counter += 1
#     logging.error(*args, **kwargs)
# 
# def fatal_error(*args, **kwargs) -> None:
#     """
#     Abort execution with a fatal error
#     """
#     counted_error(*args, **kwargs)
#     counted_error_at_exit()


# Path: toolbox/utils/config.py
import os
import re
import yaml
    from packaging.version import parse as parse_version
    from pkg_resources import parse_version
from toolbox.config.common import BUTTON_CONFIG_KEYS, CRP_TYPES, CURRENT_MAX_VERSION, CURRENT_MIN_VERSION, PROTOCOLS
from .utils import counted_error, fatal_error

    """
    Read the config.yml file

    :param path: path to the file or the base directory
    :param pre_validate: check version and crp_type fields
    :return: dict
    """
    if os.path.isdir(path):
        path = os.path.join(path, 'config.yml')

    try:
        with open(path, 'r') as f:
            config = yaml.safe_load(f)

        if pre_validate:
            validate_version(config)
            get_crp_type(config)

        return config

    except Exception as e:
        fatal_error('%s(%s)', type(e).__name__, e)


def parse_bool(value) -> bool:
    return str(value).lower() in ('true', '1')


def validate_bool(key, value):
    if str(value).lower() not in ('true', 'false', '1', '0'):

        counted_error('Invalid %s value. It must be boolean.', key)