�`^c@s>dZddlZddlZddlZddlZddlZddlZddddddgZdefd ��YZ iZ
gZdd
d�Z
dd�Zd
ed�Zd�Zd�Zd
d�Zejd dkr��Zn d�Zd�Zdefd��YZdefd��YZdefd��YZdefd��YZdefd ��YZeZd!efd"��YZd#efd$��YZeZ d%efd&��YZ!d'efd(��YZ"d)efd*��YZ#d+efd,��YZ$d-�Z%ej&jd.�r$e%�nej&jd/�r�d0�r[e
d0ded0��ned1�r�e
d1ded1��ned2�r�e
d2de"d2��ned3�r�e
d3ded3��ned4�r�d4ded4��q�ejd dkr�d5efd6��YZ'gZiZ
e
d7e'�ej(j)ej&jd8d9�d:�Z*xKd;d<d=d>d?d@e*fD]+Z+ee+�rte
e+dee+��qtqtWnejdAkr/dBefdC��YZ,dDefdE��YZ-e
dFde-dF�d�e
d;de-d;�d�e
dBde-dG�d�nejd dHkred?�rgZiZ
e
dIdedJd?dKg�d�ndLej&krej&dLj.ej/�Z0e0j1�xXe0D]PZ2e2dMkr�ee2d�Z3e3d
dkre
e2dee2�d�qq�q�WdZ2[2[0ndN�Z4e5dOkr:e4�ndS(Ps?Interfaces for launching and remotely controlling Web browsers.i�NtErrortopentopen_newtopen_new_tabtgettregistercBseZRS((t__name__t
__module__(((s /sys/lib/python2.7/webbrowser.pyRsicCsU||gt|j�<|dkr2tj|�n|dkrQtjd|�ndS(s9Register a browser connector and, optionally, connection.iN(t _browserstlowert _tryordertappendtinsert(tnametklasstinstancetupdate_tryorder((s /sys/lib/python2.7/webbrowser.pyRs
cCs�|dk r|g}nt}x�|D]�}d|krqtj|�}|ddkrdt|d �St|�Sq%yt|j�}Wntk
r�t |�}nX|ddk r�|dS|ddk r%|d�Sq%Wt
d��dS(sCReturn a browser launcher instance appropriate for the environment.s%si�t&iis!could not locate runnable browserN(tNoneR
tshlextsplittBackgroundBrowsertGenericBrowserRR tKeyErrort_synthesizeR(tusingtalternativestbrowsertcommand((s /sys/lib/python2.7/webbrowser.pyRs$
icCs:x3tD]+}t|�}|j|||�rtSqWtS(N(R
RRtTruetFalse(turltnewt autoraiseR
R((s /sys/lib/python2.7/webbrowser.pyR:s
cCs
t|d�S(Ni(R(R((s /sys/lib/python2.7/webbrowser.pyRAscCs
t|d�S(Ni(R(R((s /sys/lib/python2.7/webbrowser.pyRDscCs�|j�d}t|�s&ddgStjj|�}yt|j�}Wntk
rfddgSX|d}|r�j�|jkr�dl }|j |�}||_
tjj|�|_t|d||�d|gSddgS(s�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].
iii�N(Rt
_iscommandRtostpathtbasenameRR RtcopyR
R(RRtcmdR
Rt
controllerR&((s /sys/lib/python2.7/webbrowser.pyRHs"
itwincCs`|j�}tjj|�r1|jd�r1tSx(dD] }tjj||�r8tSq8WtS(Ns.exes.bat(s.exes.bat(s.exes.bat(R R#R$tisfiletendswithRR(R'text((s /sys/lib/python2.7/webbrowser.pyt
_isexecutableis!
cCsZtjj|�rVtj|�tj}|tj@sO|tj@sO|tj@rVtSnt S(N(
R#R$R*tstattST_MODEtS_IXUSRtS_IXGRPtS_IXOTHRR(R'tmode((s /sys/lib/python2.7/webbrowser.pyR-rs
'cCsrt|�rtStjjd�}|s,tSx?|jtj�D]+}tjj ||�}t|�r?tSq?WtS(sSReturn True if cmd is executable or can be found on the executable
search path.tPATH(
R-RR#tenvironRRRtpathsepR$tjoin(R'R$tdtexe((s /sys/lib/python2.7/webbrowser.pyR"ystBaseBrowsercBsDeZdZdgZdd�Zded�Zd�Zd�ZRS(s3Parent class for all browsers. Do not use directly.s%stcCs||_||_dS(N(R
R%(tselfR
((s /sys/lib/python2.7/webbrowser.pyt__init__�s icCs
t�dS(N(tNotImplementedError(R<RR R!((s /sys/lib/python2.7/webbrowser.pyR�scCs|j|d�S(Ni(R(R<R((s /sys/lib/python2.7/webbrowser.pyR�scCs|j|d�S(Ni(R(R<R((s /sys/lib/python2.7/webbrowser.pyR�s( RRt__doc__targsR=RRRR(((s /sys/lib/python2.7/webbrowser.pyR:�s RcBs&eZdZd�Zded�ZRS(sVClass for all browsers started with a command
and without remote functionality.cCs]t|t�r'||_dg|_n|d|_|d|_tjj|j�|_dS(Ns%sii(t
isinstancet
basestringR
R@R#R$R%(R<R
((s /sys/lib/python2.7/webbrowser.pyR=�s
icCs�|jgg|jD]}|jd|�^q}yItjd dkrZtj|�}ntj|dt�}|j�SWnt k
r�t
SXdS(Ns%siR)t close_fds(R
R@treplacetsystplatformt
subprocesstPopenRtwaittOSErrorR(R<RR R!targtcmdlinetp((s /sys/lib/python2.7/webbrowser.pyR�s&
(RRR?R=RR(((s /sys/lib/python2.7/webbrowser.pyR�s
RcBseZdZded�ZRS(sHClass for all browsers which are to be started in the
background.icCs�|jgg|jD]}|jd|�^q}y�tjd dkrZtj|�}nHttdd�}|s�ttdd�}ntj|dt
d|�}|j�dkSWntk
r�t
SXdS(Ns%siR)tsetsidtsetpgrpRCt
preexec_fn(R
R@RDRERFRGRHtgetattrR#RRtpollRJR(R<RR R!RKRLRMRN((s /sys/lib/python2.7/webbrowser.pyR�s&
(RRR?RR(((s /sys/lib/python2.7/webbrowser.pyR�stUnixBrowsercBsVeZdZdZddgZdZdZdZe Z
eZd�Z
ded�ZRS(s=Parent class for all Unix browsers with remote functionality.s%actions%scCs{g}|rC|jrCt|�}|j|}|rC|g}qCn|jg||}|sf|jr{ttjd�}nd}ttdd�}|s�ttdd�}nt j
|dtd|d|jr�|p�dd|d|�} |rFt
jd �| j�}
|
dkrAt
jd
�| j�}
|
dkrAtSn|
S|jrl| j�dkretStSn| j�SdS(Nsr+RNRORCtstdintstdouttstderrRPii(t
raise_optstintR
t
backgroundtfileR#tdevnullRRQRGRHRtredirect_stdoutttimetsleepRRRRI(R<R@tremoteR!t raise_opttoptRLtinoutRNRMtrc((s /sys/lib/python2.7/webbrowser.pyt_invoke�s<
icCs |dkr|j}n_|dkr0|j}nG|dkrc|jdkrW|j}qw|j}ntdd|��g|jD]$}|jd|�jd|�^q�}|j|t|�}|sg|j D]}|jd|�^q�}|j|t
t
�StSdS(NiiisBad 'new' parameter to open(); sexpected 0, 1, or 2, got %ss%ss%action(t
remote_actiontremote_action_newwintremote_action_newtabRRtremote_argsRDRdRR@R(R<RR R!tactionRKR@tsuccess((s /sys/lib/python2.7/webbrowser.pyRs"1(N(RRR?RRWRhReRfRgRRYRR\RdR(((s /sys/lib/python2.7/webbrowser.pyRS�s ,tMozillacBs>eZdZddgZddgZdZdZdZeZ RS(s-Launcher class for Mozilla/Netscape browsers.s-noraises-raises-remotesopenURL(%s%action)R;s,new-windows,new-tab(
RRR?RWRhReRfRgRRY(((s /sys/lib/python2.7/webbrowser.pyRkstGaleoncBs8eZdZddgZddgZdZdZeZRS(s,Launcher class for Galeon/Epiphany browsers.s-noraiseR;s%actions%ss-ns-w( RRR?RWRhReRfRRY(((s /sys/lib/python2.7/webbrowser.pyRl)stChromecBs2eZdZddgZdZdZdZeZRS(s)Launcher class for Google Chrome browser.s%actions%sR;s--new-window( RRR?RhReRfRgRRY(((s /sys/lib/python2.7/webbrowser.pyRm3stOperacBs>eZdZddgZddgZdZdZdZeZ RS(s!Launcher class for Opera browser.s-noraiseR;s-remotesopenURL(%s%action)s,new-windows ,new-page(
RRR?RWRhReRfRgRRY(((s /sys/lib/python2.7/webbrowser.pyRn?stElinkscBs8eZdZddgZdZdZdZeZeZ RS(s#Launcher class for Elinks browsers.s-remotesopenURL(%s%action)R;s,new-windows,new-tab(
RRR?RhReRfRgRRYR\(((s /sys/lib/python2.7/webbrowser.pyRoJst KonquerorcBseZdZded�ZRS(s�Controller for the KDE File Manager (kfm, or Konqueror).
See the output of ``kfmclient --commands``
for more information on the Konqueror remote-control interface.
icCsw|dkrd}nd}ttjd�}ttdd�}|sZttdd�}ny4tjd||gdtd |d
|d|�}Wntk
r�nX|j �tSy:tjdd
|gdtd |d
|d|d|�}Wntk
r�nX|j
�dkrtSy:tjdd|gdtd |d
|d|d|�}Wntk
rbtSX|j
�dkSdS(NitnewTabtopenURLsr+RNROt kfmclientRCRTRURVt konquerors--silentRPtkfms-d(RZR#R[RQRRGRHRRJRIRRR(R<RR R!RiR[RNRM((s /sys/lib/python2.7/webbrowser.pyR_s@
(RRR?RR(((s /sys/lib/python2.7/webbrowser.pyRpXstGrailcBs)eZd�Zd�Zded�ZRS(cCsddl}ddl}ddl}ddl}tjj|j�d�}|jtj ��d}tjj||d�}|j|�}|s�dS|j|j|j�} x_|D]W}
y| j
|
�Wn9|jk
rytj|
�Wqtk
rqXq�X| Sq�WdS(Ni�s.grail-unixis-*(tglobtpwdtsocketttempfileR#R$R7t
gettempdirtgetpwuidtgetuidRtAF_UNIXtSOCK_STREAMtconnectterrortunlinktIOError(R<RwRxRyRzttempdirtusertfilenametmaybeststfn((s /sys/lib/python2.7/webbrowser.pyt_find_grail_rc�s*
cCs1|j�}|sdS|j|�|j�dS(Nii(R�tsendtclose(R<RiR�((s /sys/lib/python2.7/webbrowser.pyt_remote�s
icCs3|r|jd|�}n|jd|�}|S(NsLOADNEW sLOAD (R�(R<RR R!tok((s /sys/lib/python2.7/webbrowser.pyR�s(RRR�R�RR(((s /sys/lib/python2.7/webbrowser.pyRv�s c Csdtd�r%tddtd��ndtjkrYtd�rYtddtd��ndtjkr�td�r�tddtd��ndtjkr�td�r�tdttd��ntd�r�ddtd��nx3dD]+}t|�r�|dt|��q��td�rAtdttd��n%td�rftdttd��nx3dD]+}t|�rmt|dt|��qmqmWtd�r�tddtd��nx3dD]+}t|�r�t|dt |��q�q�Wtd�rtddt
d��ntd�rAtddtd��ntd�r`tdtd�ndS( Nsxdg-opentGNOME_DESKTOP_SESSION_IDs gvfs-opens
gnome-opentKDE_FULL_SESSIONRss
x-www-browsersmozilla-firefoxtfirefoxsmozilla-firebirdtfirebirdt iceweaselticeapet seamonkeytmozillatnetscapeRuRttgaleontepiphanyt skipstones
google-chrometchrometchromiumschromium-browsertoperatmosaictgrail( smozilla-firefoxR�smozilla-firebirdR�R�R�R�R�R�(R�R�(s
google-chromeR�R�schromium-browser(R"RRRR#R5RpRkRlRmRnRv(R((s /sys/lib/python2.7/webbrowser.pytregister_X_browsers�sD
tDISPLAYtTERMswww-browsertlinkstelinkstlynxtw3mtWindowsDefaultcBseZded�ZRS(icCs.ytj|�Wntk
r%tSXtSdS(N(R#t startfiletWindowsErrorRR(R<RR R!((s /sys/lib/python2.7/webbrowser.pyRs
(RRRR(((s /sys/lib/python2.7/webbrowser.pyR�sswindows-defaulttPROGRAMFILESsC:\Program FilessInternet Explorer\IEXPLORE.EXER�R�R�R�R�R�tdarwintMacOSXcBs&eZdZd�Zded�ZRS(s{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<R
((s /sys/lib/python2.7/webbrowser.pyR=Esic Cs�d|krd|}ntt|��}|jdkrSd|jdd�}nR|jdkrkd}nd |d
}d|jdd�}d|j||f}tjd
d�}|dkr�tS|j|�|j �}|S(Nt:sfile:tdefaultsopen location "%s"t"s%22tOmniWebR;stoWindow %disOpenURL "%s"s�tell application "%s"
activate
%s %s
end tellt osascripttw(
RXtboolR
RDR#tpopenRRtwriteR�( R<RR R!tscriptttoWindowR'tosapipeRc((s /sys/lib/python2.7/webbrowser.pyRHs
(RRR?R=RR(((s /sys/lib/python2.7/webbrowser.pyR�;s tMacOSXOSAScriptcBs eZd�Zded�ZRS(cCs
||_dS(N(t_name(R<R
((s /sys/lib/python2.7/webbrowser.pyR=jsicCs�|jdkr(d|jdd�}nd|j|jdd�f}tjdd�}|dkritS|j|�|j�}|S(NR�sopen location "%s"R�s%22s�
tell application "%s"
activate
open location "%s"
end
R�R�(R�RDR#R�RRR�R�(R<RR R!R�R�Rc((s /sys/lib/python2.7/webbrowser.pyRms
(RRR=RR(((s /sys/lib/python2.7/webbrowser.pyR�is tsafariR�tos2tos2netscapetstarts%stBROWSERR;c Csddl}dtjd}y#|jtjdd�\}}Wn=|jk
r}tj|IJtj|IJtjd�nXd}x>|D]6\}}|dkr�d}q�|dkr�d}q�q�Wt|�dkr�j|IJtjd�n|d}t||�d GHdS(
Ni�sDUsage: %s [-n | -t] url
-n: open new window
-t: open new tabiitntds-ns-tis(tgetoptREtargvR�RVtexittlenR( R�tusagetoptsR@tmsgtnew_wintotaR((s /sys/lib/python2.7/webbrowser.pytmain�s(#
t__main__(6R?R#RRER.RGR]t__all__t ExceptionRRR
RRRRRRRRRFR-R"tobjectR:RRRSRktNetscapeRlRmtChromiumRnRoRpRvR�R5R�R$R7tiexploreRR�R�RR6t_userchoicestreverseRLR'R�R(((s /sys/lib/python2.7/webbrowser.pyt<module>s� P
95 >
.
#
|