Import registry settings from a Windows ``REG`` file by invoking ``REG.EXE``.

    .. versionadded:: 2018.3.0

    Args:

        source (str):
            The full path of the ``REG`` file. This can be either a local file
            path or a URL type supported by salt (e.g. ``salt://salt_master_path``)

        use_32bit_registry (bool):
            If the value of this parameter is ``True`` then the ``REG`` file
            will be imported into the Windows 32 bit registry. Otherwise the
            Windows 64 bit registry will be used.

    Returns:
        bool: True if successful, otherwise an error is raised

    Raises:
        ValueError: If the value of ``source`` is an invalid path or otherwise
            causes ``cp.cache_file`` to return ``False``
        CommandExecutionError: If ``reg.exe`` exits with a non-0 exit code

    CLI Example:

        .. code-block:: bash

            salt machine1 reg.import_file salt://win/printer_config/110_Canon/postinstall_config.reg

def import_file(source, use_32bit_registry=False):
    '''
    Import registry settings from a Windows ``REG`` file by invoking ``REG.EXE``.

    .. versionadded:: 2018.3.0

    Args:

        source (str):
            The full path of the ``REG`` file. This can be either a local file
            path or a URL type supported by salt (e.g. ``salt://salt_master_path``)

        use_32bit_registry (bool):
            If the value of this parameter is ``True`` then the ``REG`` file
            will be imported into the Windows 32 bit registry. Otherwise the
            Windows 64 bit registry will be used.

    Returns:
        bool: True if successful, otherwise an error is raised

    Raises:
        ValueError: If the value of ``source`` is an invalid path or otherwise
            causes ``cp.cache_file`` to return ``False``
        CommandExecutionError: If ``reg.exe`` exits with a non-0 exit code

    CLI Example:

        .. code-block:: bash

            salt machine1 reg.import_file salt://win/printer_config/110_Canon/postinstall_config.reg

    '''
    cache_path = __salt__['cp.cache_file'](source)
    if not cache_path:
        error_msg = "File/URL '{0}' probably invalid.".format(source)
        raise ValueError(error_msg)
    if use_32bit_registry:
        word_sz_txt = "32"
    else:
        word_sz_txt = "64"
    cmd = 'reg import "{0}" /reg:{1}'.format(cache_path, word_sz_txt)
    cmd_ret_dict = __salt__['cmd.run_all'](cmd, python_shell=True)
    retcode = cmd_ret_dict['retcode']
    if retcode != 0:
        raise CommandExecutionError(
            'reg.exe import failed',
            info=cmd_ret_dict
        )
    return True