-
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
8fdf264
commit 8c3c525
Showing
19 changed files
with
812 additions
and
642 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,81 @@ | ||
import pathlib | ||
from typing import Optional | ||
from typing import Protocol | ||
|
||
from . import lazy | ||
from .hdfdb import FileDB | ||
from .hdfdb import FilesDB, ObjDB | ||
from .interface import HDF5DBInterface | ||
|
||
|
||
def find(source, *args, **kwargs): | ||
if isinstance(source, (str, pathlib.Path)): | ||
return FileDB(source).find(*args, **kwargs) | ||
elif isinstance(source, (list, tuple)): | ||
return FilesDB(source).find(*args, **kwargs) | ||
else: | ||
return ObjDB(source).find(*args, **kwargs) | ||
|
||
|
||
def find_one(source, *args, **kwargs): | ||
if isinstance(source, (str, pathlib.Path)): | ||
return FileDB(source).find_one(*args, **kwargs) | ||
elif isinstance(source, (list, tuple)): | ||
return FilesDB(source).find_one(*args, **kwargs) | ||
else: | ||
return ObjDB(source).find_one(*args, **kwargs) | ||
|
||
|
||
class RDFQuerySource(Protocol): | ||
def rdf(self, *args, **kwargs): | ||
pass | ||
|
||
|
||
def rdf_find(source, *, | ||
rdf_subject: Optional[str] = None, | ||
rdf_type: Optional[str] = None, | ||
rdf_predicate: Optional[str] = None, | ||
rdf_object: Optional[str] = None, | ||
recursive: bool = True): | ||
"""Find function for RDF triples | ||
Parameters | ||
---------- | ||
source: Union[str, pathlib.Path, h5tbx.Group] | ||
Filename or hdf group | ||
""" | ||
if isinstance(source, (str, pathlib.Path)): | ||
return FileDB(source).rdf_find(rdf_subject=rdf_subject, | ||
rdf_type=rdf_type, | ||
rdf_predicate=rdf_predicate, | ||
rdf_object=rdf_object, | ||
recursive=recursive) | ||
elif isinstance(source, (list, tuple)): | ||
return FilesDB(source).rdf_find(rdf_subject=rdf_subject, | ||
rdf_type=rdf_type, | ||
rdf_predicate=rdf_predicate, | ||
rdf_object=rdf_object, | ||
recursive=recursive) | ||
else: | ||
return ObjDB(source).rdf_find(rdf_subject=rdf_subject, | ||
rdf_type=rdf_type, | ||
rdf_predicate=rdf_predicate, | ||
rdf_object=rdf_object, | ||
recursive=recursive) | ||
# from .. import File | ||
# from .lazy import lazy | ||
# if isinstance(source, (str, pathlib.Path)): | ||
# with File(source) as h5: | ||
# return rdf_find(h5, rdf_subject=rdf_subject, | ||
# rdf_type=rdf_type, | ||
# rdf_predicate=rdf_predicate, | ||
# rdf_object=rdf_object, | ||
# recursive=recursive) | ||
# return lazy(source.rdf.find(rdf_subject=rdf_subject, | ||
# rdf_type=rdf_type, | ||
# rdf_predicate=rdf_predicate, | ||
# rdf_object=rdf_object, | ||
# recursive=recursive)) | ||
|
||
from .template import HDF5DBInterface | ||
|
||
__all__ = ['lazy', 'FileDB', 'FilesDB', 'ObjDB', 'HDF5DBInterface'] |
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,4 +1,18 @@ | ||
import pathlib | ||
|
||
import h5rdmtoolbox as h5tbx | ||
from .filedb import FileDB, FilesDB | ||
from .objdb import ObjDB | ||
|
||
__all__ = ['ObjDB', 'FileDB', 'FilesDB'] | ||
|
||
def find(source, *args, **kwargs): | ||
if isinstance(source, (str, pathlib.Path)): | ||
with h5tbx.File(source, mode='r') as h5: | ||
return find(h5, *args, **kwargs) | ||
elif isinstance(source, (list, tuple)): | ||
raise NotImplementedError('find does not support multiple sources') | ||
else: | ||
return ObjDB(source).find(*args, **kwargs) | ||
|
||
|
||
__all__ = ['ObjDB', 'FileDB', 'FilesDB', 'find'] |
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 was deleted.
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
15 changes: 14 additions & 1 deletion
15
h5rdmtoolbox/database/template.py → h5rdmtoolbox/database/interface.py
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
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
Oops, something went wrong.