nfc@s>dZddlZddlZddlZddlZddlZddlZddddddgZdefd YZ iZ gZ dd d Z dd Zd edZdZdZd dZejd dkrdZn dZdZdefdYZdefdYZdefdYZdefdYZdefd 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/red0r[e d0ded0ned1re d1ded1ned2re d2de"d2ned3re d3ded3ned4re d4ded4qnejd dkrd5efd6YZ'gZ iZ e d7e'ej(j)ej&jd8d9d:Z*xKd;d<d=d>d?d@e*fD]+Z+ee+rte e+dee+qtqtWnejdAkr/dBefdCYZ,dDefdEYZ-e dFde-dFde d;de-d;de dBde-dGdnejd dHkred?rgZ iZ e dIdedJd?dKgdndLej&krej&dLj.ej/Z0e0j1xXe0D]PZ2e2dMkree2dZ3e3d dkre e2dee2dqqqWdZ2[2[0ndNZ4e5dOkr:e4ndS(Ps?Interfaces for launching and remotely controlling Web browsers.iNtErrortopentopen_newt open_new_tabtgettregistercBseZRS((t__name__t __module__(((s"/usr/lib64/python2.7/webbrowser.pyRsicCsU||gt|j<|dkr2tj|n|dkrQtjd|ndS(s9Register a browser connector and, optionally, connection.iN(t _browserstlowert _tryordertappendtinsert(tnametklasstinstancetupdate_tryorder((s"/usr/lib64/python2.7/webbrowser.pyRs   cCs|dk r|g}nt}x|D]}d|krqtj|}|ddkrdt|d St|Sq%yt|j}Wntk rt |}nX|ddk r|dS|ddk r%|dSq%Wt ddS(sCReturn a browser launcher instance appropriate for the environment.s%sit&iis!could not locate runnable browserN( tNoneR tshlextsplittBackgroundBrowsertGenericBrowserRR tKeyErrort _synthesizeR(tusingt alternativestbrowsertcommand((s"/usr/lib64/python2.7/webbrowser.pyRs$      icCs:x3tD]+}t|}|j|||rtSqWtS(N(R RRtTruetFalse(turltnewt autoraiseR R((s"/usr/lib64/python2.7/webbrowser.pyR:s   cCs t|dS(Ni(R(R((s"/usr/lib64/python2.7/webbrowser.pyRAscCs t|dS(Ni(R(R((s"/usr/lib64/python2.7/webbrowser.pyRDscCs|jd}t|s&ddgStjj|}yt|j}Wntk rfddgSX|d}|r|j|jkrddl }|j |}||_ tjj||_t |d||d|gSddgS(sAttempt 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]. iiiN( Rt _iscommandRtostpathtbasenameRR RtcopyR R(RRtcmdR Rt controllerR&((s"/usr/lib64/python2.7/webbrowser.pyRHs"         itwincCs`|j}tjj|r1|jdr1tSx(dD] }tjj||r8tSq8WtS(Ns.exes.bat(s.exes.bat(s.exes.bat(R R#R$tisfiletendswithRR(R'text((s"/usr/lib64/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"/usr/lib64/python2.7/webbrowser.pyR-rs 'cCsrt|rtStjjd}|s,tSx?|jtjD]+}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"/usr/lib64/python2.7/webbrowser.pyR"ys  t BaseBrowsercBsDeZdZdgZddZdedZdZdZRS(s3Parent class for all browsers. Do not use directly.s%stcCs||_||_dS(N(R R%(tselfR ((s"/usr/lib64/python2.7/webbrowser.pyt__init__s icCs tdS(N(tNotImplementedError(R<RR R!((s"/usr/lib64/python2.7/webbrowser.pyRscCs|j|dS(Ni(R(R<R((s"/usr/lib64/python2.7/webbrowser.pyRscCs|j|dS(Ni(R(R<R((s"/usr/lib64/python2.7/webbrowser.pyRs( RRt__doc__targsR=RRRR(((s"/usr/lib64/python2.7/webbrowser.pyR:s    RcBs&eZdZdZdedZRS(sVClass for all browsers started with a command and without remote functionality.cCs]t|tr'||_dg|_n|d|_|d|_tjj|j|_dS(Ns%sii(t isinstancet basestringR R@R#R$R%(R<R ((s"/usr/lib64/python2.7/webbrowser.pyR=s    icCs|jgg|jD]}|jd|^q}yItjd dkrZtj|}ntj|dt}|j SWnt k rt SXdS(Ns%siR)t close_fds( R R@treplacetsystplatformt subprocesstPopenRtwaittOSErrorR(R<RR R!targtcmdlinetp((s"/usr/lib64/python2.7/webbrowser.pyRs & (RRR?R=RR(((s"/usr/lib64/python2.7/webbrowser.pyRs RcBseZdZdedZRS(sHClass for all browsers which are to be started in the background.icCs|jgg|jD]}|jd|^q}ytjd dkrZtj|}nHttdd}|sttdd}ntj|dt d|}|j dkSWnt k rt SXdS(Ns%siR)tsetsidtsetpgrpRCt preexec_fn(R R@RDRERFRGRHtgetattrR#RRtpollRJR(R<RR R!RKRLRMRN((s"/usr/lib64/python2.7/webbrowser.pyRs & (RRR?RR(((s"/usr/lib64/python2.7/webbrowser.pyRst UnixBrowsercBsVeZdZdZddgZdZdZdZe Z e Z dZ de dZRS(s=Parent class for all Unix browsers with remote functionality.s%actions%sc Cs{g}|rC|jrCt|}|j|}|rC|g}qCn|jg||}|sf|jr{ttjd}nd}ttdd}|sttdd}nt j |dt d|d|j r|pdd|d|} |rFt jd | j} | dkrAt jd | j} | dkrAt Sn| S|jrl| jdkret StSn | j SdS( Nsr+RNRORCtstdintstdouttstderrRPii(t raise_optstintR t backgroundtfileR#tdevnullRRQRGRHRtredirect_stdoutttimetsleepRRRRI( R<R@tremoteR!t raise_opttoptRLtinoutRNRMtrc((s"/usr/lib64/python2.7/webbrowser.pyt_invokes<         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_newtabRRt remote_argsRDRdRR@R(R<RR R!tactionRKR@tsuccess((s"/usr/lib64/python2.7/webbrowser.pyRs"       1(N(RRR?RRWRhReRfRgRRYRR\RdR(((s"/usr/lib64/python2.7/webbrowser.pyRSs  ,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"/usr/lib64/python2.7/webbrowser.pyRks  tGaleoncBs8eZdZddgZddgZdZdZeZRS(s,Launcher class for Galeon/Epiphany browsers.s-noraiseR;s%actions%ss-ns-w( RRR?RWRhReRfRRY(((s"/usr/lib64/python2.7/webbrowser.pyRl)s   tChromecBs2eZdZddgZdZdZdZeZRS(s)Launcher class for Google Chrome browser.s%actions%sR;s --new-window( RRR?RhReRfRgRRY(((s"/usr/lib64/python2.7/webbrowser.pyRm3s  tOperacBs>eZdZddgZddgZdZdZdZeZ RS(s!Launcher class for Opera browser.s-noraiseR;s-remotesopenURL(%s%action)s ,new-windows ,new-page( RRR?RWRhReRfRgRRY(((s"/usr/lib64/python2.7/webbrowser.pyRn?s  tElinkscBs8eZdZddgZdZdZdZeZeZ RS(s#Launcher class for Elinks browsers.s-remotesopenURL(%s%action)R;s ,new-windows,new-tab( RRR?RhReRfRgRRYR\(((s"/usr/lib64/python2.7/webbrowser.pyRoJs t KonquerorcBseZdZdedZRS(sController for the KDE File Manager (kfm, or Konqueror). See the output of ``kfmclient --commands`` for more information on the Konqueror remote-control interface. ic Csw|dkrd}nd}ttjd}ttdd}|sZttdd}ny4tjd||gdtd |d |d |}Wntk rnX|j tSy:tjd d |gdtd |d |d |d|}Wntk rnX|j dkrtSy:tjdd|gdtd |d |d |d|}Wntk rbt SX|j dkSdS(NitnewTabtopenURLsr+RNROt kfmclientRCRTRURVt konquerors--silentRPtkfms-d( RZR#R[RQRRGRHRRJRIRRR(R<RR R!RiR[RNRM((s"/usr/lib64/python2.7/webbrowser.pyR_s@             (RRR?RR(((s"/usr/lib64/python2.7/webbrowser.pyRpXstGrailcBs)eZdZdZdedZRS(c Csddl}ddl}ddl}ddl}tjj|jd}|jtj d}tjj||d}|j|}|sdS|j|j |j } x_|D]W} y| j | Wn9|jk rytj| Wq tk rq XqX| SqWdS(Nis .grail-unixis-*(tglobtpwdtsocketttempfileR#R$R7t gettempdirtgetpwuidtgetuidRtAF_UNIXt SOCK_STREAMtconnectterrortunlinktIOError( R<RwRxRyRzttempdirtusertfilenametmaybeststfn((s"/usr/lib64/python2.7/webbrowser.pyt_find_grail_rcs*       cCs1|j}|sdS|j||jdS(Nii(Rtsendtclose(R<RiR((s"/usr/lib64/python2.7/webbrowser.pyt_remotes    icCs3|r|jd|}n|jd|}|S(NsLOADNEW sLOAD (R(R<RR R!tok((s"/usr/lib64/python2.7/webbrowser.pyRs(RRRRRR(((s"/usr/lib64/python2.7/webbrowser.pyRvs  c Csdtdr%tddtdndtjkrYtdrYtddtdndtjkrtdrtddtdndtjkrtdrtdttdntdrtddtdnx3dD]+}t|rt|dt|qqWtdrAtdttdn%tdrftdttdnx3dD]+}t|rmt|dt|qmqmWtdrtddtdnx3dD]+}t|rt|dt |qqWtdrtddt dntdrAtddtdntdr`tdt dndS( Nsxdg-opentGNOME_DESKTOP_SESSION_IDs gvfs-opens gnome-opentKDE_FULL_SESSIONRss x-www-browsersmozilla-firefoxtfirefoxsmozilla-firebirdtfirebirdt iceweaselticeapet seamonkeytmozillatnetscapeRuRttgaleontepiphanyt skipstones google-chrometchrometchromiumschromium-browsertoperatmosaictgrail( smozilla-firefoxRsmozilla-firebirdRRRRRR(RR(s google-chromeRRschromium-browser( R"RRRR#R5RpRkRlRmRnRv(R((s"/usr/lib64/python2.7/webbrowser.pytregister_X_browserssD              tDISPLAYtTERMs www-browsertlinkstelinkstlynxtw3mtWindowsDefaultcBseZdedZRS(icCs.ytj|Wntk r%tSXtSdS(N(R#t startfilet WindowsErrorRR(R<RR R!((s"/usr/lib64/python2.7/webbrowser.pyRs  (RRRR(((s"/usr/lib64/python2.7/webbrowser.pyRsswindows-defaultt PROGRAMFILESsC:\Program FilessInternet Explorer\IEXPLORE.EXERRRRRRtdarwintMacOSXcBs&eZdZdZdedZRS(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"/usr/lib64/python2.7/webbrowser.pyR=Esic Csd|krd|}ntt|}|jdkrSd|jdd}nR|jdkrkd}nd |d }d |jdd}d |j||f}tjd d}|dkrtS|j||j }| S(Nt:sfile:tdefaultsopen location "%s"t"s%22tOmniWebR;s toWindow %dis OpenURL "%s"stell application "%s" activate %s %s end tellt osascripttw( RXtboolR RDR#tpopenRRtwriteR( R<RR R!tscriptttoWindowR'tosapipeRc((s"/usr/lib64/python2.7/webbrowser.pyRHs       (RRR?R=RR(((s"/usr/lib64/python2.7/webbrowser.pyR;s  tMacOSXOSAScriptcBs eZdZdedZRS(cCs ||_dS(N(t_name(R<R ((s"/usr/lib64/python2.7/webbrowser.pyR=jsicCs|jdkr(d|jdd}nd|j|jddf}tjdd}|dkritS|j||j}| S(NRsopen location "%s"Rs%22s tell application "%s" activate open location "%s" end RR(RRDR#RRRRR(R<RR R!RRRc((s"/usr/lib64/python2.7/webbrowser.pyRms   (RRR=RR(((s"/usr/lib64/python2.7/webbrowser.pyRis tsafariRtos2t os2netscapetstarts%stBROWSERR;c Csddl}dtjd}y#|jtjdd\}}Wn=|jk r}tj|IJtj|IJtjdnXd}x>|D]6\}}|dkrd}q|dkrd}qqWt|dkrtj|IJtjdn|d}t||d GHdS( NisDUsage: %s [-n | -t] url -n: open new window -t: open new tabiitntds-ns-tis(tgetoptREtargvRRVtexittlenR( RtusagetoptsR@tmsgtnew_wintotaR((s"/usr/lib64/python2.7/webbrowser.pytmains( #       t__main__(6R?R#RRER.RGR]t__all__t ExceptionRRR RRRRRRRRRFR-R"tobjectR:RRRSRktNetscapeRlRmtChromiumRnRoRpRvRR5RR$R7tiexploreRRRRR6t _userchoicestreverseRLR'RR(((s"/usr/lib64/python2.7/webbrowser.pyts            P    95 >           .    #