"""
Module checks to see if particular modules are importable.
For now, it only checks if pylab and/or qt are available.
"""

def pylab_def():
    """
    Check to see if pylab/matplotlib is importable.
    """
    global PYLAB_DEF
    global pylab
    try:
        import pylab
        PYLAB_DEF = True
    except:
        PYLAB_DEF = False
        pylab = None
        pass
    return PYLAB_DEF, pylab

#def qt_def():
#    """
#    Check to see if qt is importable.
#    """
#    global QT_DEF
#    global qt
#    try:
#        import qt
#        QT_DEF = True
#    except:
#        QT_DEF = False
#        qt = None
#        pass
#    return QT_DEF, qt

def enthought_traits_def():
    """
    Check to see if enthought.traits is importable.
    """
    global ENTHOUGHT_TRAITS_DEF
    global traits
    try:
        import enthought.traits.api as traits
        ENTHOUGHT_TRAITS_DEF = True
    except:
        ENTHOUGHT_TRAITS_DEF = False
        try:
            import neuroimaging.utils.enthought.traits as traits
            ENTHOUGHT_TRAITS_DEF = True
        except Exception, e:
            traits = None
            print e
            pass
    return ENTHOUGHT_TRAITS_DEF, traits

@@ -196,32 +196,33 @@
 rtable.%0A    %22%22%22%0A
+#
     global PYLAB
@@ -222,24 +222,25 @@
 l PYLAB_DEF%0A
+#
     global p
@@ -282,39 +282,26 @@
     
-    PYLAB_DEF = True%0A    except
+except ImportError
 :%0A  
@@ -350,32 +350,68 @@
 ne%0A        pass%0A
+    else:%0A        PYLAB_DEF = True%0A%0A
     return PYLAB
@@ -767,24 +767,25 @@
 le.%0A    %22%22%22%0A
+#
     global E
@@ -804,16 +804,17 @@
 ITS_DEF%0A
+#
     glob
@@ -886,88 +886,27 @@
     
-    ENTHOUGHT_TRAITS_DEF = True%0A    except:%0A        ENTHOUGHT_TRAITS_DEF = False
+except ImportError:
 %0A   
@@ -976,24 +976,52 @@
 s as traits%0A
+        except ImportError:%0A
             
@@ -1043,19 +1043,20 @@
 S_DEF = 
-Tru
+Fals
 e%0A      
@@ -1061,91 +1061,143 @@
     
-except Exception, e:%0A            traits = None%0A            print e%0A            pass
+    traits = None%0A            pass%0A        else:%0A            ENTHOUGHT_TRAITS_DEF = True%0A    else:%0A        ENTHOUGHT_TRAITS_DEF = True%0A
 %0A   

clean up defines.py