Changeset View
Changeset View
Standalone View
Standalone View
swh/indexer/metadata_dictionary/utils.py
Show First 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | ) -> None: | ||||
... ) | ... ) | ||||
>>> pprint(set(graph.triples((subject, predicate, None)))) | >>> pprint(set(graph.triples((subject, predicate, None)))) | ||||
{(rdflib.term.URIRef('http://example.org/test-software'), | {(rdflib.term.URIRef('http://example.org/test-software'), | ||||
rdflib.term.URIRef('http://schema.org/license'), | rdflib.term.URIRef('http://schema.org/license'), | ||||
rdflib.term.URIRef('https://www.apache.org/licenses/LICENSE-2.0.txt'))} | rdflib.term.URIRef('https://www.apache.org/licenses/LICENSE-2.0.txt'))} | ||||
""" | """ | ||||
if not isinstance(url, str): | if not isinstance(url, str): | ||||
return | return | ||||
if " " in url or not urllib.parse.urlparse(url).netloc: | try: | ||||
parsed_url = urllib.parse.urlparse(url) | |||||
except Exception: | |||||
return | |||||
if " " in url or not parsed_url.netloc: | |||||
return | return | ||||
graph.add((subject, predicate, rdflib.term.URIRef(url))) | graph.add((subject, predicate, rdflib.term.URIRef(url))) |