B oìg­AÞã@sæddlZddlZddlZddlZddlZddlZddddddgZGdd„deƒZe  ¡Z iZ da da d;d d œd d„ZdéNÚErrorÚopenÚopen_newÚ open_new_tabÚgetÚregisterc@s eZdZdS)rN)Ú__name__Ú __module__Ú __qualname__©r r ú-/opt/alt/python37/lib/python3.7/webbrowser.pyrsF)Ú preferredc CsZtLtdkrtƒ||gt| ¡<|s4trB|tkrBt d|¡n t |¡WdQRXdS)Nr)Ú_lockÚ _tryorderÚregister_standard_browsersÚ _browsersÚlowerÚ_os_preferred_browserÚinsertÚappend)ÚnameÚklassÚinstancer r r r rsc Csätdkr&ttdkrtƒ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@Wt dƒ‚dS)Nz%séÿÿÿÿú&érz!could not locate runnable browser) rrrÚshlexÚsplitÚBackgroundBrowserÚGenericBrowserrrÚKeyErrorÚ _synthesizer)ZusingZ alternativesÚbrowserÚcommandr r r r%s,      Tc CsRtdkr&ttdkrtƒWdQRXx&tD]}t|ƒ}| |||¡r,dSq,WdS)NTF)rrrrr)ÚurlÚnewÚ autoraiserr"r r r rGs  cCs t|dƒS)Nr)r)r$r r r rZscCs t|dƒS)Né)r)r$r r r rascCs´| ¡d}t |¡sddgStj |¡}yt| ¡}Wntk rRddgSX|d}|r¬| ¡|jkr¬ddl }|  |¡}||_ tj |¡|_t |d||dd|gSddgS)Nrr)rr ) rÚshutilÚwhichÚosÚpathÚbasenamerrr Úcopyrr)r"r Úcmdrr#Z controllerr-r r r r!is"     r!c@s6eZdZdgZddd„Zddd„Zd d „Zd d „Zd S)Ú BaseBrowserz%sÚcCs||_||_dS)N)rr,)Úselfrr r r Ú__init__szBaseBrowser.__init__rTcCst‚dS)N)ÚNotImplementedError)r1r$r%r&r r r r”szBaseBrowser.opencCs | |d¡S)Nr)r)r1r$r r r r—szBaseBrowser.open_newcCs | |d¡S)Nr')r)r1r$r r r ršszBaseBrowser.open_new_tabN)r0)rT)rr r Úargsr2rrrr r r r r/‹s   r/c@seZdZdd„Zddd„ZdS) rcCsFt|tƒr||_dg|_n|d|_|dd…|_tj |j¡|_dS)Nz%srr)Ú isinstanceÚstrrr4r*r+r,)r1rr r r r2¢s    zGenericBrowser.__init__rTcsl|jg‡fdd„|jDƒ}y6tjdd…dkr­sz'GenericBrowser.open..éÚwinT)Ú close_fdsF)rr4ÚsysÚplatformÚ subprocessÚPopenÚwaitÚOSError)r1r$r%r&ÚcmdlineÚpr )r$r r¬s   zGenericBrowser.openN)rT)rr r r2rr r r r ržs rc@seZdZddd„ZdS)rrTcsp|jg‡fdd„|jDƒ}y:tjdd…dkr.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 rr r r r r¹src@s>eZdZdZdZdZddgZdZdZdZ dd„Z d d d „Z dS) Ú 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Úrcr r r Ú_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ƒ}| |d d ¡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$r r r: sz$UnixBrowser.open..cSsg|] }|r|‘qSr r )r8r9r r r r:sTcsg|]}| dˆ¡‘qS)z%s)r7)r8r9)r$r r 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 rMrOrQrYrVrWrXrTrr r r r rHËs#rHc@s$eZdZddgZdZdZdZdZdS)ÚMozillaz%actionz%sr0z -new-windowz-new-tabTN)rr r rYrVrWrXrOr r r r r[s r[c@s,eZdZddgZddgZdZdZdZdZd S) ÚNetscapez-noraisez-raisez-remotezopenURL(%s%action)r0z ,new-windowz,new-tabTN) rr r rMrYrVrWrXrOr r r r r\#s r\c@s(eZdZddgZddgZdZdZdZdS) ÚGaleonz-noraiser0z%actionz%sz-nz-wTN)rr r rMrYrVrWrOr r r r r].s r]c@s$eZdZddgZdZdZdZdZdS)ÚChromez%actionz%sr0z --new-windowTN)rr r rYrVrWrXrOr r r r r^8s r^c@s$eZdZddgZdZdZdZdZdS)ÚOperaz%actionz%sr0z --new-windowTN)rr r rYrVrWrXrOr r r r r_Ds r_c@s(eZdZddgZdZdZdZdZdZdS)ÚElinksz-remotezopenURL(%s%action)r0z ,new-windowz,new-tabFN) rr r rYrVrWrXrOrQr r r r 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ÚdevnullrEr r r rcs:      zKonqueror.openN)rT)rr r rr r r r 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_UNIXZ SOCK_STREAMZconnectrCÚunlink) r1rgrhrirjZtempdirÚuserÚfilenameZmaybesÚsÚfnr r r Ú_find_grail_rc”s*    zGrail._find_grail_rccCs&| ¡}|sdS| |¡| ¡dS)Nrr)rsÚsendÚclose)r1rUrqr r r Ú_remote®s  z Grail._remoterTcCs&|r| d|¡}n| d|¡}|S)NzLOADNEW zLOAD )rv)r1r$r%r&Úokr r r r¶sz Grail.openN)rT)rr r rsrvrr r r r rfsrfcCsò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*td ttd ƒƒx*d D]"}t |¡r0t|dt |ƒƒq0Wt d ¡rrtd dtd ƒƒx*dD]"}t |¡rxt|dt |ƒƒqxWt d¡rºtddt dƒƒ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"r r r Ú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–Wntj   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 kr.tj d tj¡}| ¡xF|D]>}|dkrìt|dd}|d dkrìt|dt|ƒddqì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)rKZTERMz www-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ÚresultZ userchoicesrDr r r rsT             rr;r<c@seZdZddd„ZdS)r…rTcCs,yt |¡Wntk r"dSXdSdS)NFT)r*Z startfilerC)r1r$r%r&r r r rSs zWindowsDefault.openN)rT)rr r rr r r r r…Rsr…rc@seZdZdd„Zddd„ZdS) r‚cCs ||_dS)N)r)r1rr r r 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%22ZOmniWebr0z toWindow %drz OpenURL "%s"z‰tell application "%s" activate %s %s end tellÚ osascriptÚwF)rNÚboolrr7r*ÚpopenÚwriteru) r1r$r%r&ÚscriptZtoWindowr.ÚosapiperSr r r rps       z MacOSX.openN)rT)rr r r2rr r r r r‚cs r‚c@seZdZdd„Zddd„ZdS) r„cCs ||_dS)N)Ú_name)r1rr r r r2’szMacOSXOSAScript.__init__rTcCsb|jdkrd| dd¡}nd|j| dd¡f}t dd¡}|dkrJdS| |¡| ¡}| S) Nrƒzopen location "%s"rz%22zž tell application "%s" activate open location "%s" end rŽrF)r•r7r*r‘r’ru)r1r$r%r&r“r”rSr r r r•s   zMacOSXOSAScript.openN)rT)rr r r2rr r r r r„‘sr„c Csòddl}dtjd}y| tjdd…d¡\}}WnJ|jk r~}z*t|tjdt|tjdt d¡Wdd}~XYnXd}x*|D]"\}}|dkr d}qŠ|dkrŠd}qŠWt|ƒdkrÔt|tjdt 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$r r r Ú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¢rr r r r ÚsP " "N     45AK .