def validate_model_present(program_name, optional_arg_map):
    """
    Determine if the model file was passed separately or requires extraction from the archive.
    If the model is in the archive, extract it to the temporary model location, and set that file as the
    MODEL_FILE_SWITCH argument.
    The MODEL_FILE_SWITCH value may be specified as multiple comma-separated models.
    :param program_name: the name of the calling program, for logging
    :param optional_arg_map: the optional arguments from the command line
    :raises CLAException: if the specified model is not an existing file, or the model is not found in the archive,
    or the model is not found from either argument
    """
    _method_name = 'validate_model_present'
    global __tmp_model_dir

    if CommandLineArgUtil.MODEL_FILE_SWITCH in optional_arg_map:
        model_file_value = optional_arg_map[
            CommandLineArgUtil.MODEL_FILE_SWITCH]
        model_files = cla_utils.get_model_files(model_file_value)

        for model_file in model_files:
            try:
                FileUtils.validateExistingFile(model_file)
            except IllegalArgumentException, iae:
                ex = exception_helper.create_cla_exception(
                    'WLSDPLY-20006',
                    program_name,
                    model_file,
                    iae.getLocalizedMessage(),
                    error=iae)
                ex.setExitCode(
                    CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE)
                __logger.throwing(ex,
                                  class_name=_class_name,
                                  method_name=_method_name)
                raise ex
def merge_model_files(model_file_value):
    """
    Merge the model files specified by the model file value.
    It may be a single file, or a comma-separated list of files.
    :param model_file_value: the value specified as a command argument
    :return: the merge model dictionary
    """
    merged_model = OrderedDict()
    model_files = cla_utils.get_model_files(model_file_value)

    for model_file in model_files:
        model = FileToPython(model_file, True).parse()
        _merge_dictionaries(merged_model, model)

    return merged_model
def __encrypt_model_and_variables(model_context):
    """
    Encrypt the model and variables file, if provided.
    :param model_context: the model context object containing the processed command-line arguments
    :return: the exit code that should be used to exit the program
    """
    _method_name = '__encrypt_model_and_variables'

    model_files = cla_utils.get_model_files(model_context.get_model_file())
    models = dict()
    for model_file in model_files:
        try:
            models[model_file] = FileToPython(model_file, True).parse()
        except TranslateException, te:
            __logger.severe('WLSDPLY-04206', _program_name, model_file, te.getLocalizedMessage(), error=te,
                            class_name=_class_name, method_name=_method_name)
            return CommandLineArgUtil.PROG_ERROR_EXIT_CODE