ó
&9_[c           @   s·   d  Z  d d l Z d d l Z d d l m Z d d l m Z m Z m Z m	 Z	 m
 Z
 m Z m Z m Z e e	 e
 e e e f Z d „  Z d „  Z e ƒ  Z e e ƒ \ Z Z Z Z d S(   s”   Import Qt in a manner suitable for an IPython kernel.

This is the import used for the `gui=qt` or `matplotlib=qt` initialization.

Import Priority:

if Qt has been imported anywhere else:
   use that

if matplotlib has been imported and doesn't support v2 (<= 1.0.1):
    use PyQt4 @v1

Next, ask QT_API env variable

if QT_API not set:
    ask matplotlib what it's using. If Qt4Agg or Qt5Agg, then use the
        version matplotlib is configured with

    else: (matplotlib said nothing)
        # this is the default path - nobody told us anything
        try in this order:
            PyQt default version, PySide, PyQt5
else:
    use what QT_API says

iÿÿÿÿN(   t   check_version(   t   load_qtt
   loaded_apit   QT_API_PYSIDEt   QT_API_PYSIDE2t   QT_API_PYQTt   QT_API_PYQT5t   QT_API_PYQTv1t   QT_API_PYQT_DEFAULTc         C   s  |  d  k r d  S|  j j d d  ƒ } | d k r´ |  j j d d  ƒ } | d  k rV d  S| j ƒ  d k ro t g S| j ƒ  d k rˆ t g S| j ƒ  d k r¡ t g St d | ƒ ‚ n] | d k r|  j j d	 d  ƒ } | d  k rå d  S| j ƒ  d
 k rþ t g St d | ƒ ‚ n  d  S(   Nt   backendt   Qt4Aggs   backend.qt4t   pysidet   pyqt4t   pyqt4v2s3   unhandled value for backend.qt4 from matplotlib: %rt   Qt5Aggs   backend.qt5t   pyqt5s3   unhandled value for backend.qt5 from matplotlib: %r(	   t   Nonet   rcParamst   gett   lowerR   R   R   t   ImportErrorR   (   t   mplR	   t   mpqt(    (    s=   lib/python2.7/site-packages/IPython/external/qt_for_kernel.pyt   matplotlib_options+   s.    c          C   sÍ   t  ƒ  }  |  d k	 r |  g St j j d d ƒ } | d k	 rW t | j d ƒ rW t g St j	 j d d ƒ } | d k r” t
 | ƒ p“ t t t t g S| t k rÂ t d | d j t ƒ f ƒ ‚ n | g Sd S(   sO   Return a list of acceptable QT APIs, in decreasing order of
    preference
    t
   matplotlibs   1.0.2t   QT_APIs'   Invalid Qt API %r, valid values are: %rs   , N(   R   R   t   syst   modulesR   R    t   __version__R   t   ost   environR   R   R   R   t   _qt_apist   RuntimeErrort   join(   t   loadedR   t   qt_api(    (    s=   lib/python2.7/site-packages/IPython/external/qt_for_kernel.pyt   get_optionsD   s    	
(   t   __doc__R   R   t   IPython.utils.versionR    t   IPython.external.qt_loadersR   R   R   R   R   R   R   R   R   R   R$   t   api_optst   QtCoret   QtGuit   QtSvgR   (    (    (    s=   lib/python2.7/site-packages/IPython/external/qt_for_kernel.pyt   <module>   s   :				