Skip to content

Commit

Permalink
add simple check: check_HDFStore_available() on CellpyCell
Browse files Browse the repository at this point in the history
  • Loading branch information
jepegit committed Jan 20, 2025
1 parent 5bd30c7 commit b9f6f61
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cellpy/logging.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"formatters": {
"stamped": {
"format": "%(asctime)s - %(name)s - %(levelname)s (%(funcName)s): %(message)s",
"datefmt": "%Y-%m-%d %H:%M"},
"datefmt": "%Y-%m-%d %H:%M:%S"},
"simple": {
"format": "(cellpy) - %(message)s"
}
Expand Down
14 changes: 13 additions & 1 deletion cellpy/readers/cellreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,14 @@ def _check_raw(self, file_names, abort_on_missing=False):
ids[name] = int(fid.last_modified)
return ids

def _check_HDFStore_available(self):
try:
_ = externals.pandas.HDFStore
except Exception as e:
print(f"Could not use HDFStore ({e})")
return False
return True

def _check_cellpy_file(self, filename: "OtherPath"):
"""Get the file-ids for the cellpy_file."""

Expand Down Expand Up @@ -3358,6 +3366,7 @@ def save(
extension="h5",
ensure_step_table=None,
ensure_summary_table=None,
cellpy_file_format="hdf5",
):
"""Save the data structure to cellpy-format.
Expand All @@ -3370,6 +3379,7 @@ def save(
extension: (str) filename extension.
ensure_step_table: (bool) make step-table if missing.
ensure_summary_table: (bool) make summary-table if missing.
cellpy_file_format: (str) format of the cellpy-file (only hdf5 is supported so far).
Returns:
None
Expand All @@ -3378,7 +3388,9 @@ def save(
logging.debug(f"Trying to save cellpy-file to {filename}")
logging.info(f" -> {filename}")

cellpy_file_format = "hdf5"
if cellpy_file_format.lower() != "hdf5":
logging.critical("Sorry, but only hdf5 is supported at the moment. Setting cellpy_file_format to hdf5.")
cellpy_file_format = "hdf5"

# some checks to find out what you want
if overwrite is None:
Expand Down

0 comments on commit b9f6f61

Please sign in to comment.