def _parse_yaml(self): """ Parse the Yaml file and convert it into a Python dictionary. :return: the Python dictionary """ _method_name = '_parse_yaml' from wlsdeploy.yaml.yaml_translator import YamlToPython as JYamlToPython self.logger.finer('WLSDPLY-01711', 'YAML', self.file_name, class_name=self._class_name, method_name=_method_name) try: return JYamlToPython(self.file_name, self.use_ordering).parse() except JYamlException, ye: translate_ex = exception_helper.create_translate_exception( 'WLSDPLY-01710', self.file_name, ye.getLocalizedMessage(), error=ye) self.logger.throwing(translate_ex, class_name=self._class_name, method_name=_method_name) raise translate_ex
def _write_to_yaml_file(self, file_name): """ Convert the Python dictionary to Yaml and write it to a file. :param file_name: the Yaml file name :return: the java.io.File object """ _method_name = '_write_to_yaml_file' from wlsdeploy.yaml.yaml_translator import PythonToYaml as JPythonToYaml self.logger.finer('WLSDPLY-01712', 'YAML', file_name, class_name=self._class_name, method_name=_method_name) try: writer = JPythonToYaml(self.dictionary) writer.set_hyphenate_lists(self._hyphenate_yaml_lists) writer.write_to_yaml_file(file_name) except JYamlException, ye: translate_ex = exception_helper.create_translate_exception( 'WLSDPLY-01713', file_name, ye.getLocalizedMessage(), error=ye) self.logger.throwing(translate_ex, class_name=self._class_name, method_name=_method_name) raise translate_ex
def _parse_json(self): """ Parse the JSON file and convert it into a Python dictionary. :return: the Python dictionary """ _method_name = '_parse_json' from wlsdeploy.json.json_translator import JsonToPython as JJsonToPython self.logger.finer('WLSDPLY-03078', 'JSON', self.file_name, class_name=self._class_name, method_name=_method_name) try: return JJsonToPython(self.file_name, self.use_ordering).parse() except JJsonException, je: translate_ex = exception_helper.create_translate_exception( 'WLSDPLY-01710', self.file_name, je.getLocalizedMessage(), error=je) self.logger.throwing(translate_ex, class_name=self._class_name, method_name=_method_name) raise translate_ex
def _write_to_json_file(self, file_name): """ Convert the Python dictionary to JSON and write it to a file. :param file_name: the JSON file name :return: the java.io.File object """ _method_name = '_write_to_json_file' from wlsdeploy.json.json_translator import PythonToJson as JPythonToJson self.logger.finer('WLSDPLY-01712', 'JSON', file_name, class_name=self._class_name, method_name=_method_name) try: return JPythonToJson(self.dictionary).write_to_json_file(file_name) except JJsonException, je: translate_ex = exception_helper.create_translate_exception('WLSDPLY-01713', file_name, je.getLocalizedMessage(), error=je) self.logger.throwing(translate_ex, class_name=self._class_name, method_name=_method_name) raise translate_ex