Skip to content

Commit 71bfa1a

Browse files
committed
prevent parsing empty uri
1 parent a243af9 commit 71bfa1a

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

csvwlib/converter/ToRDFConverter.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def parse_virtual_columns(self, row_node, atdm_row, table_metadata):
8282
self.graph.add((row_node, CSVW.describes, subject))
8383
else:
8484
print(f"term {virtual_column['propertyUrl']} not in namespaces")
85-
S
85+
8686
def _add_file_metadata(self, metadata, node):
8787
language = JSONLDUtils.language(self.metadata.get('@context',[]))
8888
for key, value in metadata.items():
@@ -165,6 +165,8 @@ def _object_node(value, col_metadata, atdm_row, tm_url):
165165

166166
@staticmethod
167167
def _normalize_to_uri(string):
168+
if string in [None, '']:
169+
return ''
168170
string = quote(string, safe='')
169171
string = string.replace('-', '%2D')
170172
return string

csvwlib/utils/TypeConverter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TypeConverter:
55

66
@staticmethod
77
def convert_if_necessary(value, column_metadata):
8-
if 'datatype' not in column_metadata:
8+
if 'datatype' not in column_metadata or not isinstance(column_metadata['datatype'], dict):
99
return value
1010

1111
return TypeConverter.convert(value, column_metadata['datatype'])

csvwlib/utils/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def validate_metadata(self, metadata):
101101
self.check_titles(table)
102102

103103
def check_csv_reference(self, table, metadata):
104-
if not self.start_url.endswith('.csv'):
104+
if not (self.start_url or "").endswith('.csv'):
105105
return
106106
if table['url'] != self.start_url:
107107
for key in list(metadata.keys()):

0 commit comments

Comments
 (0)