Commit 82b9ccc0 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Improve import warnings in graphviz_draw()

parent 7ea3821e
...@@ -36,8 +36,9 @@ try: ...@@ -36,8 +36,9 @@ try:
import matplotlib.cm import matplotlib.cm
import matplotlib.colors import matplotlib.colors
except ImportError: except ImportError:
warnings.warn("error importing matplotlib module... " + \ msg = "Error importing matplotlib module... graphviz_draw() will not work."
"graphviz_draw() will not work.", ImportWarning) warnings.filterwarnings("always", msg, ImportWarning)
warnings.warn(msg, ImportWarning)
try: try:
libname = ctypes.util.find_library("c") libname = ctypes.util.find_library("c")
...@@ -45,6 +46,9 @@ try: ...@@ -45,6 +46,9 @@ try:
if hasattr(libc, "open_memstream"): if hasattr(libc, "open_memstream"):
libc.open_memstream.restype = ctypes.POINTER(ctypes.c_char) libc.open_memstream.restype = ctypes.POINTER(ctypes.c_char)
except OSError: except OSError:
msg = "Error importing C standard library... graphviz_draw() will not work."
warnings.filterwarnings("always", msg, ImportWarning)
warnings.warn(msg, ImportWarning)
pass pass
...@@ -65,8 +69,9 @@ try: ...@@ -65,8 +69,9 @@ try:
# it, we will hit a memory leak in graphviz) # it, we will hit a memory leak in graphviz)
gvc = libgv.gvContext() gvc = libgv.gvContext()
except OSError: except OSError:
warnings.warn("error importing graphviz C library (libgvc)... " + \ msg = "Error importing graphviz C library (libgvc)... graphviz_draw() will not work."
"graphviz_draw() will not work.", ImportWarning) warnings.filterwarnings("always", msg, ImportWarning)
warnings.warn(msg, ImportWarning)
def htmlize(val): def htmlize(val):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment