+ return self.yang_class.from_xml_v2(self.model, decode(xml), strict=False) \
+ if not project else self._yang_pb_project_cls.from_xml_v2(self.model, decode(xml), strict=False)
+
+ def _from_json_file_hdl(self, file_hdl, project=None):
+ jstr = file_hdl.read()
+ self._log.debug("Convert from json file: {}".format(jstr))
+
+ try:
+ if not project:
+ desc_msg = self.yang_class.from_json(self.model, decode(jstr), strict=False)
+ else:
+ desc_msg = self._yang_pb_project_cls.from_json(self.model, decode(jstr), strict=False)
+
+ self._log.debug("desc_msg: {}".format(desc_msg.as_dict()))
+ return self.yang_class_project.from_dict(desc_msg.as_dict())
+ except Exception as e:
+ self._log.exception(e)
+ raise e
+
+ def _from_yaml_file_hdl(self, file_hdl, project=None):
+ yml = file_hdl.read()
+
+ try:
+ desc_msg = self.yang_class.from_yaml(self.model, decode(yml), strict=True)
+ except InvalidSchemaException as invalid_scheme_exception:
+ self._log.error("Exception raised during schema translation, %s. Launchpad will" \
+ "continue to process the remaining elements ", str(invalid_scheme_exception))
+ desc_msg = self.yang_class.from_yaml(self.model, decode(yml), strict=False)
+ except Exception as e:
+ self._log.exception(e)
+ raise e
+
+ return self.yang_class_project.from_dict(desc_msg.as_dict())