Skip to content

Commit 51a1f8c

Browse files
committed
release: 🔖 version 0.7.0
2 parents 97bcd8b + 5f1ea9b commit 51a1f8c

File tree

5 files changed

+40
-2
lines changed

5 files changed

+40
-2
lines changed

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "roc-validator"
3-
version = "0.6.5"
3+
version = "0.7.0"
44
description = "A Python package to validate RO-Crates"
55
authors = [
66
"Marco Enrico Piras <[email protected]>",

‎rocrate_validator/profiles/ro-crate/must/4_data_entity_metadata.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ def check_availability(self, context: ValidationContext) -> bool:
3838
logger.debug("Ensure the presence of the Data Entity '%s' within the RO-Crate", entity.id)
3939
try:
4040
logger.debug("Ensure the presence of the Data Entity '%s' within the RO-Crate", entity.id)
41+
if entity.has_local_identifier():
42+
logger.debug(
43+
"Ignoring the Data Entity '%s' as it is a local entity with a local identifier. "
44+
"According to the RO-Crate specification, local entities with local identifiers "
45+
"are not required to be included in the RO-Crate payload"
46+
"(see https://github.com/ResearchObject/ro-crate/issues/400#issuecomment-2779152885 and "
47+
"https://github.com/ResearchObject/ro-crate/pull/426 for more details)",
48+
entity.id)
49+
continue
4150
if not entity.has_relative_path():
4251
logger.debug(
4352
"Ignoring the Data Entity '%s' as it is a local entity with an absolute path. "

‎rocrate_validator/profiles/ro-crate/must/4_data_entity_metadata.ttl‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ ro-crate:FileDataEntity a sh:NodeShape ;
4848
SELECT ?this
4949
WHERE {
5050
?this a schema:MediaObject .
51-
FILTER(?this != ro:ro-crate-metadata.json)
51+
?metadatafile schema:about ?root .
52+
FILTER(contains(str(?metadatafile), "ro-crate-metadata.json"))
53+
FILTER(!STRSTARTS(STR(?this), CONCAT(STR(?root), "#")))
5254
}
5355
"""
5456
] ;
@@ -86,8 +88,10 @@ ro-crate:DirectoryDataEntity a sh:NodeShape ;
8688
WHERE {
8789
?this a schema:Dataset .
8890
?metadatafile schema:about ?root .
91+
# Exclude all dataset entities that ends with `./#<something>`
8992
FILTER(contains(str(?metadatafile), "ro-crate-metadata.json"))
9093
FILTER(?this != ?root)
94+
FILTER(!STRSTARTS(STR(?this), CONCAT(STR(?root), "#")))
9195
}
9296
"""
9397
] ;

‎rocrate_validator/rocrate.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ def has_absolute_path(self) -> bool:
135135
def has_relative_path(self) -> bool:
136136
return not self.has_absolute_path()
137137

138+
def has_local_identifier(self) -> bool:
139+
has_local_id = self.id.startswith('#') or \
140+
f"{self.ro_crate.uri}/#" in self.id or \
141+
f"file://{self.ro_crate.uri}/#" in self.id
142+
logger.debug("Identifier '%s' is %s a local identifier", self.id,
143+
"" if has_local_id else " not")
144+
return has_local_id
145+
138146
def has_type(self, entity_type: str) -> bool:
139147
assert isinstance(entity_type, str), "Entity type must be a string"
140148
e_types = self.type if isinstance(self.type, list) else [self.type]

‎tests/data/crates/valid/rocrate_with_data_entities/ro-crate-metadata.json‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,13 @@
155155
"encodingFormat": "image/jpeg",
156156
"name": "2018-06-11 12.56.14.jpg (input)"
157157
},
158+
{
159+
"@id": "#thisIsNotDataEntity",
160+
"@type": "File",
161+
"description": "A File type that is not a data entity",
162+
"encodingFormat": "text/plain",
163+
"name": "thisIsNotDataEntity.txt"
164+
},
158165
{
159166
"@id": "pics/2019-06-11 12.56.14.jpg",
160167
"@type": "File",
@@ -172,6 +179,16 @@
172179
"@id": "http://spdx.org/licenses/CC0-1.0"
173180
}
174181
},
182+
{
183+
"@id": "#xdata%20set/",
184+
"@type": "Dataset",
185+
"name": "Data set with a local ID",
186+
"description": "A dataset",
187+
"datePublished": "2024-05-17T01:04:52+01:00",
188+
"license": {
189+
"@id": "http://spdx.org/licenses/CC0-1.0"
190+
}
191+
},
175192
{
176193
"@id": "data%20set2/",
177194
"@type": "Dataset",

0 commit comments

Comments
 (0)