Your IP : 18.222.67.8


Current Path : /opt/alt/python39/lib64/python3.9/__pycache__/
Upload File :
Current File : //opt/alt/python39/lib64/python3.9/__pycache__/webbrowser.cpython-39.pyc

a

R�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�d2k�r�Gd3d4�d4e�Z&ej%d5k�r�Gd6d7�d7e�Z'Gd8d9�d9e�Z(d:d;�Z)e*d<k�r�e)�dS)@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�//opt/alt/python39/lib64/python3.9/webbrowser.pyrsrF��	preferredcCsnt�Vtdurt�||gt|��<|s4trB|tvrBt�d|�n
t�|�Wd�n1s`0YdS)zRegister a browser connector.Nr)�_lock�	_tryorder�register_standard_browsers�	_browsers�lower�_os_preferred_browser�insert�append)�name�klass�instancerrrrrsrc	Cstdur:t�tdurt�Wd�n1s00Y|durJ|g}nt}|D]�}d|vr�t�|�}|ddkr�t|dd��St|�SqRzt|��}Wnt	y�t
|�}Yn0|ddur�|dS|ddurR|d�SqRtd��dS)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%s,$
rTcCsdtdur:t�tdurt�Wd�n1s00YtD] }t|�}|�|||�r>dSq>dS)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	$rcCs
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rZsrcCs
t|d�S)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rasrcCs�|��d}t�|�sddgStj�|�}zt|��}WntyTddgYS0|d}|r�|��|jkr�ddl	}|�	|�}||_
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
controllerr1rrr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)rr0��selfrrrr�__init__�szBaseBrowser.__init__rTcCst�dSr5)�NotImplementedError�r7r&r'r(rrrr�szBaseBrowser.opencCs|�|d�S)Nrr)�r7r&rrrr�szBaseBrowser.open_newcCs|�|d�S)Nr+r)r;rrrr�szBaseBrowser.open_new_tabN)r4)rT)	rr	r
�__doc__�argsr8rrrrrrrr3�s

r3c@s"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�strrr=r.r/r0r6rrrr8�s


zGenericBrowser.__init__rTcszt�d��|jg�fdd�|jD�}z8tjdd�dkrHt�|�}ntj|dd�}|��WStytYdS0dS)	N�webbrowser.opencsg|]}|�d���qS�r��replace��.0�argr*rr�
<listcomp>�s�z'GenericBrowser.open.<locals>.<listcomp>��winT)�	close_fdsF)	�sys�auditrr=�platform�
subprocess�Popen�wait�OSError�r7r&r'r(�cmdline�prr*rr�s�zGenericBrowser.openN)rT�rr	r
r<r8rrrrrr!�s
r!c@seZdZdZddd�ZdS)r zHClass for all browsers which are to be started in the
       background.rTcs~|jg�fdd�|jD�}t�d��z<tjdd�dkrHt�|�}ntj|ddd�}|��duWStyxYdS0dS)	Ncsg|]}|�d���qSrArBrDr*rrrG�s�z*BackgroundBrowser.open.<locals>.<listcomp>r@rHrIT)rJ�start_new_sessionF)	rr=rKrLrMrNrO�pollrQrRrr*rr�s��zBackgroundBrowser.openN)rT�rr	r
r<rrrrr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*|jr*t|�}|j|}|r*|g}|jg||}|sD|jrLtj}nd}tj|d||jrd|pfd|dd�}	|r�z|	�d�}
|
WStj	y�YdS0n&|jr�|	�
�dur�dSdSn
|	��SdS)NT�rJ�stdin�stdout�stderrrV�F)�
raise_opts�intr�
backgroundrN�DEVNULLrO�redirect_stdoutrPZTimeoutExpiredrW)r7r=Zremoter(r&Z	raise_opt�optrSZinoutrT�rcrrr�_invoke�s0




�

zUnixBrowser._invokercs�t�d��|dkr|j�nB|dkr,|j�n2|dkrN|jdurF|j�q^|j�ntdd|����fdd�|jD�}d	d�|D�}|�|d
|��}|s��fdd�|jD�}|�|dd�Sd
SdS)
Nr@rrr+zBad 'new' parameter to open(); zexpected 0, 1, or 2, got %scs g|]}|�d���d���qS)rrZrBrD��actionr&rrrGs�z$UnixBrowser.open.<locals>.<listcomp>cSsg|]}|r|�qSrrrDrrrrG�Tcsg|]}|�d���qSrArBrDr*rrrGrjF)	rKrL�
remote_action�remote_action_newwin�remote_action_newtabr�remote_argsrgr=)r7r&r'r(r=Zsuccessrrhrrs*
��zUnixBrowser.open)N)rT)
rr	r
r<r`rbrdrnrkrlrmrgrrrrrrY�s
#rYc@s(eZdZdZddgZdZdZdZdZdS)	�Mozillaz$Launcher class for Mozilla browsers.rZrr4z-new-windowz-new-tabTN�	rr	r
r<rnrkrlrmrbrrrrrosroc@s0eZdZdZddgZddgZdZdZdZd	Z	d
S)�Netscapez$Launcher class for Netscape browser.�-noraisez-raise�-remote�openURL(%s%action)r4�,new-window�,new-tabTN)
rr	r
r<r`rnrkrlrmrbrrrrrq&srqc@s,eZdZdZddgZddgZdZdZdZd	S)
�Galeonz,Launcher class for Galeon/Epiphany browsers.rrr4rZr�-nz-wTN)	rr	r
r<r`rnrkrlrbrrrrrw1srwc@s(eZdZdZddgZdZdZdZdZdS)�Chromez)Launcher class for Google Chrome browser.rZrr4�--new-windowTNrprrrrry;sryc@s(eZdZdZddgZdZdZdZdZdS)�Operaz!Launcher class for Opera browser.rZrr4rzTNrprrrrr{Gsr{c@s,eZdZdZddgZdZdZdZdZdZ	dS)	�Elinksz#Launcher class for Elinks browsers.rsrtr4rurvFN)
rr	r
r<rnrkrlrmrbrdrrrrr|Qsr|c@seZdZdZddd�ZdS)�	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|�|dkrd}nd}tj}ztjd||gd|||d�}WntyTYn0|��dSz tjdd	|gd|||dd
�}Wnty�Yn0|��dur�dSz tjdd|gd|||dd
�}Wnty�Yd
S0|��duSdS)Nr@r+ZnewTabZopenURL�	kfmclientT)rJr\r]r^�	konquerorz--silentr[�kfmz-dF)rKrLrNrcrOrQrPrW)r7r&r'r(ri�devnullrTrrrrfsB�
�
�
zKonqueror.openN)rTrXrrrrr}_sr}c@s&eZdZdd�Zdd�Zd
dd�Zd	S)�GrailcCs�ddl}ddl}ddl}ddl}tj�|��d�}|�t�	��d}tj�|�
|�|�
|�d�}|�|�}|stdS|�|j|j�}	|D]P}
z|	�
|
�Wn4ty�zt�|
�Wnty�Yn0Yq�0|	Sq�dS)Nrz.grail-unixz-*)�glob�pwd�socket�tempfiler.r/�joinZ
gettempdir�getpwuid�getuid�escapeZAF_UNIXZSOCK_STREAMZconnectrQ�unlink)r7r�r�r�r�Ztempdir�user�filenameZmaybes�s�fnrrr�_find_grail_rc�s,�
zGrail._find_grail_rccCs&|��}|sdS|�|�|��dS)Nrr)r��send�close)r7rir�rrr�_remote�s
z
Grail._remoterTcCs2t�d|�|r |�d|�}n|�d|�}|S)Nr@zLOADNEW zLOAD )rKrLr�)r7r&r'r(�okrrrr�s
z
Grail.openN)rT)rr	r
r�r�rrrrrr��sr�cCs�t�d�rtddtd��dtjvr>t�d�r>tddtd��dtjvrbt�d�rbtddtd��dtjvr�t�d�r�tdttd��t�d�r�tddtd��dD]}t�|�r�t|dt|��q�d	D]}t�|�r�t|dt|��q�t�d
��rtd
ttd
��nt�d��r"tdttd��dD]"}t�|��r&t|dt	|���q&t�d
��rftd
dtd
��dD]"}t�|��rjt|dt
|���qjt�d��r�tddtd��t�d��r�tddtd��t�d��r�tdtd�dS)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 r.�environr}rorqrwryr{r�)r$rrr�register_X_browsers�sD



r�cCs,gatjdkrNtddtd��tddtd��tddtd��tddtd��tjdd�dkr�td	t�tj�tj	�
d
d�d�}dd
dddd|fD]}t�|�r�t|dt
|��q��ntj	�
d�s�tj	�
d��r$z(d��}tj|tjd�}|����}Wnttjttf�yYn0|at�tj	�
d��r�t�d��rNtddtd��t�d��rjtddtd��t�d��r�tddtd��t�d��r�tddtd��t�d��r�tddtd��dtj	v�r(tj	d�tj�}|��|D]>}|dk�r�t|dd�}|d du�r�t|dt|�dd��q�dS)!N�darwin�MacOSX�defaultr�r�ZsafarirHrIzwindows-defaultZPROGRAMFILESzC:\Program FileszInternet Explorer\IEXPLORE.EXEr�r�r�r�r�ZDISPLAYZWAYLAND_DISPLAYz$xdg-settings get default-web-browser)r^ZTERMzwww-browserZlinksZelinksZlynxZw3mZBROWSERr4Tr
r)rrKrMr�MacOSXOSAScript�WindowsDefaultr.r/r�r�rr,r-r rrNZcheck_outputrc�decode�strip�FileNotFoundErrorZCalledProcessError�PermissionError�NotADirectoryErrorrr�r!r|�pathsep�reverser#)Ziexplorer$r2Z
raw_result�resultZuserchoicesrSrrrrsX

��

rrHrIc@seZdZddd�ZdS)r�rTcCs8t�d|�zt�|�Wnty.YdS0dSdS)Nr@FT)rKrLr.Z	startfilerQr:rrrrXszWindowsDefault.openN)rT)rr	r
rrrrrr�Wsr�r�c@s"eZdZdZdd�Zd	dd�ZdS)
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.
        cCs
||_dSr5)rr6rrrr8sszMacOSX.__init__rTc	Cs�t�d|�d|vsJ�d|vr(d|}tt|��}|jdkrPd|�dd�}n<|jd	kr`d
}nd|d}d
|�dd�}d|j||f}t�dd�}|dur�dS|�|�|�	�}|S)Nr@�'�:zfile:r��open location "%s"�"�%22ZOmniWebr4ztoWindow %drzOpenURL "%s"z�tell application "%s"
                                activate
                                %s %s
                            end tell�	osascript�wF)
rKrLra�boolrrCr.�popen�writer�)	r7r&r'r(�scriptZtoWindowr2�osapiperfrrrrvs(


�
zMacOSX.openN)rTrUrrrrr�is	r�c@seZdZdd�Zddd�ZdS)	r�cCs
||_dSr5)�_namer6rrrr8�szMacOSXOSAScript.__init__rTcCsb|jdkrd|�dd�}nd|j|�dd�f}t�dd�}|durJdS|�|�|��}|S)	Nr�r�r�r�z�
                   tell application "%s"
                       activate
                       open location "%s"
                   end
                   r�r�F)r�rCr.r�r�r�)r7r&r'r(r�r�rfrrrr�s
�
zMacOSXOSAScript.openN)rT)rr	r
r8rrrrrr��sr�c	
Cs�ddl}dtjd}z|�tjdd�d�\}}WnL|jy�}z2t|tjd�t|tjd�t�d�WYd}~n
d}~00d}|D]"\}}|dkr�d}q�|dkr�d}q�t|�dkr�t|tjd�t�d�|d}t||�td	�dS)
NrzDUsage: %s [-n | -t] url
    -n: open new window
    -t: open new tabrZntd)�filerxz-tr+�)	�getoptrK�argv�error�printr^�exit�lenr)	r�ZusageZoptsr=�msgZnew_win�o�ar&rrr�main�s(� 

r��__main__)N)N)rT)+r<r.rr,rKrNZ	threading�__all__�	Exceptionr�RLockrrrrrrrrrr#�objectr3r!r rYrorqrwryZChromiumr{r|r}r�r�rrMr�r�r�r�rrrrr�<module>sR
"
"O

	
56AK/


?>