コード例 #1
0
    def write_to_yaml_file(self, file_name):
        """
        Convert the Python dictionary to Yaml and write it to the specified file.
        :param file_name: the file name to which to write the Yaml output
        :return: The canonical java.io.File object for the Yaml File
        :raises: YamlException: if an error occurs while converting the dictionary to Yaml or writing to the file
        """
        _method_name = 'writeToYamlFile'

        self._logger.entering(file_name,
                              class_name=self._class_name,
                              method_name=_method_name)
        try:
            yaml_file = JFileUtils.validateWritableFile(file_name)
        except JIllegalArgumentException, iae:
            yaml_ex = exception_helper.create_yaml_exception(
                'WLSDPLY-18009',
                file_name,
                iae.getLocalizedMessage(),
                error=iae)
            self._logger.throwing(class_name=self._class_name,
                                  method_name=_method_name,
                                  error=yaml_ex)
            raise yaml_ex
コード例 #2
0
        except JFileNotFoundException, fnfe:
            yaml_ex = exception_helper.create_yaml_exception(
                'WLSDPLY-18010',
                file_name,
                fnfe.getLocalizedMessage(),
                error=fnfe)
            self._logger.throwing(class_name=self._class_name,
                                  method_name=_method_name,
                                  error=yaml_ex)
            self._close_streams(fos, writer)
            raise yaml_ex
        except JIOException, ioe:
            yaml_ex = exception_helper.create_yaml_exception(
                'WLSDPLY-18011',
                file_name,
                ioe.getLocalizedMessage(),
                error=ioe)
            self._logger.throwing(class_name=self._class_name,
                                  method_name=_method_name,
                                  error=yaml_ex)
            self._close_streams(fos, writer)
            raise yaml_ex

        self._close_streams(fos, writer)
        self._logger.exiting(class_name=self._class_name,
                             method_name=_method_name,
                             result=yaml_file)
        return yaml_file

    def _write_dictionary_to_yaml_file(self, dictionary, writer, indent=''):