-
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
Showing
4 changed files
with
450 additions
and
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
from importlib.metadata import version | ||
|
||
from .gefslim import GEF | ||
from .utils import _get_h5_from_gef | ||
|
||
__version__ = version("gefslim") |
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,29 @@ | ||
import os | ||
import pathlib | ||
|
||
import h5py | ||
|
||
|
||
def _get_h5_from_gef( | ||
result_path: pathlib.Path, | ||
folder_name: str, | ||
file_name: str, | ||
) -> h5py.File: | ||
"""Returns the connection to a h5py file.""" | ||
if not isinstance(result_path, pathlib.Path): | ||
raise TypeError(f"Parameter 'result_path' must be a pathlib.Path, got: {type(result_path)}") | ||
|
||
if not isinstance(folder_name, str): | ||
raise TypeError(f"Parameter 'folder_name' must be a string, got: {type(folder_name)}") | ||
|
||
if not isinstance(file_name, str): | ||
raise TypeError(f"Parameter 'file_name' must be a string, got: {type(file_name)}") | ||
|
||
if ".gef" not in file_name: | ||
raise ValueError("Parameter 'file_name' must be a `.gef` file.") | ||
|
||
path = result_path / folder_name / file_name | ||
if not os.path.exists(path): | ||
raise FileNotFoundError(f"File '{path}' does not exist.") | ||
|
||
return h5py.File(path, "r") |