Skip to content

Commit 571253c

Browse files
committed
Add entity type validation
1 parent 6a67c65 commit 571253c

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

scripts/check_profiles.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,13 @@
3434
if "json" not in content_type:
3535
raise ValueError(f"{url} does not return JSON-LD (Content type: {content_type})")
3636

37-
for url in profile_urls:
37+
temp_g = Graph()
3838
base_iri = urljoin(url, '.') if url.endswith("ro-crate-metadata.json") else f"{url.rstrip('/')}/"
39-
g.parse(url, format="json-ld", publicID=base_iri)
39+
temp_g.parse(url, format="json-ld", publicID=base_iri)
40+
if any(temp_g.subjects(RDF.type, profile_class)):
41+
g += temp_g
42+
else:
43+
raise ValueError(f"No profile entity found in {url}")
4044

4145
datetime_pattern = re.compile(r"^-?\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(Z|[+-]\d{2}:\d{2})?$")
4246
date_pattern = re.compile(r"^-?\d{4}-\d{2}-\d{2}$")

scripts/profile_urls.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
https://trefx.uk/5s-crate/0.4/ro-crate-metadata.json
22
https://www.researchobject.org/workflow-run-crate/profiles/0.5/process_run_crate/ro-crate-metadata.json
33
https://www.researchobject.org/workflow-run-crate/profiles/0.5/workflow_run_crate/ro-crate-metadata.json
4-
https://about.workflowhub.eu/Workflow-RO-Crate/ro-crate-metadata.json
54
https://www.researchobject.org/workflow-run-crate/profiles/0.5/provenance_run_crate/ro-crate-metadata.json

0 commit comments

Comments
 (0)