From a2297e8441188692fb684f255884c30412302e50 Mon Sep 17 00:00:00 2001 From: Karamaz0V1 Date: Mon, 9 Apr 2018 18:25:12 +0200 Subject: [PATCH] Raise IOError when file not found --- python/triskele/CreaTIFF.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/triskele/CreaTIFF.py b/python/triskele/CreaTIFF.py index 1514af0..49649cb 100644 --- a/python/triskele/CreaTIFF.py +++ b/python/triskele/CreaTIFF.py @@ -8,6 +8,7 @@ # # TODO details +from pathlib import Path import numpy as np import gdal @@ -41,7 +42,12 @@ def write(fname, X): dst_ds.FlushCache() def read(fname): - gdl_data = gdal.Open(str(fname)) + pname = Path(fname) + + if not pname.exists(): + raise IOError('File not found: {}'.format(pname)) + + gdl_data = gdal.Open(pname.as_posix()) if gdl_data.RasterCount == 1: return gdl_data.ReadAsArray()