# Path: mod/log.py
# RED = '\033[1;31m'
# GREEN = '\033[1;32m'
# YELLOW = '\033[1;33m'
# BLUE = '\033[1;36m'
# DEF = '\033[0;0m'
# def error(msg, fatal=True) :
# def warn(msg) :
# def ok(item, status) :
# def failed(item, status) :
# def optional(item, status) :
# def info(msg) :
# def colored(color, msg) :
# 
# Path: mod/util.py
# def fix_path(path) :
# def get_workspace_dir(fips_dir) :
# def get_project_dir(fips_dir, proj_name) :
# def get_build_root_dir(fips_dir, proj_name):
# def get_deploy_root_dir(fips_dir, proj_name):
# def get_build_dir(fips_dir, proj_name, cfg) :
# def get_deploy_dir(fips_dir, proj_name, cfg) :
# def get_fips_dir(proj_dir, name):
# def get_configs_dir(proj_dir):
# def get_verbs_dir(proj_dir):
# def get_generators_dir(proj_dir):
# def get_toolchains_dir(proj_dir):
# def get_giturl_from_url(url) :
# def get_gitbranch_from_url(url) :
# def get_project_name_from_url(url) :
# def get_project_name_from_dir(proj_dir) :
# def load_fips_yml(proj_dir) :
# def lookup_target_cwd(proj_dir, target) :
# def is_valid_project_dir(proj_dir) :
# def ensure_valid_project_dir(proj_dir) :
# def is_git_url(url) :
# def confirm(question) :
# def url_download_hook(count, block_size, total_size) :
# def get_host_platform() :
# def get_cfg_target_list(fips_dir, proj_dir, cfg):
# def get_cfg_headersdirs_by_target(fips_dir, proj_dir, cfg):
# def get_cfg_defines_by_target(fips_dir, proj_dir, cfg):
# def get_num_cpucores():
# 
# Path: mod/config.py
# def valid_build_tool(name) :
# def get_default_config() :
# def get_toolchain(fips_dir, proj_dir, cfg) :
# def exists(pattern, proj_dirs) : 
# def get_config_dirs(fips_dir, proj_dir) :
# def list(fips_dir, proj_dir, pattern) :
# def load(fips_dir, proj_dir, pattern) :
# def missing_build_tools(fips_dir, tool_name) :
# def check_sdk(fips_dir, platform_name) :
# def check_config_valid(fips_dir, proj_dir, cfg, print_errors=False) :


import yaml
import os.path
from mod import log, util, config
    :param value:       new value associated with key
    """
    util.ensure_valid_project_dir(proj_dir)

    settings = load(proj_dir)
    settings[key] = value
    save(proj_dir, settings)

    proj_name = util.get_project_name_from_dir(proj_dir)
    if type(value) is bool :
        value_str = 'on' if value else 'off'
    else :
        value_str = str(value)
    log.info("'{}' set to '{}' in project '{}'".format(key, value_str, proj_name))

#-------------------------------------------------------------------------------
def unset(proj_dir, key) :
    """delete a settings value from the project-local settings file

    :param proj_dir:    absolute project directory
    :param key:         settings key
    """
    util.ensure_valid_project_dir(proj_dir)

    settings = load(proj_dir)
    if key in settings :
        del settings[key]
    save(proj_dir, settings)

    proj_name = util.get_project_name_from_dir(proj_dir)

# Path: mod/log.py
# RED = '\033[1;31m'
# GREEN = '\033[1;32m'
# YELLOW = '\033[1;33m'
# BLUE = '\033[1;36m'
# DEF = '\033[0;0m'
# def error(msg, fatal=True) :
# def warn(msg) :
# def ok(item, status) :
# def failed(item, status) :
# def optional(item, status) :
# def info(msg) :
# def colored(color, msg) :
# 
# Path: mod/util.py
# def fix_path(path) :
# def get_workspace_dir(fips_dir) :
# def get_project_dir(fips_dir, proj_name) :
# def get_build_root_dir(fips_dir, proj_name):
# def get_deploy_root_dir(fips_dir, proj_name):
# def get_build_dir(fips_dir, proj_name, cfg) :
# def get_deploy_dir(fips_dir, proj_name, cfg) :
# def get_fips_dir(proj_dir, name):
# def get_configs_dir(proj_dir):
# def get_verbs_dir(proj_dir):
# def get_generators_dir(proj_dir):
# def get_toolchains_dir(proj_dir):
# def get_giturl_from_url(url) :
# def get_gitbranch_from_url(url) :
# def get_project_name_from_url(url) :
# def get_project_name_from_dir(proj_dir) :
# def load_fips_yml(proj_dir) :
# def lookup_target_cwd(proj_dir, target) :
# def is_valid_project_dir(proj_dir) :
# def ensure_valid_project_dir(proj_dir) :
# def is_git_url(url) :
# def confirm(question) :
# def url_download_hook(count, block_size, total_size) :
# def get_host_platform() :
# def get_cfg_target_list(fips_dir, proj_dir, cfg):
# def get_cfg_headersdirs_by_target(fips_dir, proj_dir, cfg):
# def get_cfg_defines_by_target(fips_dir, proj_dir, cfg):
# def get_num_cpucores():
# 
# Path: mod/config.py
# def valid_build_tool(name) :
# def get_default_config() :
# def get_toolchain(fips_dir, proj_dir, cfg) :
# def exists(pattern, proj_dirs) : 
# def get_config_dirs(fips_dir, proj_dir) :
# def list(fips_dir, proj_dir, pattern) :
# def load(fips_dir, proj_dir, pattern) :
# def missing_build_tools(fips_dir, tool_name) :
# def check_sdk(fips_dir, platform_name) :
# def check_config_valid(fips_dir, proj_dir, cfg, print_errors=False) :


# Path: mod/settings.py
import yaml
import os.path
from mod import log, util, config

    :param value:       new value associated with key
    """
    util.ensure_valid_project_dir(proj_dir)

    settings = load(proj_dir)
    settings[key] = value
    save(proj_dir, settings)

    proj_name = util.get_project_name_from_dir(proj_dir)
    if type(value) is bool :
        value_str = 'on' if value else 'off'
    else :
        value_str = str(value)
    log.info("'{}' set to '{}' in project '{}'".format(key, value_str, proj_name))

#-------------------------------------------------------------------------------
def unset(proj_dir, key) :
    """delete a settings value from the project-local settings file

    :param proj_dir:    absolute project directory
    :param key:         settings key
    """
    util.ensure_valid_project_dir(proj_dir)

    settings = load(proj_dir)
    if key in settings :
        del settings[key]
    save(proj_dir, settings)

    proj_name = util.get_project_name_from_dir(proj_dir)

    log.info("'{}' unset in project '{}'".format(key, proj_name))