+
    ^|iW.                     \   R t ^ RIt^ RIt^ RIt^ RIt^ RIHtHt ^ RI	t	Rt
RtRtRtRtRtR	tR
t]
R]R]R]R]R]R]R]R/t ! R R]P&                  P(                  4      t]! 4       t]P.                  P1                  ^ ]4       R tR tR tR tR tR R ltR tR t R t!R t"R t#R t$R t%R# )!aD  
This module contains factory functions that attempt
to return Qt submodules from the various python Qt bindings.

It also protects against double-importing Qt with different
bindings, which is unstable and likely to crash

This is used primarily by qt and qt_for_kernel, and shouldn't
be accessed directly from the outside
N)partial	lru_cachepyqt6pyside6pyqt5pyside2pyqtpyqtv1pysidepyqtdefaultPyQt6PySide6PyQt5PySide2PySidePyQt4c                   :   a  ] tR t^4t o RtR tR tRR ltRtV t	R# )ImportDenierz^Import Hook that will guard against bad Qt imports
once IPython commits to a specific binding
c                $    \        4       V n        R # N)set_ImportDenier__forbidden)selfs   &=/usr/lib/python3/dist-packages/IPython/external/qt_loaders.py__init__ImportDenier.__init__9   s    5    c                |    \         P                  P                  VR 4       V P                  P	                  V4       R # r   )sysmodulespopr   add)r   module_names   &&r   forbidImportDenier.forbid<   s(    T*[)r   Nc                r    V'       d   R # WP                   9   d   \        RV: R\        4       : R24      hR # )Nz
    Importing zQ disabled by IPython, which has
    already imported an Incompatible QT Binding: 
    )r   ImportError
loaded_api)r   fullnamepathtargets   &&&&r   	find_specImportDenier.find_spec@   s4    '''
 Z\	+  (r   )__forbiddenr   )
__name__
__module____qualname____firstlineno____doc__r   r#   r,   __static_attributes____classdictcell__)__classdict__s   @r   r   r   4   s     !*
 
r   r   c                    \        \        P                  4       4      pVP                  \        V ,          4       V F  p\        P                  V4       K  	  R# )zTCommit to a particular API, and trigger ImportErrors on subsequent
dangerous importsN)r   api_to_modulevaluesremoveIDr#   )apir   mods   &  r   
commit_apir>   Q   s=     -&&()GNN=%&
		# r   c                 4   \         P                  P                  R4      '       d   \        # \         P                  P                  R4      '       d   \        # \         P                  P                  R4      '       d   \
        # \         P                  P                  R4      '       d   \        # \         P                  P                  R4      '       d   \        4       ^8X  d   \        # \        # \         P                  P                  R4      '       d   \        # R# )zReturn which API is loaded, if any

If this returns anything besides None,
importing any other Qt binding is unsafe.

Returns
-------
None, 'pyside6', 'pyqt6', 'pyside2', 'pyside', 'pyqt', 'pyqt5', 'pyqtv1'
zPyQt6.QtCorezPySide6.QtCorezPyQt5.QtCorezPySide2.QtCorezPyQt4.QtCorezPySide.QtCoreN)r   r   getQT_API_PYQT6QT_API_PYSIDE6QT_API_PYQT5QT_API_PYSIDE2qtapi_versionQT_API_PYQTQT_API_PYQTv1QT_API_PYSIDE r   r   r(   r(   [   s     {{~&&	)	*	*		(	(	)	*	*		(	(?a  		)	)r   c                .   \         V ,          p^ RIHp . ROpV \        \        \
        \        39   d   VP                  R4       V F  p V! V: RV: 24      pVf    R# K  	  V \        8X  d   ^ RI
pVP                  R8  # R#   \         d      R# i ; i)	a  Safely check for PyQt4/5, PySide or PySide2, without importing submodules

Parameters
----------
api : str [ 'pyqtv1' | 'pyqt' | 'pyqt5' | 'pyside' | 'pyside2' | 'pyqtdefault']
    Which module to check for

Returns
-------
True if the relevant module appears to be importable
)r,   	QtWidgets.NFT)QtCoreQtGuiQtSvg)          )r8   importlib.utilr,   rC   rD   rA   rB   appendr'   rH   r   __version_info__)r<   r"   r,   requiredsubmodspecr   s   &      r   has_bindingrY   x   s      $K(+H
|^\>JJ$	V<=D
 |   m&&)33  		s   
BBBc                      ^ RI p  T P                  R4      #   \         d     ^ RIH p   L&  \         d      R# i ; ii ; i  \         d     R# i ; i)ztReturn which QString API has been set, if any

Returns
-------
The QString API version (1 or 2), or None if not set
NsipQString)r\   r'   r   getapi
ValueErrorr[   s    r   rE   rE      s\    zz)$$  	! 		  s0    A A ,<A <A AAc                t    \        V 4      '       g   R# \        4       pV \        8X  d   V\        R39   # WR39   # )z?Safely query whether an API is importable, without importing itFN)rY   r(   QT_API_PYQT_DEFAULTrA   )r<   currents   & r   
can_importrc      s=    slG
!!<...+%%r   c                \   ^ RI pV e%   VP                  RV 4       VP                  RV 4       ^ RIHpHpHp VP                  R8  d   \        RVP                  ,          4      hVP                  Vn
        VP                  Vn        VP                  R4      p V ^8X  d   \        M\        pW2WE3# )z
Import PyQt4

Parameters
----------
version : 1, 2, or None
    Which QString/QVariant API to use. Set to None to use the system
    default
ImportErrors raised within this function are non-recoverable
Nr]   QVariantrN   rM   rO   i  z'IPython requires PyQt4 >= 4.7, found %s)r\   setapir   rN   rM   rO   PYQT_VERSIONr'   PYQT_VERSION_STR
pyqtSignalSignalpyqtSlotSlotr^   rG   rF   )versionr\   rN   rM   rO   r<   s   &     r   import_pyqt4ro      s     

9g&

:w'**X%C 112 3 	3 %%FM//FK jj#G"a<-[C%$$r   c                 2   ^ RI Hp HpHpHp V P
                  V n        V P                  V n        \        P                  ! R4      pVP                  P                  VP                  4       VP                  P                  VP                  4       \        pWW3# )zL
Import PyQt5

ImportErrors raised within this function are non-recoverable
rM   rO   rK   rN   QtGuiCompat)r   rM   rO   rK   rN   rj   rk   rl   rm   types
ModuleType__dict__updaterC   rM   rO   rK   rN   rr   r<   s         r   import_pyqt5rx      x     65 %%FM//FK ""=1K/	 2 23
C**r   c                 2   ^ RI Hp HpHpHp V P
                  V n        V P                  V n        \        P                  ! R4      pVP                  P                  VP                  4       VP                  P                  VP                  4       \        pWW3# )zL
Import PyQt6

ImportErrors raised within this function are non-recoverable
rq   rr   )r   rM   rO   rK   rN   rj   rk   rl   rm   rs   rt   ru   rv   rA   rw   s         r   import_pyqt6r{      ry   r   c                 (    ^ RI Hp HpHp WV\        3# )zM
Import PySide

ImportErrors raised within this function are non-recoverable
rf   )r   rN   rM   rO   rH   rf   s      r   import_pysider}     s     ,+%..r   c                 :   ^ RI Hp HpHpHpHp \        P                  ! R4      pVP                  P                  V P                  4       VP                  P                  VP                  4       VP                  P                  VP                  4       WV\        3# )zN
Import PySide2

ImportErrors raised within this function are non-recoverable
rN   rM   rO   rK   QtPrintSupportrr   )r   rN   rM   rO   rK   r   rs   rt   ru   rv   rD   )rN   rM   rO   rK   r   rr   s         r   import_pyside2r     sv     HG ""=1K/	 2 23 7 78~55r   c                    R p ^ RI HpHpHpHpHp \        P                  ! R4      pVP                  P                  VP                  4       VP                  R8  dL   VP                  P                  VP                  4       VP                  P                  VP                  4       MBVP                  P                  V ! V4      4       VP                  P                  V ! V4      4       W&V\        3# )zN
Import PySide6

ImportErrors raised within this function are non-recoverable
c                     \        V 4       Uu/ uF(  pVP                  R 4      '       d   K  V\        W4      bK*  	  up# u upi )_)dir
startswithgetattr)modulenames   & r   	get_attrs!import_pyside6.<locals>.get_attrs3  sE     F
#??3' (D'&''#
 	
 
s   ??r   rr   )      )r   rN   rM   rO   rK   r   rs   rt   ru   rv   rU   rB   )r   rN   rM   rO   rK   r   rr   s          r   import_pyside6r   ,  s    
 HG ""=1K/'##I$6$67##N$;$;<##Ii$89##In$=>~55r   c                   \         \        \        \        \        \
        \        \        \        \        \        \        \        \        \        ^R7      \        \        /pV  F  pW!9  dH   \        RV: RRP!                  VP#                  4        Uu. uF  pRV,          NK  	  up4      : 24      h\%        V4      '       g   Kc  W,          ! 4       pVR,          p\'        V4       Vu # 	  R\(        P*                  9   d   \(        P*                  R \-        R\/        4       : R\1        \        4      : R	\1        \         4      : R
\1        \        4      : R\1        \        4      : RV : R24      hu upi )aq  
Attempt to import Qt, given a preference list
of permissible bindings

It is safe to call this function multiple times.

Parameters
----------
api_options : List of strings
    The order of APIs to try. Valid items are 'pyside', 'pyside2',
    'pyqt', 'pyqt5', 'pyqtv1' and 'pyqtdefault'

Returns
-------
A tuple of QtCore, QtGui, QtSvg, QT_API
The first three are the Qt modules. The last is the
string indicating which module was loaded.

Raises
------
ImportError, if it isn't possible to import any requested
bindings (either because they aren't installed, or because
an incompatible library has already been installed)
)rn   zInvalid Qt API z, valid values are: z, z%rQT_APIz
    Could not load requested Qt binding. Please ensure that
    PyQt4 >= 4.7, PyQt5, PyQt6, PySide >= 1.0.3, PySide2, or
    PySide6 is available, and only one is imported per session.

    Currently-imported Qt library:                              zA
    PyQt5 available (requires QtCore, QtGui, QtSvg, QtWidgets): zA
    PyQt6 available (requires QtCore, QtGui, QtSvg, QtWidgets): zA
    PySide2 installed:                                          zA
    PySide6 installed:                                          zA
    Tried to load:                                              r&   )rA   r{   rB   r   rC   rx   rD   r   rH   r}   rF   ro   rG   r   ra   RuntimeErrorjoinkeysrc   r>   osenvironr'   r(   rY   )api_optionsloadersr<   kresults   &    r   load_qtr   I  s   6 	ll}\w|Q7\G dii7<<> B>a> BCEF F # Rj3 " rzz!

8$ L)L)N+N+%
 	
 !Cs   E0c                4   a a \        R4      V V3R l4       pV# )z@Construct an enum helper to account for PyQt5 <-> PyQt6 changes.Nc                    < \         P                  ! S\        8X  d   T MV P                  R 4      ^ ,          4      ! \        P
                  SP                  ,          4      # )rL   )operator
attrgetterrA   
rpartitionr   r   __package__)r   r   rM   s   &r   _enumenum_factory.<locals>._enum  sI     ""l*D0DQ0G

++f((
)+ 	+r   )r   )r   rM   r   s   ff r   enum_factoryr     s"     t_+ + Lr   )   )&r3   importlib.abc	importlibr   r   rs   	functoolsr   r   r   rA   rB   rC   rD   rF   rG   rH   ra   r8   abcMetaPathFinderr   r;   	meta_pathinsertr>   r(   rY   rE   rc   ro   rx   r{   r}   r   r   r   r   rI   r   r   <module>r      s   	  
 	  (    #  'I'I87 9==// 2 ^   Q :%P,	&!%H+,+,/6"6:Q
h
r   