Skip to content

Commit 0724760

Browse files
committed
separated import try/except blocks for each optional package
1 parent 779026f commit 0724760

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

sliderule/io.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
# imports with warnings if not present
3737
try:
3838
import scipy.io
39+
except ModuleNotFoundError as e:
40+
sys.stderr.write("Warning: missing packages, some functions will throw an exception if called. (%s)\n" % (str(e)))
41+
try:
3942
import h5py
4043
except ModuleNotFoundError as e:
4144
sys.stderr.write("Warning: missing packages, some functions will throw an exception if called. (%s)\n" % (str(e)))

sliderule/ipysliderule.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@
3838
# imports with warnings if not present
3939
try:
4040
import ipywidgets
41+
except ModuleNotFoundError as e:
42+
sys.stderr.write("Warning: missing packages, some functions will throw an exception if called. (%s)\n" % (str(e)))
43+
try:
4144
import tkinter.filedialog
45+
except ModuleNotFoundError as e:
46+
sys.stderr.write("Warning: missing packages, some functions will throw an exception if called. (%s)\n" % (str(e)))
47+
try:
4248
import IPython.display
4349
except ModuleNotFoundError as e:
4450
sys.stderr.write("Warning: missing packages, some functions will throw an exception if called. (%s)\n" % (str(e)))

0 commit comments

Comments
 (0)