Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion impose/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import OrderedDict
import copy
import pathlib
import errno

import numpy as np

Expand Down Expand Up @@ -84,7 +85,11 @@ def __setstate__(self, state):
def _initialize_from_path(self, path):
self.path = pathlib.Path(path).resolve()
if not self.path.exists():
raise FileNotFoundError(f"File does not exist: '{self.path}'")
raise FileNotFoundError(
errno.ENOENT,
f"File does not exist: '{self.path}'",
self.path
)
# extract the data and metadata
data_channels, meta_orig = load(path)
self.data_channels = data_channels
Expand Down
13 changes: 7 additions & 6 deletions impose/gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,18 @@ def on_session_open(self):
QtWidgets.QMessageBox.warning(
self,
"Data file location unknown",
f"At least one file ({e.name}) could not be found "
"on this machine. In the following dialog(s), "
"please select the location(s) of the missing "
"file(s). The search is done recursively "
"(including subdirectories)."
f"At least one file ({e.filename}) could not be "
"found on this machine. In the following "
"dialog(s), please select the location(s) of "
"the missing file(s). The search is done "
"recursively (including subdirectories)."
)
initial_dialog_shown = True
# Let the user choose another search path
sdir = QtWidgets.QFileDialog.getExistingDirectory(
self,
f"Please select directory tree containing '{e.name}'!"
"Please select directory tree "
f"containing '{e.filename}'!"
)
if sdir:
search_paths.append(sdir)
Expand Down
9 changes: 5 additions & 4 deletions impose/session.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import pathlib
import warnings
import errno

import numpy as np

Expand All @@ -12,8 +13,7 @@


class ImposeDataFileNotFoundError(FileNotFoundError):
def __init__(self, name, *args, **kwargs):
self.name = name
def __init__(self, *args, **kwargs):
super(ImposeDataFileNotFoundError, self).__init__(*args, **kwargs)


Expand Down Expand Up @@ -277,10 +277,11 @@ def find_file(name, search_paths, signature=None):
return pp
else:
raise ImposeDataFileNotFoundError(
name,
errno.ENOENT,
"Could not find file '{}'".format(name)
+ (f" (sig '{signature}')" if signature is not None else "")
+ "!"
+ "!",
name
)

def clear(self):
Expand Down