diff --git a/news/patch_glob.rst b/news/patch_glob.rst new file mode 100644 index 0000000..32f8f62 --- /dev/null +++ b/news/patch_glob.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* Removed glob of user home in load-image + +**Fixed:** + +* + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index 759efc0..0df8d91 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,6 +42,9 @@ template = "{tag}" dev_template = "{tag}" dirty_template = "{tag}" +[tool.setuptools] +package-dir = {"" = "src"} + [tool.setuptools.packages.find] where = ["src"] # list of folders that contain the packages (["."] by default) include = ["*"] # package names should match these glob patterns (["*"] by default) diff --git a/src/diffpy/srxplanar/loadimage.py b/src/diffpy/srxplanar/loadimage.py index 5a75d50..579a835 100644 --- a/src/diffpy/srxplanar/loadimage.py +++ b/src/diffpy/srxplanar/loadimage.py @@ -73,21 +73,13 @@ def load_image(self, filename): :param filename: str or Path, image file name or path :return: 2D ndarray, flipped image array """ - filename = Path( - filename - ).expanduser() # handle "~", make it a Path object - if filename.exists(): - filenamefull = filename - else: - found_files = list(Path.home().rglob(filename.name)) - filenamefull = found_files[0] if found_files else None - - if filenamefull is None or not filenamefull.exists(): + filenamefull = Path(filename).resolve() + + if not filenamefull.exists(): raise FileNotFoundError( f"Error: file not found: {filename}, " f"Please rerun specifying a valid filename." ) - return np.zeros((100, 100)) image = np.zeros((100, 100)) for _ in range(10): # retry 10 times (5 seconds total)