Skip to content

Commit

Permalink
cleanup and retrun cv if exists
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasprobst committed Sep 26, 2023
1 parent 3a2b84e commit b812be2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 185 deletions.
163 changes: 0 additions & 163 deletions docs/conventions/EngMeta.ipynb

This file was deleted.

8 changes: 4 additions & 4 deletions docs/conventions/examples/EngMeta.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,12 @@
"\n",
" <ul style=\"list-style-type: none;\" class=\"h5grp-sections\">\n",
" <li>\n",
" <input id=\"group-ds--5208023100\" type=\"checkbox\" checked>\n",
" <label style=\"font-weight: bold\" for=\"group-ds--5208023100\">\n",
" <input id=\"group-ds--5757953000\" type=\"checkbox\" checked>\n",
" <label style=\"font-weight: bold\" for=\"group-ds--5757953000\">\n",
" /<span>(0)</span></label>\n",
" \n",
"\n",
" <ul class=\"h5tb-attr-list\"><li style=\"list-style-type: none; font-style: italic\">__h5rdmtoolbox_version__ : 0.9.0</li><li style=\"list-style-type: none; font-style: italic\">contact : name='Matthias Probst' givenName=None familyName=None address=None affiliation=None email=None id...</li><li style=\"list-style-type: none; font-style: italic\">creator : name='Matthias Probst' givenName=None familyName=None address=None affiliation=None email=None id...</li><li style=\"list-style-type: none; font-style: italic\">pid : id='123' type=pidTypes(value=<pidTypes.other: 'other'>) scheme=None</li><li style=\"list-style-type: none; font-style: italic\">title : Test file to demonstrate usage of EngMeta schema</li>\n",
" <ul class=\"h5tb-attr-list\"><li style=\"list-style-type: none; font-style: italic\">__h5rdmtoolbox_version__ : 0.10.0</li><li style=\"list-style-type: none; font-style: italic\">contact : name='Matthias Probst' givenName=None familyName=None address=None affiliation=None email=None id...</li><li style=\"list-style-type: none; font-style: italic\">creator : name='Matthias Probst' givenName=None familyName=None address=None affiliation=None email=None id...</li><li style=\"list-style-type: none; font-style: italic\">pid : id='123' type=pidTypes(value=<pidTypes.other: 'other'>) scheme=None</li><li style=\"list-style-type: none; font-style: italic\">title : Test file to demonstrate usage of EngMeta schema</li>\n",
" </ul>\n",
"</li>\n",
"</ul>\n",
Expand Down Expand Up @@ -386,7 +386,7 @@
"text/plain": [
"{'file_size': array(10552) <Unit('byte')>,\n",
" 'file_type': 'hdf5',\n",
" 'checksum': '3d2edd7a16bb3dbedaba98155d155a51'}"
" 'checksum': '3d23860665ec242d2268302e0996fe4b'}"
]
},
"execution_count": 6,
Expand Down
14 changes: 2 additions & 12 deletions docs/conventions/examples/Provenance.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
HDF Research Data Management Toolbox
====================================
HDF5 Research Data Management Toolbox
=====================================

The "HDF5 Research Data Management Toolbox" (h5RDMtoolbox) is a python package supporting everyone who is working
with HDF5 to achieve a sustainable data lifecycle which follows the
Expand Down
6 changes: 5 additions & 1 deletion h5rdmtoolbox/conventions/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ def from_yaml(yaml_filename: Union[str, pathlib.Path, List[str], List[pathlib.Pa
----------
yaml_filename: Union[str, pathlib.Path]
Path to yaml file
overwrite: bool=False
Overwrite existing convention. If False and convention already exists,
the existing convention is returned.
Returns
-------
Expand Down Expand Up @@ -459,7 +462,8 @@ def from_yaml(yaml_filename: Union[str, pathlib.Path, List[str], List[pathlib.Pa
convention_name = attrs['__name__'].lower().replace('-', '_')
if convention_name in [d.name for d in CV_DIR.glob('*')]:
if not overwrite:
raise FileExistsError('Convention already exists with this name: {convention_name}')
return _get_convention_from_dir(attrs['__name__'])
# overwriting existing convention
delete(convention_name)

from . import generate
Expand Down
4 changes: 1 addition & 3 deletions tests/conventions/test_conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,8 @@ def test_from_yaml(self):
with open(h5tbx.utils.generate_temporary_filename(suffix='.yaml'), 'w') as f:
f.writelines(['__name__: test\n', '__contact__: me'])

_ = h5tbx.conventions.from_yaml(f.name, overwrite=True)
cv = h5tbx.conventions.from_yaml(f.name, overwrite=False)
cv = h5tbx.conventions.from_yaml(f.name, overwrite=True)
with self.assertRaises(FileExistsError):
_ = h5tbx.conventions.from_yaml(f.name, overwrite=False)
self.assertEqual(cv.name, 'test')
self.assertEqual(cv.contact, 'me')

Expand Down

0 comments on commit b812be2

Please sign in to comment.