예제 #1
0
def get_catalog_html_resource_output_full_path(root_output_folder):
    output_catalog_html_root_path = _plPath(
        _environment_config_local['output_catalog_html_resource']['root_path'])
    output_catalog_html_root_full_path = root_output_folder.joinpath(
        output_catalog_html_root_path)

    return output_catalog_html_root_full_path
예제 #2
0
def get_catalog_chm_file_full_path():
    global _magic_value_config_local
    global _message_config_local

    # Result placeholder
    catalog_file_full_path = None

    try:
        # Glob all potential catalog file
        # Call it a list, but see python generator for more information
        catalog_file_list = _plPath(crDevInput.unpackedChmFolder) \
            .glob(_magic_value_config_local['chm']['catalog_file_search_pattern'])

        # Expect only one catalog file
        catalog_file_list_count = 0

        # Explore the glob generator
        for catalog_file_glob_result in catalog_file_list:
            # Increase file count on every loop
            catalog_file_list_count = catalog_file_list_count + 1

            # Prevent more than one catalog file
            if catalog_file_list_count > 1:
                crPrintCyan(
                    _message_config_local['err']['multiple_catalog_file'])
                raise CrNotImplementedError(
                    _message_config_local['err']['multiple_catalog_file'])

            # Everything is fine, copy it as plPath
            catalog_file_full_path = _plPath(catalog_file_glob_result)

        # After explored the generator
        if catalog_file_list_count == 0:
            # Nothing found, raise error
            error_message = _message_config_local['err'][
                'catalog_file_not_found']
            crPrintCyan(error_message)
            raise CrFileNotFoundError(error_message)
    except:
        raise

    return catalog_file_full_path
예제 #3
0
def _load_magic_value_config():
    magic_value_config_path = _plPath(
        _crGlobalLevel.environment_config['dev']['magic_value_config_path'])

    if _osPath.exists(magic_value_config_path) is False:
        error_message = _crGlobalLevel.message_config['err']['software_broken'] \
            + str(magic_value_config_path)
        _crLog.crPrintCyan(error_message)
        raise _crException.CrFileNotFoundError(error_message)

    _crGlobalLevel.magic_value_config.read(magic_value_config_path)
예제 #4
0
def copy_catalog_html_resource(output_folder_path):
    try:
        data_catalog_html_resource_root_full_path = _plPath(
            _environment_config_local['data_catalog_html_resource']
            ['root_full_path'])

        _copytree(data_catalog_html_resource_root_full_path,
                  output_folder_path,
                  dirs_exist_ok=True)
    except:
        error_message = _message_config_local['err']['failed_to_copy_file']
        _crLog.crPrintCyan(error_message)
        raise
예제 #5
0
def _load_environment_config():
    environment_config_path = _plPath('environment.ini')

    if _osPath.exists(environment_config_path) is False:
        # Message config not yet loaded
        error_message = "Config file missing: " + str(environment_config_path)
        _crLog.crPrintCyan(error_message)
        raise _crException.CrFileNotFoundError(error_message)

    _crGlobalLevel.environment_config.read(environment_config_path)

    # Apply locale
    _crGlobalLevel.environment_config = _crLocale.apply_locale_to_environment_config(
        _crGlobalLevel.environment_config)
예제 #6
0
def _load_message_config():
    message_config_path = _plPath(
        _crGlobalLevel.environment_config['message']['config_message_path'])

    if _osPath.exists(message_config_path) is False:
        # Message config not yet loaded
        error_message = "Config file missing: " + str(message_config_path)
        _crLog.crPrintCyan(error_message)
        raise _crException.CrFileNotFoundError(error_message)

    _crGlobalLevel.message_config.read(message_config_path, encoding='utf-8')

    # Apply preprocessor
    _crGlobalLevel.message_config = _crMessageConfigPreprocess.apply_message_config_preprocessor(
        _crGlobalLevel.message_config)
예제 #7
0
def _my_locale_parser(config_environment):
    # Get current system language
    language_root = config_environment['language']['root_path']
    system_language = get_system_language()
    current_language = language_root + system_language + '/'  # language/en_US/

    # Confirm the language files are exists.
    # If not, use default fallback language
    current_language_exists = _osPath.exists(_plPath(current_language))
    if current_language_exists is False:
        current_language = config_environment['language']['fallback_path']

    # Apply language to path
    config_message_path = config_environment['message']['message_config_path']
    config_message_path = current_language + config_message_path  # language/en_US/message.xml

    # Put it back
    config_environment['message']['config_message_path'] = config_message_path

    return config_environment
예제 #8
0
def get_root_output_folder_full_path():
    output_folder = _plPath(_crEnvironmentUtil.crDevInput.outputFolder)

    _crEnvironmentUtil.crCreateFolder(output_folder)

    return output_folder