
    G@dlm                        d Z ddlZddlZddlmZ ddlZddlZddlmZ	 ddl
Z
ddlZddlZddlmZ ddlmZmZ ddlmZmZmZmZmZmZmZmZmZmZ ddlmZmZm Z m!Z! ddl"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 dd	l1m2Z2 dd
l3m4Z4 ddl5m6Z6m7Z7 ddl8m9Z9 ddl:m;Z; ddl<m=Z= ddl>m?Z? ddl@mAZAmBZB ddlCmDZD ejE        dk    r e2            sddlFZG ejH        eI          ZJdZKd ZLdLdZMd ZNdMdZOd ZPdaQd ZRd ZSd ZTd ZUdNdZVd  ZWd! ZXd" ZY	 	 	 	 	 dOd$ZZdPd'Z[	 	 dQd(Z\d) Z]dddddddej^        dddddd#d#fd*Z_d+ Z`d, Zad- Zbd. ZcdNd/Zdd0 Zed1 ZfdRd2Zgd3 ZhdRd4Zig fd5Zj G d6 d7e          Zkd8 Zl G d9 d:e#          Zm G d; d<e0          Znd= Zod> ZpdNd?Zqd@ Zr G dA dBe+          Zs G dC dDe%          Zt G dE dFe$          ZudG Zv	 	 dSdJZweIdKk    r eo             dS dS )TzQt utilities.    N)pi)unquote)from_qvariantto_qvariant)
QEventQLibraryInfoQLocaleQObjectQtQTimerQTranslatorQUrlSignalSlot)QDesktopServices	QKeyEventQKeySequenceQPixmap)QActionQApplicationQDialogQHBoxLayoutQLabel	QLineEditQMenuQPlainTextEditQProxyStyleQPushButtonQStyleQToolButtonQVBoxLayoutQWidget)running_in_mac_app)CONF)is_text_stringto_text_string)ima)programs)get_image_path)QStylePalette)ACTION_REGISTRYTOOLBUTTON_REGISTRY)QWaitingSpinnerdarwinc                 p    t                      }|                    |            t          j        |          S )z
    Generalized os.startfile for all platforms supported by Qt

    This function is simply wrapping QDesktopServices.openUrl

    Returns True if successful, otherwise returns False.
    )r   setUrlr   openUrl)filenameurls     6lib/python3.11/site-packages/spyder/utils/qthelpers.py
start_filer5   =   s0     &&CJJx#C(((    	not_foundc                     t                      }|                    t          t          | |                               |S )z#Return image inside a QLabel object)r   	setPixmapr   r)   )namedefaultlabels      r4   get_image_labelr=   O   s4    HHE	OOGN499::;;;Lr6   c                  j    t          j                    } | j        | j        } | j        | j        j        S )z+Return the filename at the top of the stack)sys	_getframef_backf_codeco_filename)fs    r4   get_origin_filenamerE   V   s3     	A
(
H (
8r6   T   c                 *   t           j        dk    rt          }nt          }|                                }|" |ddg          }|                    d           t           j        dk    r2t                      s$t          j        ddd          rt                       | rt          |           t          j                            dd          }|Ft          |          }|j                            |j                   |                    |d	z             |S )
z
    Return QApplication instance
    Creates it if it doesn't already exist

    test_time: Time to maintain open the application when testing. It's given
    in seconds
    r.   NSpyderz--no-sandboxmainmac_open_fileFTEST_CI_WIDGETSi  )r?   platformMacApplicationr   instancesetApplicationNamer#   r$   getregister_app_launchservicesinstall_translatorosenvironr   timeoutconnectquitstart)	translate	test_timeSpyderApplicationapptest_citimer_shutdowns         r4   qapplicationr_   _   s    |x*(

$
$
&
&C
{  > :;; 	x(((  &(( 	!%88 	! 	$%%%  3jnn.55G&&sx000Y-...Jr6   c                 j    t           j        dk    rt          j        d|           rd| z   S d| z   S d| z   S )zBSelect the right file uri scheme according to the operating systemntz
^[a-zA-Z]:file:///file://)rS   r:   research)fnames    r4   file_urirg      sD    	w$9]E** 	%%% u$$5  r6   c                 *   t           ht                      }|                    dt          j                                                    z   t          j        t          j                            r|a t           | 	                    t                      dS dS )z2Install Qt translator to the QApplication instanceNqt_)
QT_TRANSLATORr   loadr	   systemr:   r   locationTranslationsPathinstallTranslator)qappqt_translators     r4   rR   rR      s     #((--///%l&CDDF F 	* *M }----- ! r6   c                     t          t          |           }t          t          j        |          d         t                    S )zReturn keybindingr   )getattrr   r   keyBindingsstr)attrkss     r4   
keybindingrx      s1    	t	$	$B1"55a8#>>>r6   c                    	 t          |                                 |                                 z                                            S # t          $ r |                                 }|                                 t
          j        z  }|                                 t
          j        z  }|                                 t
          j        z  }|                                 t
          j	        z  }|}|r|t
          j
        z  }|r|t
          j        z  }|r|t
          j        z  }|r|t
          j        z  }t          |                                          cY S w xY w)z:Get key sequence corresponding to a key event as a string.)r   	modifierskeytoString	TypeErrorr   AltModifierShiftModifierControlModifierMetaModifierCTRLSHIFTALTMETA)eventr{   altshiftctrlmetakey_sequences          r4   keyevent_to_keysequence_strr      s1   5EOO--		;<<EEGGG 5 5 5
 iikkoo".0!!B$44  2#55  2?2 	$BG#L 	%BH$L 	#BF"L 	$BG#LL))2244444+5s   AA
 
D
EEc                 f   |                      d          rEt          j        dk    r+|                      d          r| dd          } n| dd          } n
| dd          } |                     dt          j                  } t          j        |           r |t          j        |           d         |v r| S d S d S )	Nrc   ra   rb            \   )
startswithrS   r:   replacesepospexistssplitext)pathextlists     r4   _process_mime_pathr      s    z"" 	7d?? {++  ABBxABBx8D<<bf%%D
z$ ?cl4003w>>K >>r6   c           	         g }|                                  rk|                                 D ]U}t          t          t	          |                                                    |          }||                    |           Vnq|                                 r]t	          |                                           	                                D ])}t          ||          }||                    |           *|r|S dS )zR
    Extract url list from MIME data
    extlist: for example ('.py', '.pyw')
    N)
hasUrlsurlsr   r   r&   r|   appendhasTexttext
splitlines)sourcer   pathlistr3   r   rawpaths         r4   mimedata2urlr      s    
 H~~ 
&;;== 	& 	&C%s||~~6677B BD%%%		&
 
		 &%fkkmm44??AA 	& 	&G%gw77D%%%  r6   c                     |                                  |                                 |                                 |                                 |                                 |                                 fS )z'Convert QKeyEvent instance into a tuple)typer{   rz   r   isAutoRepeatcount)r   s    r4   keyevent2tupler      sP    JJLL%))++u'8'8%**,,  %++--1 1r6   c                     t          |  S )z'Convert tuple into a QKeyEvent instance)r   )
past_events    r4   tuple2keyeventr      s    j!!r6   c                     t          | t                    r| \  }}}}}}t          |           } n<|                                 }|                                 }|                                 }|t          j        z  }|t          j        z  }| ||||fS N)	
isinstancetupler   r   rz   r{   r   r   r   )r   _r{   rz   r   r   r   s          r4   restore_keyeventr      s    % (-%3	4Au%%zz||OO%%	iikkr))D((E$T5((r6   Fc                 >   t          |           }||                    |           |8t          |          rt          j        |          }|                    |           |||                    ||n|           |r|                    t          j	                   |
                    |           ||j                            |           |t          |||	|
           ||                    |           |||_        |rt!          j        ||||           |S )zCreate a QToolButton)r    setTextr%   r'   get_iconsetIcon
setToolTipsetToolButtonStyler   ToolButtonTextBesideIconsetAutoRaiseclickedrV   setup_toggled_actionsetShortcutIDr,   register_reference)parentr   shortcuticontiptoggled	triggered	autoraisetext_beside_iconsectionoptionid_plugincontext_nameregister_toolbuttonbuttons                   r4   create_toolbuttonr     s@      Ft$ 	&<%%Dt3?#+$$3777 ?!!""=>>>
	"""y)))VWgv>>>8$$$
	 /.C	/ 	/ 	/Mr6          c                    d}t           | z  ||z  z
  |t           z   z  }| d|z  z
  dz  }t          |d          }|                    d           |                    |           |                    |           |                    |           |                    |           |                    t          j	                   |S )zS
    Create a wait spinner with the specified size built with n circling dots.
    r      F)centerOnParentT)
r   r-   setTrailSizeDecreasingsetNumberOfLinessetLineLengthsetLineWidthsetInnerRadiussetColorr*   COLOR_TEXT_1)sizenr   dot_paddingdot_sizeinner_radiusspinners          r4   create_waitspinnerr   %  s     K T	AO+B7H1x<'1,LfU;;;G""4(((Q(###"""<(((]/000Nr6   c                    ||                                  }t          |          }|                    |            |                    |           |r|                    t
          j                   |r|                     |           |S )z3Create a QToolButton directly from a QAction object)r   r    setDefaultActionr   r   r   r   r   )actionr   r   r   r   r   s         r4   action2buttonr   =  s     ~  F
F###
	""" ?!!""=>>> tMr6   c                 F    | | D ]}||                     |           dS dS )zEnable/disable actionsN)
setEnabled)actionsenabler   s      r4   toggle_actionsr   L  sD     	* 	*F!!!&))) 	* 	*r6   c                 $   t          || |          }||j                            |           |t          ||||
           |8t	          |          rt          j        |          }|                    |           |*|                    |           |	                    |           |"|
                    t          |                     ||                    |           t          j        dk    rVd|_        |	t           j        k    r|||_        nad|_        nY||                    |           |                    |	           n,||                    |           |                    |	           |rt)          j        |||||           |S )zCreate a QAction	action_idNr.   missing)SpyderActionr   rV   r   r%   r'   r   r   r   setStatusTipsetDatar   setMenuRoler?   rL   _shown_shortcutr   WidgetShortcutr   setShortcutContextr+   r   )r   r   r   r   r   r   r   datamenurolecontextr   r   r   r   r   register_action	overwriter   s                     r4   create_actionr   T  s    $#666F  +++VWgv>>>$ 	&<%%Dt
#C   {4(()))8$$$ |x!%b'''#)1&& *3&&#""8,,,%%g....x(((!!'*** :*Cy	: 	: 	:Mr6   c                     t          |||          }| j                            |           |                     d           |)|)t	          j        | ||           t          |            dS dS dS )z]
    Setup a checkable action and wrap the toggle function to receive
    configuration.
    TN)wrap_toggledr   rV   setCheckabler$   observe_configurationadd_configuration_update)r   r   r   r   s       r4   r   r     s    
 7GV44G
N7###
v1"67F;;; ((((( 11r6   c                 Z     %#t          j                    fd            }|S  S )z@Wrap a toggle function to set a value on a configuration option.Nc                 N    t          j        | d            |            d S )NT)recursive_notification)r$   set)valuer   r   r   s    r4   wrapped_toggledz%wrap_toggled.<locals>.wrapped_toggled  s-    HWfeDIIIIGENNNNNr6   )	functoolswraps)r   r   r   r	  s   ``` r4   r   r     sU    v1		!	!	 	 	 	 	 	 
"	!	 Nr6   c                 X    d }t          j        ||           }t          | d|           dS )zCAdd on_configuration_change to a SpyderAction that depends on CONF.c                     |                      d           |                     |           |                      d           d S NTF)blockSignals
setChecked)self_option_sectionr  s       r4   on_configuration_changez9add_configuration_update.<locals>.on_configuration_change  sB    $%     r6   r  N)types
MethodTypesetattr)r   r  methods      r4   r  r    s?    ! ! ! 5v>>FF-v66666r6   c                    t          | d          s|                                 | _        	 t          j        ||          }n## t
          j        t
          j        f$ r d}Y nw xY w|r^t          |          }|	                    t          j
                  }|                     d                    | j        |                     dS dS )z>Add the shortcut associated with a given action to its tooltip_tooltip_backup)r   r:   Nz	{0} ({1}))hasattrtoolTipr  r$   get_shortcutconfigparserNoSectionErrorNoOptionErrorr   r|   
NativeTextr   format)r   r   r:   r   keyseqstrings         r4   add_shortcut_to_tooltipr%    s    6,-- 2
 "(!1!1$W4@@@')CD     Oh''!899,--f.DfMMNNNNN	O Os   A A"!A"c                 ,   d}t          |                                           }|r|d         }|                                rd}|D ]}|/|-||                                  n|                     |           nt          |t                    r/||                     |           nk|                     ||           nTt          |t                    r?|'	 | 
                    |           n&# t          $ r Y w xY w|                     ||           |}dS )z%Add actions to a QMenu or a QToolBar.N)listr   isSeparatoraddSeparatorinsertSeparatorr   r   addMenu
insertMenur   	addActionRuntimeErrorinsertAction)targetr   insert_beforeprevious_actiontarget_actionsr   s         r4   add_actionsr5    sW   O&..**++N #(,&&(( 	#"O ! !N!<$##%%%%&&}5555&& 	;$v&&&&!!-8888(( 
	;$$$V,,,,#   H ##M6::: -! !s   C++
C87C8c                 h    t          |                     dt          j                  t                    S )z$Get QTreeWidgetItem user role stringr   )r   r   r   UserRoler&   )items    r4   get_item_user_textr9    s"    1bk22NCCCr6   c                 b    |                      dt          j        t          |                     dS )z$Set QTreeWidgetItem user role stringr   N)r   r   r7  r   )r8  r   s     r4   set_item_user_textr;    s(    LLBKT!2!233333r6   c                 ^    t                      fd            }t          | ||||          S )zCreate bookmark actionc                  "    t                     S r   )r5   )r3   s   r4   open_urlz(create_bookmark_action.<locals>.open_url  s    #r6   )r   r   r   )r   r   )r   r3   titler   r   r>  s    `    r4   create_bookmark_actionr@    sP     
VV    V &%($,. . . .r6   c                     g }|D ]L\  }}}d}|dk    rt          j        |          sd}|r&t          | ||          }|                    |           M|S )zt
    Create bookmark actions depending on module installation:
    bookmarks = ((module_name, url, title), ...)
    T	winpythonF)r(   is_module_installedr@  r   )r   	bookmarksr   r{   r3   r?  
create_actacts           r4   create_module_bookmark_actionsrG    sy    
 G$ 	  	 S% 
+/44 #"
 	 (e<<CNN3Nr6   c                     t          |          rt          j        |          }t          j        dk    r||t          j                  }|t          | ||fd          S dS )zCreate action to run a programra   Nc                  ,    t          j                   S r   )r(   run_program)r:   s   r4   <lambda>z'create_program_action.<locals>.<lambda>  s    x/CD/I/I r6   r   r   )r%   r'   r   rS   r:   r(   find_programr   )r   r   r:   r   nt_namer   s     `   r4   create_program_actionrO    s    d "|D!!	w$7. &&DVT'I'I'I'IK K K 	K r6   c                     t          |          rt          j        |          }t          j                  rt          | ||fd          S dS )z.Create action to run a GUI based Python scriptc                  0    t          j                   S r   )r(   run_python_script)argsmodulepackages   r4   rK  z-create_python_script_action.<locals>.<lambda>  s    %7NN r6   rL  N)r%   r'   r   r(   python_script_existsr   )r   r   r   rU  rT  rS  s      ```r4   create_python_script_actionrW    s    d "|D!!$Wf55 PVT(O (O (O (O (O (OP P P 	PP Pr6   c                   *    e Zd ZdZd Zd Zd Zd ZdS )DialogManagerz
    Object that keep references to non-modal dialog boxes for another QObject,
    typically a QMainWindow or any kind of QWidget
    c                 <    t          j        |            i | _        d S r   )r
   __init__dialogsr  s    r4   r[  zDialogManager.__init__#  s    r6   c                 >    t           j                                                  D ]q}t          |                                          t          |                                          k    r+|                                 |                                  dS r|                                 | j        t          |          <   |j        	                    t          |          f fd	           |j
        	                    t          |          f fd	           dS )zYGeneric method to show a non-modal dialog and keep reference
        to the Qt C++ objectc                 .                         |           S r   dialog_finishedeidr  s    r4   rK  z$DialogManager.show.<locals>.<lambda>4      t';';C'@'@ r6   c                 .                         |           S r   r`  rb  s    r4   rK  z$DialogManager.show.<locals>.<lambda>6  rd  r6   N)r(  r\  valuesr&   windowTitleshowraise_idacceptedrV   rejected)r  dialogdlgs   `  r4   rh  zDialogManager.show'  s    ++--.. 	B 	BCcoo//00 !3!3!5!5667 7




	7 KKMMM'-DLF$O##f::@@@@@B B BO##f::@@@@@B B B B Br6   c                 6    | j                             |          S )zManage non-modal dialog boxes)r\  pop)r  	dialog_ids     r4   ra  zDialogManager.dialog_finished8  s    |	***r6   c                     t          | j                                                  D ]}|                                 dS )zClose all opened dialog boxesN)r(  r\  rf  reject)r  rn  s     r4   	close_allzDialogManager.close_all<  s@    ++--.. 	 	CJJLLLL	 	r6   N)__name__
__module____qualname____doc__r[  rh  ra  rt   r6   r4   rY  rY    s]         
  B B B"+ + +    r6   rY  c                     t          j        |           d         }|                    d          r
|dd         }t          j        d|z  t          j        d                    S )zReturn file type iconr   .Nz%s.pngFileIcon)r   r   r   r'   r   r   )rf   exts     r4   get_filetype_iconr~  B  sW    
,u

a
 C
~~c !""g<3(<(<===r6   c                   4     e Zd ZdZdd fd
Zd Zd Z xZS )r   >Spyder QAction class wrapper to handle cross platform patches.Nr   c                     t          t          |           j        |i | || _        t          j        dk    r|                     d           dS dS )r  r.   FN)superr   r[  r   r?   rL   setIconVisibleInMenu)r  r   rS  kwargs	__class__s       r4   r[  zSpyderAction.__init__M  s[    *lD!!*D;F;;;"<8##%%e,,,,, $#r6   c                 P    d                     |                                           S NzSpyderAction('{0}')r"  r   r]  s    r4   __str__zSpyderAction.__str__T      $++DIIKK888r6   c                 P    d                     |                                           S r  r  r]  s    r4   __repr__zSpyderAction.__repr__W  r  r6   )ru  rv  rw  rx  r[  r  r  __classcell__r  s   @r4   r   r   J  si        HH(, - - - - - - -9 9 99 9 9 9 9 9 9r6   r   c                       e Zd ZdZd ZdS )ShowStdIconsz'
    Dialog showing standard icons
    c           	      2   t          j        | |           t                      }d}d}t          t                    D ]}|                    d          r|dk    rt                      }t                      }t          j        |          }t                      }	|	
                    |                    dd                     |                    |	           |                    t          |                    dd                               |                    |           |dz   |z  }|dk    r|                    |           
|                     |           |                     d           |                     t          j        d                     d S )	N   r   SP_r    r   zStandard Platform IconsTitleBarMenuButton)r"   r[  r   dirr   r   r!   r'   get_std_iconr   r9   pixmap	addWidgetr   r   	addLayout	setLayoutsetWindowTitlesetWindowIcon)
r  r   layoutrow_nbcindexchild
col_layouticon_layoutr   r<   s
             r4   r[  zShowStdIcons.__init__`  sr   v&&&[[ 	1 	1E&& 1Q;;!,J)mm'..B 3 3444%%e,,,%%ieR0H0H&I&IJJJ$$[111 1*.Q;;$$Z000v56663+,@AABBBBBr6   N)ru  rv  rw  rx  r[  ry  r6   r4   r  r  [  s2         C C C C Cr6   r  c                      t                      } t          d          }|                                 t          j        |                                            dS )z!
    Show all standard Icons
    N)r_   r  rh  r?   exitexec_)r\   rm  s     r4   show_std_iconsr  x  sE     ..C$F
KKMMMHSYY[[r6   c           
      @   dddddddddd	}t                                                                          d	          }t          j        d
|}||v rI||         \  }}|                                                                 }||z
  |z   }t          |d          S dS )a  
    Return a spacing (int) or None if we don't have the appropriate metrics
    to calculate the spacing.

    We're trying to adapt the spacing below the tools_layout spacing so that
    the main_widget has the same vertical position as the editor widgets
    (which have tabs above).

    The required spacing is

        spacing = tabbar_height - tools_height + offset

    where the tabbar_heights were empirically determined for a combination of
    operating systems and styles. Offsets were manually adjusted, so that the
    heights of main_widgets and editor widgets match. This is probably
    caused by a still not understood element of the layout and style metrics.
    )r   r   )   rF   )   r   )   r'  )&   )   r   )   r   )	z	nt.fusionznt.windowsvistaznt.windowsxpz
nt.windowszposix.breezezposix.oxygenzposix.qtcurvezposix.windowszposix.fusionr:   r{  r   N)r_   stylepropertyrS   r:   sizeHintheightmax)tools_layoutmetrics
style_namer{   tabbar_heightoffsettools_heightspacings           r4   calc_tools_spacingr    s    & "    
 
G %%''0088JWWWjj
)C
g~~ 'v#,,..5577,.77A	 ~r6   c                     t                      }|                    dddd           t          |           }||                    |           |                    |            ||                    |           |S )a  
    Returns a layout for a set of controls above a main widget. This is a
    standard layout for many plugin panes (even though, it's currently
    more often applied not to the pane itself but with in the one widget
    contained in the pane.

    tools_layout: a layout containing the top toolbar
    main_widget: the main widget. Can be None, if you want to add this
        manually later on.
    r   )r!   setContentsMarginsr  
setSpacingr  r  )r  main_widgetr  r  s       r4   create_plugin_layoutr    s     ]]F
aAq))) ..G'"""
\"""%%%Mr6   c                    |                                  }|D ]t}	 |                                #t          |                                |           n*|                                rO|                    |           e# t
          $ r Y qw xY wdS )z!Show/hide icons for menu actions.N)r   menuset_menu_iconsr)  r  r/  )r  statemenu_actionsr   s       r4   r  r    s    <<>>L 
 
		{{}}(v{{}}e4444##%% 3++E222 	 	 	H	
 
s   AA<&A<<
B	B	c                       e Zd ZdZddZdS )SpyderProxyStylez(Style proxy to adjust qdarkstyle issues.r   c                 V    |t           j        k    rdS t          j        | ||||          S )zOverride Qt method.r   )r   SH_ComboBox_Popupr   	styleHint)r  hintr   widget
returnDatas        r4   r  zSpyderProxyStyle.styleHint  s0    6+++ 1$T4LLLr6   N)r   r   r   )ru  rv  rw  rx  r  ry  r6   r4   r  r    s4        22M M M M M Mr6   r  c                   $     e Zd ZdZd fd	Z xZS )QInputDialogMultilinezy
    Build a replica interface of QInputDialog.getMultilineText.

    Based on: https://stackoverflow.com/a/58823967
    r  c                 r    t          t          |           j        |fi | ||                     |           |                     t                                 |                                                     t          |                     t                      | _
        |                                                     | j
                   t                      }|                                 t          d          }|                    |           t          d          }|                    |           |                                                     |           | j
                            |           |j                            | j                   |j                            | j                   d S )NOKCancel)r  r  r[  r  r  r!   r  r  r   r   	text_editr   
addStretchr   r  setPlainTextr   rV   acceptrs  )
r  r   r?  r<   r   r  button_layout	ok_buttoncancel_buttonr  s
            r4   r[  zQInputDialogMultiline.__init__  sm   3#T**3FEEfEEE&&&{}}%%%u...'))///#  """%%		***#H--......##D)))!!$+...%%dk22222r6   )r  )ru  rv  rw  rx  r[  r  r  s   @r4   r  r    sG         3 3 3 3 3 3 3 3 3 3r6   r  c                   4    e Zd ZdZ ee          Zd Zd ZdS )rM   z;Subclass to be able to open external files with our Mac appc                 b    t          j        | g|R   d| _        d| _        g | _        i | _        d S r  )r   r[  _never_shown_has_started_pending_file_open_original_handlers)r  rS  s     r4   r[  zMacApplication.__init__  sA    d*T**** !"$"$r6   c                 p   |                                 t          j        k    rt          |                                          }t
          j        rt
          j        d         |k    rn<| j        r| j        	                    |           n| j
                            |           t          j        | |          S )Nr   )r   r   FileOpenru   filer?   argvr  sig_open_external_fileemitr  r   r   r   )r  r   rf   s      r4   r   zMacApplication.event
  s    ::<<6?**

%%Ex 6CHQK500 " 6+007777'..u555!$...r6   N)	ru  rv  rw  rx  r   ru   r  r[  r   ry  r6   r4   rM   rM     sF        EE#VC[[% % %/ / / / /r6   rM   c                      t          j                    } | j                                        D ] \  }}|\  }}t	          j        |||           !dS )z,Restore LaunchServices to the previous stateN)r   rN   r  itemsalsset_UTI_handler)r\   r{   handlerUTIroles        r4   restore_launchservicesr    s]    


!
!C.4466 0 0W	TCw////0 0r6   public.python-scripteditorc                 X    t          j                    t          j                   }|j         f<   j                            t                     j        s+t          j	                    }t          j
         |           dS  fd}j                            |           dS )zO
    Register app to the Apple launch services so it can open Python files
    Nc                     | t           j        k    r9j        r4d_        t          j                    }t          j        |           d S d S d S )NF)r   ApplicationActiver  r  get_bundle_identifierr  )r  bundle_identifierr\   r  uniform_type_identifiers     r4   handle_applicationStateChangedzCregister_app_launchservices.<locals>.handle_applicationStateChanged6  sj    B(((S-=($C # 9 ; ;'/@B B B B B )(((r6   )r   rN   r  get_UTI_handlerr  aboutToQuitrV   r  r  r  r  applicationStateChanged)r  r  old_handlerr  r  r\   s   ``   @r4   rQ   rQ      s     

!
!C%&=tDDK>IC3T:; O2333 577#T+<	> 	> 	>B B B B B B B ''(FGGGGGr6   __main__)r7   )TrF   r   )NNNNNNTFNNNNNF)r   r   N)TFNN)NN)r  r  )xrx  r  r
  mathr   loggingrS   os.pathr   r   rd   r?   r  urllib.parser   qtpy.compatr   r   qtpy.QtCorer   r   r	   r
   r   r   r   r   r   r   
qtpy.QtGuir   r   r   r   qtpy.QtWidgetsr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   spyder.config.baser#   spyder.config.managerr$   spyder.py3compatr%   r&   spyder.utils.icon_managerr'   spyder.utilsr(   spyder.utils.image_path_managerr)   spyder.utils.paletter*   spyder.utils.registriesr+   r,   spyder.widgets.waitingspinnerr-   rL   applaunchservicesr  	getLoggerru  loggerMENU_SEPARATORr5   r=   rE   r_   rg   rj   rR   rx   r   r   r   r   r   r   r   r   r   r   WindowShortcutr   r   r   r  r%  r5  r9  r;  r@  rG  rO  rW  rY  r~  r   r  r  r  r  r  r  r  rM   r  rQ   ry  r6   r4   <module>r     s                    				       				 



              3 2 2 2 2 2 2 2: : : : : : : : : : : : : : : : : : : : : : : : I I I I I I I I I I I I? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 2 1 1 1 1 1 & & & & & & ; ; ; ; ; ; ; ; ) ) ) ) ) ) ! ! ! ! ! ! : : : : : : . . . . . . H H H H H H H H 9 9 9 9 9 9 <8$6$6$8$8#### 
	8	$	$) ) )$        $ $ $ $N
! 
! 
! 
. 
. 
.? ? ?5 5 5:  "   *1 1 1" " "

) 
) 
) HL.27<BF=B	   B   0 JN   * * * *.Dd$TD+D$4d"'5	. . . .b
) 
) 
)  7 7 7O O O,! ! ! !BD D D
4 4 4
. . . .  &	K 	K 	K 	K KM P P P P" " " " "G " " "J> > >9 9 9 9 97 9 9 9"C C C C C7 C C C:  % % %P   .   
M 
M 
M 
M 
M{ 
M 
M 
M3 3 3 3 3G 3 3 3B/ / / / /\ / / /20 0 0 !7H H H H@ zN r6   