Your IP : 18.219.110.54


Current Path : /proc/self/root/opt/alt/python37/lib64/python3.7/__pycache__/
Upload File :
Current File : //proc/self/root/opt/alt/python37/lib64/python3.7/__pycache__/webbrowser.cpython-37.opt-2.pyc

B

YI~d�\�@s�ddlZddlZddlZddlZddlZddlZddddddgZGdd�de�Ze�	�Z
iZdada
d;d	d
�dd�Zd<dd�Zd=dd�Zdd�Zdd�Zd	d
�dd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd �d e�ZGd!d"�d"e�ZeZGd#d$�d$e�ZGd%d&�d&e�ZGd'd(�d(e�Z Gd)d*�d*e�Z!d+d,�Z"d-d.�Z#ej$dd/�d0k�r�Gd1d2�d2e�Z%ej$d3k�r�Gd4d5�d5e�Z&Gd6d7�d7e�Z'd8d9�Z(e)d:k�r�e(�dS)>�N�Error�open�open_new�open_new_tab�get�registerc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�//opt/alt/python37/lib64/python3.7/webbrowser.pyrsF)�	preferredc	CsZt�Ltdkrt�||gt|��<|s4trB|tkrBt�d|�n
t�|�WdQRXdS)Nr)�_lock�	_tryorder�register_standard_browsers�	_browsers�lower�_os_preferred_browser�insert�append)�name�klass�instancer
rrrrsc	Cs�tdkr&t�tdkrt�WdQRX|dk	r6|g}nt}x�|D]�}d|kr|t�|�}|ddkrrt|dd��St|�Sq@yt|��}Wnt	k
r�t
|�}YnX|ddk	r�|dS|ddk	r@|d�Sq@Wtd��dS)Nz%s����&�rz!could not locate runnable browser)rrr�shlex�split�BackgroundBrowser�GenericBrowserrr�KeyError�_synthesizer)ZusingZalternatives�browser�commandrrrr%s,


Tc	CsRtdkr&t�tdkrt�WdQRXx&tD]}t|�}|�|||�r,dSq,WdS)NTF)rrrrr)�url�new�	autoraiserr"rrrrGs	
cCs
t|d�S)Nr)r)r$rrrrZscCs
t|d�S)N�)r)r$rrrrascCs�|��d}t�|�sddgStj�|�}yt|��}Wntk
rRddgSX|d}|r�|��|jkr�ddl	}|�	|�}||_
tj�|�|_t|d||d�d|gSddgS)Nrr)rr
)r�shutil�which�os�path�basenamerrr �copyrr)r"r
�cmdrr#Z
controllerr-rrrr!is"


r!c@s6eZdZdgZddd�Zddd�Zd	d
�Zdd�Zd
S)�BaseBrowserz%s�cCs||_||_dS)N)rr,)�selfrrrr�__init__�szBaseBrowser.__init__rTcCst�dS)N)�NotImplementedError)r1r$r%r&rrrr�szBaseBrowser.opencCs|�|d�S)Nr)r)r1r$rrrr�szBaseBrowser.open_newcCs|�|d�S)Nr')r)r1r$rrrr�szBaseBrowser.open_new_tabN)r0)rT)rr	r
�argsr2rrrrrrrr/�s


r/c@seZdZdd�Zddd�ZdS)	rcCsFt|t�r||_dg|_n|d|_|dd�|_tj�|j�|_dS)Nz%srr)�
isinstance�strrr4r*r+r,)r1rrrrr2�s


zGenericBrowser.__init__rTcsl|jg�fdd�|jD�}y6tjdd�dkr<t�|�}ntj|dd�}|��Stk
rfdSXdS)Ncsg|]}|�d���qS)z%s)�replace)�.0�arg)r$rr�
<listcomp>�sz'GenericBrowser.open.<locals>.<listcomp>��winT)�	close_fdsF)rr4�sys�platform�
subprocess�Popen�wait�OSError)r1r$r%r&�cmdline�pr)r$rr�s
zGenericBrowser.openN)rT)rr	r
r2rrrrrr�s
rc@seZdZddd�ZdS)rrTcsp|jg�fdd�|jD�}y:tjdd�dkr<t�|�}ntj|ddd�}|��dkStk
rjdSXdS)Ncsg|]}|�d���qS)z%s)r7)r8r9)r$rrr:�sz*BackgroundBrowser.open.<locals>.<listcomp>r;r<T)r=�start_new_sessionF)rr4r>r?r@rA�pollrC)r1r$r%r&rDrEr)r$rr�szBackgroundBrowser.openN)rT)rr	r
rrrrrr�src@s>eZdZdZdZdZddgZdZdZdZ	dd�Z
dd	d
�ZdS)�UnixBrowserNFTz%actionz%sc
Cs�g}|r*|jr*t|�}|j|}|r*|g}|jg||}|sD|jrLtj}nd}tj|d||jrd|pfd|dd�}|r�y|�d�}	|	Stj	k
r�dSXn&|jr�|�
�dkr�dSdSn
|��SdS)NT)r=�stdin�stdout�stderrrF�F)�
raise_opts�intr�
backgroundr@�DEVNULLrA�redirect_stdoutrBZTimeoutExpiredrG)
r1r4Zremoter&Z	raise_opt�optrDZinoutrE�rcrrr�_invoke�s0





zUnixBrowser._invokercs�|dkr|j�nB|dkr |j�n2|dkrB|jdkr:|j�qR|j�ntdd|����fdd�|jD�}dd�|D�}|�|d	|�}|s��fd
d�|jD�}|�|dd�Sd	SdS)Nrrr'zBad 'new' parameter to open(); zexpected 0, 1, or 2, got %scs g|]}|�d���d���qS)z%sz%action)r7)r8r9)�actionr$rrr:
sz$UnixBrowser.open.<locals>.<listcomp>cSsg|]}|r|�qSrr)r8r9rrrr:sTcsg|]}|�d���qS)z%s)r7)r8r9)r$rrr:sF)�
remote_action�remote_action_newwin�remote_action_newtabr�remote_argsrTr4)r1r$r%r&r4�successr)rUr$rr�s$

zUnixBrowser.open)rT)rr	r
rMrOrQrYrVrWrXrTrrrrrrH�s#rHc@s$eZdZddgZdZdZdZdZdS)�Mozillaz%actionz%sr0z-new-windowz-new-tabTN)rr	r
rYrVrWrXrOrrrrr[s
r[c@s,eZdZddgZddgZdZdZdZdZd	S)
�Netscapez-noraisez-raisez-remotezopenURL(%s%action)r0z,new-windowz,new-tabTN)	rr	r
rMrYrVrWrXrOrrrrr\#sr\c@s(eZdZddgZddgZdZdZdZdS)	�Galeonz-noraiser0z%actionz%sz-nz-wTN)rr	r
rMrYrVrWrOrrrrr].s
r]c@s$eZdZddgZdZdZdZdZdS)�Chromez%actionz%sr0z--new-windowTN)rr	r
rYrVrWrXrOrrrrr^8s
r^c@s$eZdZddgZdZdZdZdZdS)�Operaz%actionz%sr0z--new-windowTN)rr	r
rYrVrWrXrOrrrrr_Ds
r_c@s(eZdZddgZdZdZdZdZdZdS)�Elinksz-remotezopenURL(%s%action)r0z,new-windowz,new-tabFN)	rr	r
rYrVrWrXrOrQrrrrr`Nsr`c@seZdZddd�ZdS)�	KonquerorrTcCs�|dkrd}nd}tj}ytjd||gd|||d�}Wntk
rJYnX|��dSy tjdd|gd|||dd	�}Wntk
r�YnX|��dkr�dSy tjd
d|gd|||dd	�}Wntk
r�dSX|��dkSdS)
Nr'ZnewTabZopenURL�	kfmclientT)r=rIrJrK�	konquerorz--silent)r=rIrJrKrF�kfmz-dF)r@rPrArCrBrG)r1r$r%r&rU�devnullrErrrrcs:zKonqueror.openN)rT)rr	r
rrrrrra\srac@s&eZdZdd�Zdd�Zd
dd�Zd	S)�GrailcCs�ddl}ddl}ddl}ddl}tj�|��d�}|�t�	��d}tj�||d�}|�|�}|shdS|�|j
|j�}	xX|D]P}
y|	�|
�Wn8t
k
r�yt�|
�Wnt
k
r�YnXYq~X|	Sq~WdS)Nrz.grail-unixz-*)�glob�pwd�socket�tempfiler*r+�joinZ
gettempdir�getpwuid�getuidZAF_UNIXZSOCK_STREAMZconnectrC�unlink)r1rgrhrirjZtempdir�user�filenameZmaybes�s�fnrrr�_find_grail_rc�s*

zGrail._find_grail_rccCs&|��}|sdS|�|�|��dS)Nrr)rs�send�close)r1rUrqrrr�_remote�s
z
Grail._remoterTcCs&|r|�d|�}n|�d|�}|S)NzLOADNEW zLOAD )rv)r1r$r%r&�okrrrr�sz
Grail.openN)rT)rr	r
rsrvrrrrrrf�srfcCs�t�d�rtddtd��dtjkr>t�d�r>tddtd��dtjkrbt�d�rbtddtd��dtjkr�t�d�r�tdttd��t�d�r�tddtd��x&dD]}t�|�r�t|dt|��q�Wx&d	D]}t�|�r�t|dt|��q�Wt�d
��rtd
ttd
��nt�d��r*tdttd��x*dD]"}t�|��r0t|dt	|���q0Wt�d
��rrtd
dtd
��x*dD]"}t�|��rxt|dt
|���qxWt�d��r�tddtd��t�d��r�tddtd��t�d��r�tdtd�dS)Nzxdg-openZGNOME_DESKTOP_SESSION_IDz	gvfs-openz
gnome-openZKDE_FULL_SESSIONrbz
x-www-browser)�firefoxZ	iceweaselZiceape�	seamonkey)zmozilla-firefoxzmozilla-firebird�firebird�mozilla�netscaperdrc)ZgaleonZepiphanyZ	skipstone)z
google-chrome�chromeZchromiumzchromium-browser�operaZmosaicZgrail)
r(r)rrr*�environrar[r\r]r^r_rf)r"rrr�register_X_browsers�sD







r�c	Cs2gatjdkrNtddtd��tddtd��tddtd��tddtd��tjdd�dkr�td	t�tj�tj	�
d
d�d�}x4dd
dddd|fD]}t�|�r�t|dt
|��q�W�ntj	�
d�s�tj	�
d��r&y(d��}tj|tjd�}|����}Wnttjfk
�rYnX|at�tj	�
d��r�t�d��rPtddtd��t�d��rltddtd��t�d��r�tddtd��t�d��r�tddtd��t�d��r�tddtd��dtj	k�r.tj	d�tj�}|��xF|D]>}|dk�r�t|dd�}|d dk�r�t|dt|�dd��q�WdS)!N�darwin�MacOSX�defaultr}rxZsafarir;r<zwindows-defaultZPROGRAMFILESzC:\Program FileszInternet Explorer\IEXPLORE.EXErzryr{r|r~ZDISPLAYZWAYLAND_DISPLAYz$xdg-settings get default-web-browser)rKZTERMzwww-browserZlinksZelinksZlynxZw3mZBROWSERr0T)r
r)rr>r?r�MacOSXOSAScript�WindowsDefaultr*r+rkrrr(r)rrr@Zcheck_outputrP�decode�strip�FileNotFoundErrorZCalledProcessErrorrr�rr`�pathsep�reverser!)Ziexplorer"r.Z
raw_result�resultZuserchoicesrDrrrrsT





rr;r<c@seZdZddd�ZdS)r�rTcCs,yt�|�Wntk
r"dSXdSdS)NFT)r*Z	startfilerC)r1r$r%r&rrrrSs
zWindowsDefault.openN)rT)rr	r
rrrrrr�Rsr�r�c@seZdZdd�Zddd�ZdS)	r�cCs
||_dS)N)r)r1rrrrr2mszMacOSX.__init__rTc	Cs�d|krd|}tt|��}|jdkr8d|�dd�}n<|jdkrHd}nd	|d
}d|�dd�}d|j||f}t�d
d�}|dkr�dS|�|�|��}|S)N�:zfile:r�zopen location "%s"�"z%22ZOmniWebr0ztoWindow %drzOpenURL "%s"z�tell application "%s"
                                activate
                                %s %s
                            end tell�	osascript�wF)rN�boolrr7r*�popen�writeru)	r1r$r%r&�scriptZtoWindowr.�osapiperSrrrrps 


zMacOSX.openN)rT)rr	r
r2rrrrrr�cs
r�c@seZdZdd�Zddd�ZdS)	r�cCs
||_dS)N)�_name)r1rrrrr2�szMacOSXOSAScript.__init__rTcCsb|jdkrd|�dd�}nd|j|�dd�f}t�dd�}|dkrJdS|�|�|��}|S)	Nr�zopen location "%s"r�z%22z�
                   tell application "%s"
                       activate
                       open location "%s"
                   end
                   r�r�F)r�r7r*r�r�ru)r1r$r%r&r�r�rSrrrr�s

zMacOSXOSAScript.openN)rT)rr	r
r2rrrrrr��sr�c	
Cs�ddl}dtjd}y|�tjdd�d�\}}WnJ|jk
r~}z*t|tjd�t|tjd�t�d�Wdd}~XYnXd}x*|D]"\}}|dkr�d}q�|dkr�d}q�Wt|�dkr�t|tjd�t�d�|d}t||�td	�dS)
NrzDUsage: %s [-n | -t] url
    -n: open new window
    -t: open new tabrZntd)�filez-nz-tr'�)	�getoptr>�argv�error�printrK�exit�lenr)	r��usageZoptsr4�msgZnew_win�o�ar$rrr�main�s(

r��__main__)N)N)rT)*r*rr(r>r@Z	threading�__all__�	Exceptionr�RLockrrrrrrrrrr!�objectr/rrrHr[r\r]r^ZChromiumr_r`rarfr�rr?r�r�r�r�rrrrr�<module>sP
"
"N

	
45AK.


?>