Skip to content

Commit b0257ed

Browse files
committed
[RDFWriter] Handle Unsupported RDF Format
Catch unsupported RDF Formats and Raise ValueError. Related to issue #215.
1 parent c3e328c commit b0257ed

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

odml/tools/format_converter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ def _convert_file(cls, input_path, output_path, res_format):
119119
p, _ = os.path.splitext(output_path)
120120
output_path = p + cls._conversion_formats[res_format]
121121
RDFWriter(odml.load(input_path)).write_file(output_path, res_format)
122+
else:
123+
raise ValueError("Format for output files is incorrect. "
124+
"Please choose from the list: {}".format(cls._conversion_formats.keys()))
122125

123126
@staticmethod
124127
def _create_sub_directory(dir_path):

odml/tools/rdf_converter.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,9 @@ def get_rdf_str(self, rdf_format="turtle"):
204204
Full lists see in odml.tools.format_converter.FormatConverter._conversion_formats
205205
:return: string object
206206
"""
207+
if rdf_format not in self._conversion_formats:
208+
raise ValueError("odml.RDFWriter.get_rdf_str: Format for output files is incorrect. "
209+
"Please choose from the list: {}".format(self._conversion_formats.keys()))
207210
return self.convert_to_rdf().serialize(format=rdf_format).decode("utf-8")
208211

209212
def write_file(self, filename, rdf_format="turtle"):

0 commit comments

Comments
 (0)