Hacked By AnonymousFox

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

B

� f�\�@s�dZddlZddlZddlZddlZddlZddlZddddddgZGd	d�de�Z	e�
�ZiZda
dad<d
d�dd�Zd=d
d�Zd>dd�Zdd�Zdd�Zd
d�dd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�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.d/�Z$ej%dd0�d1k�r�Gd2d3�d3e�Z&ej%d4k�r�Gd5d6�d6e�Z'Gd7d8�d8e�Z(d9d:�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/python37/lib64/python3.7/webbrowser.pyrsF)�	preferredc	CsZt�Ltdkrt�||gt|��<|s4trB|tkrBt�d|�n
t�|�WdQRXdS)zRegister a browser connector.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)zCReturn a browser launcher instance appropriate for the environment.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)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	
cCs
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rZscCs
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rascCs�|��d}t�|�sddgStj�|�}yt|��}Wntk
rRddgSX|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
controllerr-rrrr!is"


r!c@s:eZdZdZdgZddd�Zddd	�Zd
d�Zdd
�ZdS)�BaseBrowserz3Parent class for all browsers. Do not use directly.z%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
�__doc__�argsr2rrrrrrrr/�s

r/c@s"eZdZdZdd�Zd	dd�ZdS)
rzVClass for all browsers started with a command
       and without remote functionality.cCsFt|t�r||_dg|_n|d|_|dd�|_tj�|j�|_dS)Nz%srr)�
isinstance�strrr5r*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)rr5�sys�platform�
subprocess�Popen�wait�OSError)r1r$r%r&�cmdline�pr)r$rr�s
zGenericBrowser.openN)rT)rr	r
r4r2rrrrrr�s
rc@seZdZdZddd�ZdS)rzHClass for all browsers which are to be started in the
       background.rTcsp|jg�fdd�|jD�}y:tjdd�dkr<t�|�}ntj|ddd�}|��dkStk
rjdSXdS)Ncsg|]}|�d���qS)z%s)r8)r9r:)r$rrr;�sz*BackgroundBrowser.open.<locals>.<listcomp>r<r=T)r>�start_new_sessionF)rr5r?r@rArB�pollrD)r1r$r%r&rErFr)r$rr�szBackgroundBrowser.openN)rT)rr	r
r4rrrrrr�src@sBeZdZdZdZdZdZddgZdZdZ	dZ
dd�Zdd
d�ZdS)
�UnixBrowserz=Parent class for all Unix browsers with remote functionality.NFTz%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�stderrrG�F)�
raise_opts�intr�
backgroundrA�DEVNULLrB�redirect_stdoutrCZTimeoutExpiredrH)
r1r5Zremoter&Z	raise_optZoptrEZinoutrF�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)r8)r9r:)�actionr$rrr;
sz$UnixBrowser.open.<locals>.<listcomp>cSsg|]}|r|�qSrr)r9r:rrrr;sTcsg|]}|�d���qS)z%s)r8)r9r:)r$rrr;sF)�
remote_action�remote_action_newwin�remote_action_newtabr�remote_argsrTr5)r1r$r%r&r5Zsuccessr)rUr$rr�s$

zUnixBrowser.open)rT)
rr	r
r4rNrPrRrYrVrWrXrTrrrrrrI�s#rIc@s(eZdZdZddgZdZdZdZdZdS)	�Mozillaz$Launcher class for Mozilla browsers.z%actionz%sr0z-new-windowz-new-tabTN)	rr	r
r4rYrVrWrXrPrrrrrZsrZc@s0eZdZdZddgZddgZdZdZdZd	Z	d
S)�Netscapez$Launcher class for Netscape browser.z-noraisez-raisez-remotezopenURL(%s%action)r0z,new-windowz,new-tabTN)
rr	r
r4rNrYrVrWrXrPrrrrr[#sr[c@s,eZdZdZddgZddgZdZdZdZd	S)
�Galeonz,Launcher class for Galeon/Epiphany browsers.z-noraiser0z%actionz%sz-nz-wTN)	rr	r
r4rNrYrVrWrPrrrrr\.sr\c@s(eZdZdZddgZdZdZdZdZdS)�Chromez)Launcher class for Google Chrome browser.z%actionz%sr0z--new-windowTN)	rr	r
r4rYrVrWrXrPrrrrr]8sr]c@s(eZdZdZddgZdZdZdZdZdS)�Operaz!Launcher class for Opera browser.z%actionz%sr0z--new-windowTN)	rr	r
r4rYrVrWrXrPrrrrr^Dsr^c@s,eZdZdZddgZdZdZdZdZdZ	dS)	�Elinksz#Launcher class for Elinks browsers.z-remotezopenURL(%s%action)r0z,new-windowz,new-tabFN)
rr	r
r4rYrVrWrXrPrRrrrrr_Nsr_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�|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>rJrKrL�	konquerorz--silent)r>rJrKrLrG�kfmz-dF)rArQrBrDrCrH)r1r$r%r&rU�devnullrFrrrrcs:zKonqueror.openN)rT)rr	r
r4rrrrrr`\sr`c@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_STREAMZconnectrD�unlink)r1rfrgrhriZtempdir�user�filenameZmaybes�s�fnrrr�_find_grail_rc�s*

zGrail._find_grail_rccCs&|��}|sdS|�|�|��dS)Nrr)rr�send�close)r1rUrprrr�_remote�s
z
Grail._remoterTcCs&|r|�d|�}n|�d|�}|S)NzLOADNEW zLOAD )ru)r1r$r%r&�okrrrr�sz
Grail.openN)rT)rr	r
rrrurrrrrre�srecCs�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_SESSIONraz
x-www-browser)�firefoxZ	iceweaselZiceape�	seamonkey)zmozilla-firefoxzmozilla-firebird�firebird�mozilla�netscapercrb)ZgaleonZepiphanyZ	skipstone)z
google-chrome�chromeZchromiumzchromium-browser�operaZmosaicZgrail)
r(r)rrr*�environr`rZr[r\r]r^re)r"rrr�register_X_browsers�sD







rc	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|rwZsafarir<r=zwindows-defaultZPROGRAMFILESzC:\Program FileszInternet Explorer\IEXPLORE.EXEryrxrzr{r}ZDISPLAYZWAYLAND_DISPLAYz$xdg-settings get default-web-browser)rLZTERMzwww-browserZlinksZelinksZlynxZw3mZBROWSERr0T)r
r)rr?r@r�MacOSXOSAScript�WindowsDefaultr*r+rjr~rr(r)rrrAZcheck_outputrQ�decode�strip�FileNotFoundErrorZCalledProcessErrorrrrr_�pathsep�reverser!)Ziexplorer"r.Z
raw_result�resultZuserchoicesrErrrrsT





rr<r=c@seZdZddd�ZdS)r�rTcCs,yt�|�Wntk
r"dSXdSdS)NFT)r*Z	startfilerD)r1r$r%r&rrrrSs
zWindowsDefault.openN)rT)rr	r
rrrrrr�Rsr�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
||_dS)N)r)r1rrrrr2mszMacOSX.__init__rTc	Cs�d|kst�d|krd|}tt|��}|jdkrDd|�dd�}n<|jdkrTd	}nd
|d}d|�dd�}d
|j||f}t�dd�}|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)	�AssertionErrorrO�boolrr8r*�popen�writert)	r1r$r%r&�scriptZtoWindowr.�osapiperSrrrrps"


zMacOSX.openN)rT)rr	r
r4r2rrrrr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�r8r*r�r�rt)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�printrL�exit�lenr)	r�ZusageZoptsr5�msgZnew_win�o�ar$rrr�main�s(

r��__main__)N)N)rT)+r4r*rr(r?rAZ	threading�__all__�	Exceptionr�RLockrrrrrrrrrr!�objectr/rrrIrZr[r\r]ZChromiumr^r_r`rerrr@r�r�r�r�rrrrr�<module>sR
"
"N

	
45AK.


Hacked By AnonymousFox1.0, Coded By AnonymousFox