Skip to content

Commit aed54bf

Browse files
rokroskarjsam
authored andcommitted
feat: export filename as schema:name (#643)
closes #640
1 parent fbef55e commit aed54bf

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

renku/models/datasets.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,9 @@ def _convert_dataset_files_creators(value):
179179
@jsonld.s(
180180
type='schema:DigitalDocument',
181181
slots=True,
182-
context={'schema': 'http://schema.org/'}
182+
context={
183+
'schema': 'http://schema.org/',
184+
}
183185
)
184186
class DatasetFile(Entity, CreatorsMixin):
185187
"""Represent a file in a dataset."""
@@ -197,7 +199,9 @@ class DatasetFile(Entity, CreatorsMixin):
197199

198200
dataset = jsonld.ib(context='schema:isPartOf', default=None, kw_only=True)
199201

200-
filename = attr.ib(kw_only=True)
202+
filename = attr.ib(kw_only=True, converter=lambda x: Path(x).name)
203+
204+
name = jsonld.ib(context='schema:name', kw_only=True, default=None)
201205

202206
filesize = attr.ib(default=None, kw_only=True)
203207

@@ -228,6 +232,10 @@ def size_in_mb(self):
228232
"""Return file size in megabytes."""
229233
return self.filesize * 1e-6
230234

235+
def __attrs_post_init__(self):
236+
"""Set the property "name" after initialization."""
237+
self.name = self.filename
238+
231239

232240
def _parse_date(value):
233241
"""Convert date to datetime."""
@@ -274,13 +282,7 @@ def _convert_keyword(keywords):
274282
@jsonld.s(
275283
type='schema:Dataset',
276284
context={
277-
'added': 'schema:dateCreated',
278-
'affiliation': 'schema:affiliation',
279-
'alternate_name': 'schema:alternateName',
280-
'email': 'schema:email',
281-
'name': 'schema:name',
282285
'schema': 'http://schema.org/',
283-
'url': 'schema:url'
284286
},
285287
)
286288
class Dataset(Entity, CreatorsMixin):

0 commit comments

Comments
 (0)