Your IP : 3.12.165.68


Current Path : /opt/alt/python310/lib64/python3.10/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib64/python3.10/__pycache__/webbrowser.cpython-310.opt-1.pyc

o

6��f�^�@s�dZddlZddlZddlZddlZddlZddlZgd�ZGdd�de�Z	e�
�ZiZda
dad=dd�dd	�Zd=d
d�Zd>d
d�Zdd�Zdd�Zdd�dd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZGd#d$�d$e�ZeZGd%d&�d&e�ZGd'd(�d(e�Z Gd)d*�d*e�Z!Gd+d,�d,e�Z"d-d.�Z#d/d0�Z$ej%dd1�d2kr�Gd3d4�d4e�Z&ej%d5kr�Gd6d7�d7e�Z'Gd8d9�d9e�Z(d:d;�Z)e*d<kr�e)�dSdS)?z?Interfaces for launching and remotely controlling web browsers.�N)�Error�open�open_new�open_new_tab�get�registerc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�1/opt/alt/python310/lib64/python3.10/webbrowser.pyrsrF��	preferredcCs�t�4tdur
t�||gt|��<|str!|tvr!t�d|�n
t�|�Wd�dSWd�dS1s9wYdS)zRegister a browser connector.Nr)�_lock�	_tryorder�register_standard_browsers�	_browsers�lower�_os_preferred_browser�insert�append)�name�klass�instancerrrrrs�	"�rc	Cs�tdurt�tdurt�Wd�n1swY|dur%|g}nt}|D]P}d|vrJt�|�}|ddkrDt|dd��St|�Szt|��}Wn
t	y_t
|�}Ynw|ddurl|dS|ddury|d�Sq)td��)zCReturn a browser launcher instance appropriate for the environment.N�%s����&�rz!could not locate runnable browser)rrr�shlex�split�BackgroundBrowser�GenericBrowserrr�KeyError�_synthesizer)ZusingZalternatives�browser�commandrrrr%s4��
��rTcCsdtdurt�tdurt�Wd�n1swYtD]}t|�}|�|||�r/dSqdS)aDisplay url using the default browser.

    If possible, open url in a location determined by new.
    - 0: the same browser window (the default).
    - 1: a new browser window.
    - 2: a new browser page ("tab").
    If possible, autoraise raises the window (the default) or not.
    NTF)rrrrr)�url�new�	autoraiserr$rrrrGs	���rcC�
t|d�S)zuOpen url in a new window of the default browser.

    If not possible, then open url in the only browser window.
    r�r�r&rrrrZ�
rcCr))z�Open url in a new page ("tab") of the default browser.

    If not possible, then the behavior becomes equivalent to open_new().
    �r*r+rrrrar,rcCs�|��d}t�|�sddgStj�|�}zt|��}Wn
ty*ddgYSw|d}|rW|��|jkrWddl	}|�	|�}||_
tj�|�|_t|d||d�d|gSddgS)a�Attempt to synthesize a controller based on existing controllers.

    This is useful to create a controller when a user specifies a path to
    an entry in the BROWSER environment variable -- we can copy a general
    controller to operate using a specific installation of the desired
    browser in this way.

    If we can't create a controller in this way, or if there is no
    executable for the requested browser, return [None, None].

    rNr)rr)r�shutil�which�os�path�basenamerrr"�copyrr)r$r�cmdrr%Z
controllerr3rrrr#is$
�
r#c@s:eZdZdZdgZddd�Zddd	�Zd
d�Zdd
�ZdS)�BaseBrowserz3Parent class for all browsers. Do not use directly.r�cCs||_||_dS�N)rr2��selfrrrr�__init__�s
zBaseBrowser.__init__rTcCst�r7)�NotImplementedError�r9r&r'r(rrrr�szBaseBrowser.opencC�|�|d�S)Nrr*�r9r&rrrr��zBaseBrowser.open_newcCr=)Nr-r*r>rrrr�r?zBaseBrowser.open_new_tabN)r6�rT)	rr	r
�__doc__�argsr:rrrrrrrr5�s

r5c@�"eZdZdZdd�Zd	dd�ZdS)
r!zVClass for all browsers started with a command
       and without remote functionality.cCsFt|t�r
||_dg|_n|d|_|dd�|_tj�|j�|_dS)Nrrr)�
isinstance�strrrBr0r1r2r8rrrr:�s


zGenericBrowser.__init__rTcsvt�d��|jg�fdd�|jD�}ztjdd�dkr$t�|�}ntj|dd�}|��WSty:YdSw)	N�webbrowser.openc�g|]}|�d���qS�r��replace��.0�argr+rr�
<listcomp>���z'GenericBrowser.open.<locals>.<listcomp>��winT)�	close_fdsF)	�sys�auditrrB�platform�
subprocess�Popen�wait�OSError�r9r&r'r(�cmdline�prr+rr�s��zGenericBrowser.openNr@�rr	r
rAr:rrrrrr!�s
r!c@�eZdZdZddd�ZdS)r zHClass for all browsers which are to be started in the
       background.rTcsz|jg�fdd�|jD�}t�d��ztjdd�dkr$t�|�}ntj|ddd�}|��duWSty<YdSw)	NcrGrHrIrKr+rrrN�rOz*BackgroundBrowser.open.<locals>.<listcomp>rFrPrQT)rR�start_new_sessionF)	rrBrSrTrUrVrW�pollrYrZrr+rr�s���zBackgroundBrowser.openNr@�rr	r
rArrrrrr �sr c@sDeZdZdZdZdZdZddgZdZdZ	dZ
ddd�Zd
d
d�ZdS)�UnixBrowserz=Parent class for all Unix browsers with remote functionality.NFT�%actionrcCs�g}|r|jrt|�}|j|}|r|g}|jg||}|s"|jr&tj}nd}tj|d||jr2|p3d|dd�}	|rOz	|	�d�}
|
WStj	yNYdSw|jr\|	�
�durZdSdS|	��S)NT�rR�stdin�stdout�stderrr_�F)�
raise_opts�intr�
backgroundrV�DEVNULLrW�redirect_stdoutrXZTimeoutExpiredr`)r9rBZremoter(r&Z	raise_opt�optr[Zinoutr\�rcrrr�_invoke�s2




�
�
zUnixBrowser._invokercs�t�d��|dkr|j�n!|dkr|j�n|dkr'|jdur#|j�n|j�ntdd|����fdd�|jD�}d	d�|D�}|�|d
|��}|s\�fdd�|jD�}|�|dd�Sd
S)
NrFrrr-zBad 'new' parameter to open(); zexpected 0, 1, or 2, got %scs g|]}|�d���d���qS)rrcrIrK��actionr&rrrNs�z$UnixBrowser.open.<locals>.<listcomp>cSsg|]}|r|�qSrrrKrrrrNsTcrGrHrIrKr+rrrNsF)	rSrT�
remote_action�remote_action_newwin�remote_action_newtabr�remote_argsrprB)r9r&r'r(rBZsuccessrrqrrs*
��zUnixBrowser.openr7r@)
rr	r
rArirkrmrvrsrtrurprrrrrrb�s
#rbc@s(eZdZdZddgZdZdZdZdZdS)	�Mozillaz$Launcher class for Mozilla browsers.rcrr6z-new-windowz-new-tabTN�	rr	r
rArvrsrtrurkrrrrrw�rwc@s0eZdZdZddgZddgZdZdZdZd	Z	d
S)�Netscapez$Launcher class for Netscape browser.�-noraisez-raise�-remote�openURL(%s%action)r6�,new-window�,new-tabTN)
rr	r
rArirvrsrtrurkrrrrrz&srzc@s,eZdZdZddgZddgZdZdZdZd	S)
�Galeonz,Launcher class for Galeon/Epiphany browsers.r{r6rcr�-nz-wTN)	rr	r
rArirvrsrtrkrrrrr�1sr�c@�(eZdZdZddgZdZdZdZdZdS)�Chromez)Launcher class for Google Chrome browser.rcrr6�--new-windowTNrxrrrrr�;ryr�c@r�)�Operaz!Launcher class for Opera browser.rcrr6r�TNrxrrrrr�Gryr�c@s,eZdZdZddgZdZdZdZdZdZ	dS)	�Elinksz#Launcher class for Elinks browsers.r|r}r6r~rFN)
rr	r
rArvrsrtrurkrmrrrrr�Qsr�c@r^)�	Konquerorz�Controller for the KDE File Manager (kfm, or Konqueror).

    See the output of ``kfmclient --commands``
    for more information on the Konqueror remote-control interface.
    rTcCs�t�d|�|dkr
d}nd}tj}ztjd||gd|||d�}Wn	ty*Ynw|��dSztjdd	|gd|||dd
�}Wn	tyJYn	w|��durSdSztjdd|gd|||dd
�}Wn
tymYd
Sw|��duS)NrFr-ZnewTabZopenURL�	kfmclientT)rRrerfrg�	konquerorz--silentrd�kfmz-dF)rSrTrVrlrWrYrXr`)r9r&r'r(rr�devnullr\rrrrfsH
��
��
��zKonqueror.openNr@rarrrrr�_sr�c@s&eZdZdd�Zdd�Zd
dd�Zd	S)�GrailcCs�ddl}ddl}ddl}ddl}tj�|��d�}|�t�	��d}tj�|�
|�|�
|�d�}|�|�}|s:dS|�|j|j�}	|D]&}
z
|	�
|
�W|	Styjzt�|
�Wn	tygYnwYqDwdS)Nrz.grail-unixz-*)�glob�pwd�socket�tempfiler0r1�joinZ
gettempdir�getpwuid�getuid�escapeZAF_UNIXZSOCK_STREAMZconnectrY�unlink)r9r�r�r�r�Ztempdir�user�filenameZmaybes�s�fnrrr�_find_grail_rc�s4�
�����zGrail._find_grail_rccCs&|��}|sdS|�|�|��dS)Nrr)r��send�close)r9rrr�rrr�_remote�s
z
Grail._remoterTcCs4t�d|�|r|�d|�}|S|�d|�}|S)NrFzLOADNEW zLOAD )rSrTr�)r9r&r'r(�okrrrr�s�z
Grail.openNr@)rr	r
r�r�rrrrrr��sr�cCs�t�d�r
tddtd��dtjvrt�d�rtddtd��dtjvr1t�d�r1tddtd��dtjvrCt�d�rCtdttd��t�d�rPtddtd��dD]}t�|�rat|dt|��qRd	D]}t�|�rst|dt|��qdt�d
�r�td
ttd
��n
t�d�r�tdttd��dD]}t�|�r�t|dt	|��q�t�d
�r�td
dtd
��dD]}t�|�r�t|dt
|��q�t�d�r�tddtd��t�d�r�tddtd��t�d�r�tdtd�dSdS)Nzxdg-openZGNOME_DESKTOP_SESSION_IDz	gvfs-openz
gnome-openZKDE_FULL_SESSIONr�z
x-www-browser)�firefoxZ	iceweaselZiceape�	seamonkey)zmozilla-firefoxzmozilla-firebird�firebird�mozilla�netscaper�r�)ZgaleonZepiphanyZ	skipstone)z
google-chrome�chromeZchromiumzchromium-browser�operaZmosaicZgrail)
r.r/rr r0�environr�rwrzr�r�r�r�)r$rrr�register_X_browsers�sN


�
�


�

�


�r�cCs6gatjdkr'tddtd��tddtd��tddtd��tddtd��tjdkr4tddtd��tjdd	�d
krhtdt�tj�	tj
�dd
�d�}dddddd|fD]}t�
|�rft|dt|��qWn{tj
�d�sttj
�d�r�zd��}tj|tjd�}|����}Wnttjttfy�Ynw|at�tj
�d�r�t�
d�r�tddtd��t�
d�r�tddtd��t�
d�r�tddtd��t�
d�r�tddtd��t�
d�r�tddtd��dtj
v�rtj
d�tj�}|��|D] }|dk�rt|d d!�}|d"du�rt|dt|�d d!�q�dSdS)#N�darwin�MacOSX�defaultr�r�ZsafariZ
serenityosZBrowserrPrQzwindows-defaultZPROGRAMFILESzC:\Program FileszInternet Explorer\IEXPLORE.EXEr�r�r�r�r�ZDISPLAYZWAYLAND_DISPLAYz$xdg-settings get default-web-browser)rgZTERMzwww-browserZlinksZelinksZlynxZw3mZBROWSERr6Tr
r)rrSrUr�MacOSXOSAScriptr �WindowsDefaultr0r1r�r�rr.r/rrVZcheck_outputrl�decode�strip�FileNotFoundErrorZCalledProcessError�PermissionError�NotADirectoryErrorrr�r!r��pathsep�reverser#)Ziexplorer$r4Z
raw_result�resultZuserchoicesr[rrrrsh


��
���





��rrPrQc@seZdZddd�ZdS)r�rTcCs2t�d|�zt�|�WdStyYdSw)NrFFT)rSrTr0Z	startfilerYr<rrrr\s��zWindowsDefault.openNr@)rr	r
rrrrrr�[sr�r�c@rC)
r�a{Launcher class for Aqua browsers on Mac OS X

        Optionally specify a browser name on instantiation.  Note that this
        will not work for Aqua browsers if the user has moved the application
        package after installation.

        If no browser is specified, the default browser, as specified in the
        Internet System Preferences panel, will be used.
        cC�
||_dSr7)rr8rrrr:w�
zMacOSX.__init__rTc	Cs�t�d|�d|vrd|}tt|��}|jdkr"d|�dd�}n|jdkr*d	}nd
|d}d|�dd�}d
|j||f}t�dd�}|durLdS|�|�|�	�}|S)NrF�:zfile:r��open location "%s"�"�%22ZOmniWebr6ztoWindow %drzOpenURL "%s"z�tell application "%s"
                                activate
                                %s %s
                            end tell�	osascript�wF)
rSrTrj�boolrrJr0�popen�writer�)	r9r&r'r(�scriptZtoWindowr4�osapiperorrrrzs&


�
zMacOSX.openNr@r]rrrrr�ms	r�c@seZdZdd�Zddd�ZdS)	r�cCr�r7)�_namer8rrrr:�r�zMacOSXOSAScript.__init__rTcCsb|jdkrd|�dd�}nd|j|�dd�f}t�dd�}|dur%dS|�|�|��}|S)	Nr�r�r�r�z�
                   tell application "%s"
                       activate
                       open location "%s"
                   end
                   r�r�F)r�rJr0r�r�r�)r9r&r'r(r�r�rorrrr�s
�
zMacOSXOSAScript.openNr@)rr	r
r:rrrrrr��sr�c	
Cs�ddl}dtjd}z|�tjdd�d�\}}Wn&|jy@}zt|tjd�t|tjd�t�d�WYd}~nd}~wwd}|D]\}}|dkrPd}qE|dkrVd}qEt|�dkrit|tjd�t�d�|d}t||�td	�dS)
NrzDUsage: %s [-n | -t] url
    -n: open new window
    -t: open new tabrZntd)�filer�z-tr-�)	�getoptrS�argv�error�printrg�exit�lenr)	r�ZusageZoptsrB�msgZnew_win�o�ar&rrr�main�s.����

r��__main__r7r@)+rAr0rr.rSrVZ	threading�__all__�	Exceptionr�RLockrrrrrrrrrr#�objectr5r!r rbrwrzr�r�ZChromiumr�r�r�r�r�rrUr�r�r�r�rrrrr�<module>sV

""O

	
56AO
/
�

?>