-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9721f88
commit 8f8aee3
Showing
13 changed files
with
358 additions
and
243 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
"""constants used by the h5rdmtoolbox package""" | ||
|
||
ANCILLARY_DATASET = 'ANCILLARY_DATASETS' | ||
ANCILLARY_DATASET = 'ANCILLARY_DATASETS' | ||
IRI_ATTR_NAME = 'IRI' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
class IRIManager: | ||
"""Manager class to handle IRIs of opened HDF5 files""" | ||
|
||
def __init__(self): | ||
self.registries = {} | ||
|
||
def __contains__(self, item): | ||
return item in self.registries | ||
|
||
def get(self, name, existing_iri=None): | ||
if name not in self.registries: | ||
if existing_iri is None: | ||
existing_iri = {} | ||
self.registries[name] = existing_iri | ||
return self.registries[name] | ||
|
||
|
||
class IRI: | ||
"""Helper class to store a IRI (international resource identifier) as an attribute. | ||
It will write the value to the attribute and store the IRI in a separate attribute | ||
(see constant `ATTRIRI`). | ||
Example: | ||
-------- | ||
>>> import h5rdmtoolbox as h5tbx | ||
>>> with h5tbx.File() as h5: | ||
>>> h5.attrs['creator'] = h5tbx.IRI('https://orcid.org/0000-0001-8729-0482') | ||
""" | ||
|
||
def __init__(self, value, iri): | ||
self.iri = iri | ||
self.value = value | ||
|
||
def __repr__(self): | ||
return f'{self.__class__.__name__}({self.value}, {self.iri})' | ||
|
||
|
||
irimanager = IRIManager() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.