Skip to content

Commit

Permalink
Merge pull request #2 from mih/idmap
Browse files Browse the repository at this point in the history
RF: Provide an "interface" to perform ID mapping to an external DB
  • Loading branch information
cmaumet authored May 29, 2019
2 parents 83fe039 + e4fc4dc commit 0507edd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions nidmresults/objects/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,25 @@ def __init__(self, oid=None):
oid = NIIRI.qname(Identifier(oid))
self.id = oid

# the next three methods build a .file property
# with a dedicated function call on "set" that can
# be used to implement external ID mappings
# e.g. DataLad can replace '_map_fileid()' to provides
# its internal file IDs based on the filename associated
# with a NIDMFile object
@property
def file(self):
return getattr(self, '_file', None)

@file.setter
def file(self, fileobj):
if isinstance(fileobj, NIDMFile):
self._map_fileid(fileobj)
self._file = fileobj

def _map_fileid(self, fileobj):
pass

def __str__(self):
value = ""
if hasattr(self, 'value'):
Expand Down

0 comments on commit 0507edd

Please sign in to comment.