def _validate_model_file_arg(self, value):
        method_name = '_validate_model_file_arg'

        result_model_files = []  # type: list
        if self._allow_multiple_models:
            model_files = get_model_files(value)
        else:
            model_files = [value]

        for model_file in model_files:
            try:
                model_file = JFileUtils.validateFileName(model_file)
                model_file = model_file.getAbsolutePath()
                result_model_files.append(model_file)
            except JIllegalArgumentException, iae:
                ex = exception_helper.create_cla_exception(
                    'WLSDPLY-01617',
                    model_file,
                    iae.getLocalizedMessage(),
                    error=iae)
                ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
                self._logger.throwing(ex,
                                      class_name=self._class_name,
                                      method_name=method_name)
                raise ex
示例#2
0
    def _validate_variable_properties_file_arg(self, value):
        method_name = '_validate_variable_properties_file_arg'

        try:
            variables = JFileUtils.validateFileName(value)
        except JIllegalArgumentException, iae:
            ex = exception_helper.create_cla_exception('WLSDPLY-01620', value, iae.getLocalizedMessage(), error=iae)
            ex.setExitCode(self.ARG_VALIDATION_ERROR_EXIT_CODE)
            self._logger.throwing(ex, class_name=self._class_name, method_name=method_name)
            raise ex
    def parse(self):
        """
        Based on the syntax of the file, parse the contents of the file into a python dictionary.
        :return: dictionary parsed from the file contents
        :raises TranslateException: if an error occurs
        """
        _method_name = 'parse'

        self.logger.entering(class_name=self._class_name, method_name=_method_name)
        # throws IllegalArgument if not a valid existing file
        model_file = JFileUtils.validateFileName(self.file_name)
        # yaml is the default. For now, if the file extension is not known, then parse the contents as yaml
        if JFileUtils.isJsonFile(model_file):
            result_dict = self._parse_json()
        else:
            result_dict = self._parse_yaml()

        # called method already logged result. don't log it again
        self.logger.exiting(class_name=self._class_name, method_name=_method_name)
        return result_dict