Qf\hdZddlZddlZddlZddlZddlZddlZddlZgdZGdde Z ejZ iZ dadad1dddZd1d Zd2d Zd Zd Zddd ZGddeZGddeZGddeZGddeZGddeZGddeZGddeZeZGddeZGddeZ Gd d!eZ!Gd"d#eZ"d$Z#d%Z$ejJdd&d'k(r Gd(d)eZ&ejJd*k(rGd+d,eZ'Gd-d.eZ(d/Z)e*d0k(re)yy)3z?Interfaces for launching and remotely controlling web browsers.N)Erroropenopen_new open_new_tabgetregisterc eZdZy)rN)__name__ __module__ __qualname__1/opt/alt/python312/lib64/python3.12/webbrowser.pyrrsrrF preferredc t5t t||gt|j <|st r#|dt k(rtj d|ntj|dddy#1swYyxYw)zRegister a browser connector.Nz.desktopr)_lock _tryorderregister_standard_browsers _browserslower_os_preferred_browserinsertappend)nameklassinstancers rrrse    & (#(("3 $**, .dV83DH]3]   Q %   T " s A*A::Bctt5t tddd||g}nt}|D]u}d|vr:tj|}|ddk(rt |ddcSt |cS t|j}|d|dcS|dk|dcStd#1swYxYw#t$rt|}YLwxYw)zCReturn a browser launcher instance appropriate for the environment.N%s&rz!could not locate runnable browser) rrrshlexsplitBackgroundBrowserGenericBrowserrrKeyError _synthesizer)using alternativesbrowsercommands rrr&s  *, w   7?kk'*Gr{c!("66%g.. /#GMMO4qz%qz!'!wqz|## $ 3 443U& /%g. /sB76C7CCCctt5t tdddtD]"}t|}|j |||s"yy#1swY5xYw)azDisplay 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. If opening the browser succeeds, return True. If there is a problem, return False. NTF)rrrrr)urlnew autoraiserr+s rrrHsS  *,d) <<S) , Us AAct|dS)zuOpen url in a new window of the default browser. If not possible, then open url in the only browser window. r"rr.s rrr^ Q<rct|dS)zOpen url in a new page ("tab") of the default browser. If not possible, then the behavior becomes equivalent to open_new(). r2r3s rrrer4rc|jd}tj|sddgStjj |} t |j}|d}|rp|j|j k(rSddl }|j|}||_ tjj ||_t|d||d|gSddgS#t$rddgcYSwxYw)aAttempt 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$shutilwhichospathbasenamerrr'copyrr)r+rcmdrr, controllerr=s rr(r(ms --/! C << d| 77  C DDJJL)Jdjjlj&9&99YYz* !  gg..w7 $yIj!! $< d|s C C/.C/c2eZdZdZdgZddZd dZdZdZy) BaseBrowserz3Parent class for all browsers. Do not use directly.rc ||_||_yN)rr<selfrs r__init__zBaseBrowser.__init__s  rctrC)NotImplementedErrorrEr.r/r0s rrzBaseBrowser.opens!!rc&|j|dS)Nr"r2rEr.s rrzBaseBrowser.open_newyya  rc&|j|dS)Nr6r2rKs rrzBaseBrowser.open_new_tabrLrN)rT) r r r __doc__argsrFrrrr rrrArAs = 6D"!!rrAceZdZdZdZddZy)r&zVClass for all browsers started with a command and without remote functionality.ct|tr||_dg|_n|d|_|dd|_tj j |j|_y)Nrrr") isinstancestrrrQr:r;r<rDs rrFzGenericBrowser.__init__sP dC DIDIQDIQRDI((3 rcptjd||jg|jDcgc]}|j d|c}z} tj dddk(rt j|}nt j|d}|j Scc}w#t$rYywxYw)Nwebbrowser.openrwinT) close_fdsF) sysauditrrQreplaceplatform subprocessPopenwaitOSErrorrEr.r/r0argcmdlineps rrzGenericBrowser.opens #S)99+,0II!7,5S"%T3!7,5!77 ||BQ5($$W-$$W=vvx< !7  sB$AB)) B54B5NrOr r r rPrFrr rrr&r&s,4 rr&ceZdZdZddZy)r%zHClass for all browsers which are to be started in the background.ct|jg|jDcgc]}|jd|c}z}tjd| tj dddk(rt j|}nt j|dd}|jduScc}w#t$rYywxYw)NrrWrXrYT)rZstart_new_sessionF) rrQr]r[r\r^r_r`pollrbrcs rrzBackgroundBrowser.opens99+,0II!7,5S"%T3!7,5!77 #S) ||BQ5($$W-$$W7;=FFH$ %!7  sB&AB++ B76B7NrOr r r rPrr rrr%r%s  rr%c@eZdZdZdZdZdZddgZdZdZ dZ d dZ d dZ y) UnixBrowserz=Parent class for all Unix browsers with remote functionality.NFT%actionrcg}|r+|jrt|}|j|}|r|g}|jg|z|z}|s |jrtj }nd}t j |d||jxr|xsd|d} |r | jd} | S|jr| jyy| j S#tj$rYywxYw)NTrZstdinstdoutstderrrjF) raise_optsintr backgroundr_DEVNULLr`redirect_stdoutraTimeoutExpiredrk) rErQremoter0r. raise_optoptreinoutrfrcs r_invokezUnixBrowser._invokes dooII//),CI99+ )D0 T__&&EE   WE%)%9%9%Ce%Kt$)T C  VVAYv __vvxvvx< ,,  sCC-,C-cHtjd||dk(r |j}nN|dk(r |j}n<|dk(r&|j |j}n|j}nt dd|zz|j Dcgc]$}|jd|jd|&}}|Dcgc]}|s| }}|j|d ||}|s<|jDcgc]}|jd|}}|j|d d Sy cc}wcc}wcc}w) NrWrr"r6zBad 'new' parameter to open(); zexpected 0, 1, or 2, got %srroTF) r[r\ remote_actionremote_action_newwinremote_action_newtabr remote_argsr]rrQ)rEr.r/r0actionrdrQsuccesss rrzUnixBrowser.opens/ #S) !8''F AX..F AX((0222295;<= = ++-+C D#&..y&A+ -#+tst+,,tT9c:6:ii@isCKKc*iD@<<eU3 3-+As)D4D<D&DrCrO) r r r rPrvrxrzrrrrrrr rrrnrns<GJJOd#KM! Frrnc(eZdZdZddgZdZdZdZdZy) Mozillaz$Launcher class for Mozilla browsers.rorrNz -new-windowz-new-tabTN r r r rPrrrrrxr rrrr s%.d#KM(%Jrrc,eZdZdZddgZddgZdZdZdZy ) Epiphanyz$Launcher class for Epiphany browser.z-noraiserNror-nz-wTN) r r r rPrvrrrrxr rrrr*s).b!Jd#KMJrrc(eZdZdZddgZdZdZdZdZy)Chromez)Launcher class for Google Chrome browser.rorrN --new-windowTNrr rrrr4s%/d#KM)Jrrc(eZdZdZddgZdZdZdZdZy)Operaz!Launcher class for Opera browser.rorrNrTNrr rrrr@s%'d#KM)Jrrc,eZdZdZddgZdZdZdZdZdZ y) Elinksz#Launcher class for Elinks browsers.z-remotezopenURL(%s%action)rNz ,new-windowz,new-tabFN) r r r rPrrrrrxrzr rrrrJs-)23KM(%JOrrceZdZdZddZy) KonquerorzController for the KDE File Manager (kfm, or Konqueror). See the output of ``kfmclient --commands`` for more information on the Konqueror remote-control interface. ctjd||dk(rd}nd}tj} tjd||gd|||}|j y#t $rYnwxYw tjdd |gd|||d }|jy#t $rYnwxYw tjd d |gd|||d }|jduS#t $rYy wxYw)NrWr6newTabopenURL kfmclientT)rZrrrsrt konquerorz--silentrqkfmz-dF)r[r\r_ryr`rarbrk)rEr.r/r0rdevnullrfs rrzKonqueror.open_s #S) !8FF$$   +vs!;+/w(/AA FFH       +z3!?+/w(/379Avvx     &  %s!3+/w(/379AFFH$ %  s5A A,+A,0B B+*B+/C C+*C+NrOrlr rrrrXs  +&rrc(eZdZdZddgZdZdZdZdZy)Edgez*Launcher class for Microsoft Edge browser.rorrNrTNrr rrrrs%0d#KM)Jrrctjdrtddtdtjdrtddtgddtj vr+tjdrtddtddtj vr/tjdrtdt t dtjdrtddtdd D].}tj|st|dt|0tjd rtd t t d n/tjd rtd t t d tjd rtd dtd d D].}tj|st|dt|0tjdrtddtdtjdrtddtdyy)Nzxdg-opengio)rrz--rGNOME_DESKTOP_SESSION_IDz gvfs-openKDE_FULL_SESSIONrz x-www-browser)firefox iceweasel seamonkeyzmozilla-firefoxmozillarrepiphany)z google-chromechromechromiumzchromium-browseroperamicrosoft-edge) r8r9rr%r:environrrrrrr)r+s rregister_X_browsersrs||JT#4Z#@A||E/0KLM"RZZ/FLL4Md$5k$BCRZZ'FLL,Ei;)?@||O$$(9/(JK << WdGG$4 5 ||E 9U#34 k "i;)?@||JT8J#78O << WdF7O 4O ||G$g/||$%!4.>)?@&rcgatjdk(rXtddt dtddt dtddt dtddt dtjdk(rtddt dtjdd d k(rtd t tjjtjjd d d}tjjtjjddd}ddddd||fD].}tj|st|dt |0tjdrtddtdntjjdstjjdr` dj}t!j"|t j$}|j'j)}|at5tjjdrtjdrtddt7dtjdrtddt7dtjdrtddt9dtjdrtddt7dtjdrtddt7dd tjvrytjd jtj:}|j=|D]3}|d!k7s t?|d"#}|d$t|dt7|d"#5yy#t,t j.t0t2f$rYwxYw)%NdarwinMacOSXdefaultrrsafari serenityosBrowserrXrYzwindows-defaultzPROGRAMFILES(x86)zC:\Program Files (x86)z%Microsoft\Edge\Application\msedge.exe PROGRAMFILESzC:\Program FilesrrrzMicrosoftEdge.exerDISPLAYWAYLAND_DISPLAYz$xdg-settings get default-web-browser)rtTERMz www-browserlinkselinkslynxw3mBROWSERrNTrr") rr[r^rMacOSXOSAScriptr%WindowsDefaultr:r;joinrrr8r9rr$r_ check_outputrydecodestriprFileNotFoundErrorCalledProcessErrorPermissionErrorNotADirectoryErrorrr&rpathsepreverser()edge64edge32r+r> raw_resultresult userchoicesres rrrsI ||x4!;<4!:;D/)"<=4!:; |||#D"3I">? ||BQ5 "N3bjjnn-@B[\HJbjjnn^=PQHJ!; 81G||G$$(9'(BC1 <<+ , %tT2E-F G ::>>) $ 7H(I /<BBD'44SASAST #**,224 )/%  ! ::>>& !||M*n].KL||G$$w(?@||H%4)9:||F#~f'=>||E"nU&;<BJJjj+11"**= #G"}!'T:q6>WdN7,CtT # 7&z'D'DoWij  s AO#O('O(rXrYceZdZddZy)rcztjd| tj|y#t$rYywxYw)NrWTF)r[r\r: startfilerbrIs rrzWindowsDefault.open+s= II' -  S!    s . ::NrO)r r r rr rrrr*s rrrceZdZdZdZddZy)ra{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. cxtj|jjdtd||_y)Nz3 is deprecated in 3.11 use MacOSXOSAScript instead.r6 stacklevelwarningswarn __class__r DeprecationWarningrrDs rrFzMacOSX.__init__Fs5 MMT^^4456::;MZ[ ]DIrctjd|d|vrd|z}tt|}|jdk(rd|j ddz}nE|jdk(rd }nd |d z z}d |j ddz}d |jd|d|d}t jdd}|y|j||j}| S)NrW:zfile:ropen location "%s""%22OmniWebrNz toWindow %dr"z OpenURL "%s"ztell application "zK" activate  z% end tell osascriptwF) r[r\rwboolrr]r:popenwriteclose) rEr.r/r0scripttoWindowr>osapipers rrz MacOSX.openKs II' -#:ckd3i.CyyI%- C0GG99 )!H -a8H$s{{3'>>,099c8E hh{C0G MM& !B6MrNrOrgr rrrr<s   rrc\eZdZdfd ZedZej dZddZxZS)rc$t||yrC)superrF)rErrs rrFzMacOSXOSAScript.__init__ns G T "rctj|jjd|jjdtd|j SNz!._name is deprecated in 3.11 use z.name instead.r6rr)rEs r_namezMacOSXOSAScript._nameqsK MMT^^4456""&.."9"9!:.J, <99 rctj|jjd|jjdtd||_yrr)rEvals rrzMacOSXOSAScript._namexsH MMT^^4456""&.."9"9!:.J, <DIrc4tjd||jdk(rd|jddz}n!d|j|jddfz}t j dd}|y |j ||j}| S) NrWrrrrz tell application "%s" activate open location "%s" end rrF)r[r\rr]r:rrr)rEr.r/r0rrrs rrzMacOSXOSAScript.opens II' -yyI%- C0GG  3;;sE#:; <hh{C0G MM& !B6Mr)rrO) r r r rFpropertyrsetterr __classcell__)rs@rrrms9 #          rrcddl}dtjdz} |jtjddddg\}}d}D]O\}}|dk(rd}|dk(rd }|d k(s|d k(s!t |tj tj Qtdk7r0t |tj tj d|d}t||t d y#|j$rV}t |tj t |tj tj dYd}~d}~wwxYw) NrzcUsage: %s [-n | -t | -h] url -n: open new window -t: open new tab -h, --help: show helpr"ntdhhelp)filerz-tr6z-hz--help) getoptr[argverrorprintrtexitlenr) rusageoptsrQmsgnew_winoar.s rmainr s  #xx{ +E]]388AB<A d G1 9g $Y! $Y!x- %cjj ) HHJ   4yA~ e#**%  q'Cg $K% << c # e#**%  s(C55EA EE__main__rCrO)+rPr:r#r8r[r_ threadingr__all__ ExceptionrRLockrrrrrrrrrr(objectrAr&r%rnrrrChromiumrrrrrrr^rrrr r r rrrs|E  J I       #e #5D,',D!&!&[8&L+L^k{[ K [ 2& 2&j;"2AjMUl<<u   <<8//b$+$N8 zFr