ok

Mini Shell

Direktori : /proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/
Upload File :
Current File : //proc/thread-self/root/opt/alt/python34/lib64/python3.4/__pycache__/webbrowser.cpython-34.pyo

�
i f�S�@s�dZddlZddlZddlZddlZddlZddddddgZGd	d�de�ZiZ	gZ
dd
dd�Zddd�Zdd
dd�Z
dd�Zdd�Zd
dd�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZeZGdd�de�ZGdd �d e�ZeZGd!d"�d"e�ZGd#d$�d$e�ZGd%d&�d&e�ZGd'd(�d(e�Zd)d*�Zej jd+�r�e�nej jd,�r�ej!d-�r6ed-ded-��nej!d.�r^ed.ded.��nej!d/�r�ed/ded/��nej!d0�r�ed0ded0��nej!d1�r�ed1ded1��q�nej"dd2�d3kr�Gd4d5�d5e�Z#gZ
iZ	ed6e#�ej$j%ej jd7d8�d9�Z&xNd:d;d<d=d>d?e&fD].Z'ej!e'�raee'dee'��qaqaWnej"d@krGdAdB�dBe�Z(GdCdD�dDe�Z)edEde)dE�dL�ed:de)d:�dM�edBde)dF�dN�ndGej kr�ej dGj*ej+�Z,e,j-�xXe,D]PZ.e.dHkrXee.dO�Z/e/d
dkr�ee.dee.�dP�q�qXqXWdZ.[.[,ndIdJ�Z0e1dKkr�e0�ndS)Qz?Interfaces for launching and remotely controlling Web browsers.�N�Error�open�open_new�open_new_tab�get�registerc@seZdZdS)rN)�__name__�
__module__�__qualname__�rr�//opt/alt/python34/lib64/python3.4/webbrowser.pyr
s�cCsU||gt|j�<|dkr2tj|�n|dkrQtjd|�ndS)z9Register a browser connector and, optionally, connection.rN)�	_browsers�lower�	_tryorder�append�insert)�name�klass�instance�update_tryorderrrrrs
cCs�|dk	r|g}nt}x�|D]�}d|krwtj|�}|ddkrjt|dd��St|�Sq%yt|j�}Wntk
r�t|�}YnX|ddk	r�|dS|ddk	r%|d�Sq%Wt	d��dS)	zCReturn a browser launcher instance appropriate for the environment.Nz%sr
�&rz!could not locate runnable browser���r)
r�shlex�split�BackgroundBrowser�GenericBrowserrr�KeyError�_synthesizer)ZusingZalternatives�browser�commandrrrrs$


TcCs:x3tD]+}t|�}|j|||�rdSqWdS)NTF)rrr)�url�new�	autoraiserrrrrr9s

cCs
t|d�S)Nr
)r)r!rrrr@scCs
t|d�S)N�)r)r!rrrrCsc
Cs�|j�d}tj|�s)ddgStjj|�}yt|j�}Wntk
rmddgSYnX|d}|r�|j�|jkr�ddl	}|j	|�}||_
tjj|�|_t|d||�d|gSddgS)a�Attempt to synthesize a controller base 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
)r�shutil�which�os�path�basenamerrr�copyrr)rr�cmdrr Z
controllerr*rrrrGs"


	
rc@sXeZdZdZdgZddd�Zdddd	�Zd
d�Zdd
�ZdS)�BaseBrowserz3Parent class for all browsers. Do not use directly.z%s�cCs||_||_dS)N)rr))�selfrrrr�__init__ns	zBaseBrowser.__init__rTcCs
t�dS)N)�NotImplementedError)r.r!r"r#rrrrrszBaseBrowser.opencCs|j|d�S)Nr
)r)r.r!rrrruszBaseBrowser.open_newcCs|j|d�S)Nr$)r)r.r!rrrrxszBaseBrowser.open_new_tabN)	rr	r
�__doc__�argsr/rrrrrrrr,is	r,c@s4eZdZdZdd�Zdddd�ZdS)	rzVClass for all browsers started with a command
       and without remote functionality.cCsct|t�r'||_dg|_n |d|_|dd�|_tjj|j�|_dS)Nz%srr
)�
isinstance�strrr2r'r(r))r.rrrrr/�s	
zGenericBrowser.__init__rTcs�|jg�fdd�|jD�}yOtjdd�dkrTtj|�}ntj|dd�}|j�SWntk
r�dSYnXdS)Ncs"g|]}|jd���qS)z%s)�replace)�.0�arg)r!rr�
<listcomp>�s	z'GenericBrowser.open.<locals>.<listcomp>��win�	close_fdsTF)rr2�sys�platform�
subprocess�Popen�wait�OSError)r.r!r"r#�cmdline�pr)r!rr�s
zGenericBrowser.openN)rr	r
r1r/rrrrrr|s
rc@s(eZdZdZdddd�ZdS)rzHClass for all browsers which are to be started in the
       background.rTcs�|jg�fdd�|jD�}yZtjdd�dkrTtj|�}ntj|dddd�}|j�dkSWntk
r�dSYnXdS)	Ncs"g|]}|jd���qS)z%s)r5)r6r7)r!rrr8�s	z*BackgroundBrowser.open.<locals>.<listcomp>r9r:r;T�start_new_sessionF)rr2r<r=r>r?�pollrA)r.r!r"r#rBrCr)r!rr�s	
zBackgroundBrowser.openN)rr	r
r1rrrrrr�src@sdeZdZdZdZdZdZddgZdZdZ	dZ
dd�Zd	dd
d�ZdS)�UnixBrowserz=Parent class for all Unix browsers with remote functionality.NFTz%actionz%sc
Cs&g}|rC|jrCt|�}|j|}|rC|g}qCn|jg||}|sf|jrrtj}nd}tj|ddd|d|jr�|p�dd|dd�}|r�y|jd�}	|	SWq"tj	k
r�dSYq"Xn1|jr|j
�dkrdSdSn|j�SdS)	Nr;T�stdin�stdout�stderrrD�F)�
raise_opts�intr�
backgroundr>�DEVNULLr?�redirect_stdoutr@ZTimeoutExpiredrE)
r.r2Zremoter#Z	raise_optZoptrBZinoutrC�rcrrr�_invoke�s0
		zUnixBrowser._invokercs�|dkr|j�n_|dkr0|j�nG|dkrc|jdkrW|j�qw|j�ntdd|����fdd�|jD�}dd�|D�}|j|d	|�}|s��fd
d�|jD�}|j|dd�Sd	SdS)Nrr
r$zBad 'new' parameter to open(); zexpected 0, 1, or 2, got %scs.g|]$}|jd��jd���qS)z%sz%action)r5)r6r7)�actionr!rrr8�s	z$UnixBrowser.open.<locals>.<listcomp>cSsg|]}|r|�qSrr)r6r7rrrr8�s	Tcs"g|]}|jd���qS)z%s)r5)r6r7)r!rrr8�s	F)�
remote_action�remote_action_newwin�remote_action_newtabr�remote_argsrQr2)r.r!r"r#r2�successr)rRr!rr�s$
zUnixBrowser.open)
rr	r
r1rKrMrOrVrSrTrUrQrrrrrrF�s#rFc@sFeZdZdZddgZddgZdZdZdZd	Z	d
S)�Mozillaz-Launcher class for Mozilla/Netscape browsers.z-noraisez-raisez-remotezopenURL(%s%action)r-z,new-windowz,new-tabTN)
rr	r
r1rKrVrSrTrUrMrrrrrX�srXc@s@eZdZdZddgZddgZdZdZdZd	S)
�Galeonz,Launcher class for Galeon/Epiphany browsers.z-noraiser-z%actionz%sz-nz-wTN)	rr	r
r1rKrVrSrTrMrrrrrYsrYc@s:eZdZdZddgZdZdZdZdZdS)�Chromez)Launcher class for Google Chrome browser.z%actionz%sr-z--new-windowTN)	rr	r
r1rVrSrTrUrMrrrrrZsrZc@sFeZdZdZddgZddgZdZdZdZdZ	d	S)
�Operaz!Launcher class for Opera browser.z-noraiser-z-remotezopenURL(%s%action)z,new-windowz	,new-pageTN)
rr	r
r1rKrVrSrTrUrMrrrrr[sr[c@s@eZdZdZddgZdZdZdZdZdZ	dS)	�Elinksz#Launcher class for Elinks browsers.z-remotezopenURL(%s%action)r-z,new-windowz,new-tabFN)
rr	r
r1rVrSrTrUrMrOrrrrr\%sr\c@s(eZdZdZdddd�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.
    rTc"CsG|dkrd}nd}tj}y4tjd||gddd|d|d	|�}Wntk
rlYnX|j�dSy:tjd
d|gddd|d|d	|dd�}Wntk
r�YnX|j�dkr�dSy:tjd
d|gddd|d|d	|dd�}Wntk
r2dSYnX|j�dkSdS)Nr$ZnewTabZopenURL�	kfmclientr;TrGrHrI�	konquerorz--silentrD�kfmz-dF)r>rNr?rAr@rE)r.r!r"r#rR�devnullrCrrrr:s:		





	zKonqueror.openN)rr	r
r1rrrrrr]3sr]c@s:eZdZdd�Zdd�Zdddd�Zd	S)
�GrailcCsddl}ddl}ddl}ddl}tjj|j�d�}|jtj	��d}tjj||d�}|j|�}|s�dS|j|j
|j�}	x^|D]V}
y|	j|
�Wn8t
k
rytj|
�Wnt
k
rYnXYq�X|	Sq�WdS)Nrz.grail-unixz-*)�glob�pwd�socket�tempfiler'r(�joinZ
gettempdir�getpwuid�getuidZAF_UNIXZSOCK_STREAMZconnectrA�unlink)r.rcrdrerfZtempdir�user�filenameZmaybes�s�fnrrr�_find_grail_rcks*	



zGrail._find_grail_rccCs1|j�}|sdS|j|�|j�dS)Nrr
)ro�send�close)r.rRrmrrr�_remote�s

z
Grail._remoterTcCs3|r|jd|�}n|jd|�}|S)NzLOADNEW zLOAD )rr)r.r!r"r#�okrrrr�sz
Grail.openN)rr	r
rorrrrrrrrbgsrbc	Cs�tjd�r(tddtd��ndtjkr_tjd�r_tddtd��ndtjkr�tjd�r�tddtd��ndtjkr�tjd�r�tdttd��ntjd�r�tddtd��nx6dD].}tj|�r�t|dt|��q�q�Wtjd�rVtdttd��n(tjd�r~tdttd��nx6dD].}tj|�r�t|dt|��q�q�Wtjd�r�tddtd��nx6dD].}tj|�r�t|dt	|��q�q�Wtjd�r@tddt
d��ntjd�rhtddtd��ntjd�r�tdtd�ndS) Nzxdg-openZGNOME_DESKTOP_SESSION_IDz	gvfs-openz
gnome-openZKDE_FULL_SESSIONr^z
x-www-browser�mozilla-firefox�firefox�mozilla-firebird�firebird�	iceweasel�iceape�	seamonkey�mozilla�netscaper`r_�galeon�epiphanyZ	skipstone�
google-chrome�chrome�chromium�chromium-browser�operaZmosaicZgrail)	rtrurvrwrxryrzr{r|)r}r~)rr�r�r�)r%r&rrr'�environr]rXrYrZr[rb)rrrr�register_X_browsers�sD


r�ZDISPLAYZTERMzwww-browserZlinksZelinksZlynxZw3mr9r:c@s"eZdZdddd�ZdS)�WindowsDefaultrTcCs2ytj|�Wntk
r)dSYnXdSdS)NFT)r'Z	startfilerA)r.r!r"r#rrrr�s

	zWindowsDefault.openN)rr	r
rrrrrr��sr�zwindows-defaultZPROGRAMFILESzC:\Program FileszInternet Explorer\IEXPLORE.EXErurwrzr{r|r��darwinc@s4eZdZdZdd�Zdddd�ZdS)	�MacOSXa{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)r.rrrrr/szMacOSX.__init__rTc	Cs�d|krd|}ntt|��}|jdkrSd|jdd�}nR|jdkrkd}nd	|d
}d|jdd�}d|j||f}tjd
d�}|dkr�dS|j|�|j�}|S)N�:zfile:�defaultzopen location "%s"�"z%22ZOmniWebr-ztoWindow %dr
zOpenURL "%s"z�tell application "%s"
                                activate
                                %s %s
                            end tell�	osascript�wF)rL�boolrr5r'�popen�writerq)	r.r!r"r#�scriptZtoWindowr+�osapiperPrrrrs 
	
zMacOSX.openN)rr	r
r1r/rrrrrr�s	r�c@s.eZdZdd�Zdddd�ZdS)�MacOSXOSAScriptcCs
||_dS)N)�_name)r.rrrrr/@szMacOSXOSAScript.__init__rTcCs�|jdkr(d|jdd�}nd|j|jdd�f}tjdd�}|dkridS|j|�|j�}|S)	Nr�zopen location "%s"r�z%22z�
                   tell application "%s"
                       activate
                       open location "%s"
                   end
                   r�r�F)r�r5r'r�r�rq)r.r!r"r#r�r�rPrrrrCs
zMacOSXOSAScript.openN)rr	r
r/rrrrrr�?sr�Zsafarir�ZBROWSERr-c	CsEddl}dtjd}y)|jtjdd�d�\}}Wn[|jk
r�}z8t|dtj�t|dtj�tjd�WYdd}~XnXd}x>|D]6\}}|dkr�d}q�|dkr�d}q�q�Wt|�dkr t|dtj�tjd�n|d}t||�td	�dS)
NrzDUsage: %s [-n | -t] url
    -n: open new window
    -t: open new tabr
Zntd�filez-nz-tr$�)	�getoptr<�argv�error�printrI�exit�lenr)	r�ZusageZoptsr2�msgZnew_win�o�ar!rrr�mainrs() 	


r��__main__rrrrr)2r1r'rr%r<r>�__all__�	Exceptionrrrrrrrrr�objectr,rrrFrXZNetscaperYrZZChromiumr[r\r]rbr�r�r&r=r�r(rgZiexplorerr�r�r�pathsepZ_userchoices�reverserBr+r�rrrrr�<module>s�"N

	45>

	 .

#

Zerion Mini Shell 1.0