VcbcsdZddlZddlZddlZddlZddlZddlZddlZgdZGdde Z ej Z iZ dadad4dddZd4d Zd5d Zd Zd ZdddZGddeZGddeZGddeZGddeZGddeZGddeZGddeZGddeZeZGdd eZ Gd!d"eZ!Gd#d$eZ"Gd%d&eZ#d'Z$d(Z%ej&dd)d*krGd+d,eZ'ej&d-krGd.d/eZ(Gd0d1eZ)d2Z*e+d3kr e*dSdS)6z?Interfaces for launching and remotely controlling web browsers.N)Erroropenopen_new open_new_tabgetregistercseZdZdS)rN)__name__ __module__ __qualname__#/usr/lib64/python3.11/webbrowser.pyrrsDr rF preferredcs<t5tt||gt|<|st r%|t vrtd|nt|ddddS#1swxYwYdS)zRegister a browser connector.Nr)_lock _tryorderregister_standard_browsers _browserslower_os_preferred_browserZinsertZappend)nameZklassinstancer r rrs  # #  ) & ( ( (#(("3 $**,,  #. #4;P3P #   Q % % % %   T " " " # # # # # # # # # # # # # # # # # #sAr N)r5rT) rrr __doc__argsr:rrrr r r r4r4sg== 6D""""!!!!!!!!r r4c eZdZdZdZddZdS)rzVClass for all browsers started with a command and without remote functionality.cst|tr||_dg|_n|d|_|dd|_tj|j|_dS)Nrrr)Z isinstanceZstrrrAr.r/r0r7r9r r:zGenericBrowser.__init__s_ dC  !DIDIIQDIQRRDI((33 r rTcs:tjd|jgfd|jDz} tjdddkrt j|}nt j|d}| S#t$rYdSwxYw)Nwebbrowser.openc<g|]}|dSrreplace.0argr" r z'GenericBrowser.open..7!7!7!7%("%T3!7!7!7!7!7r winT) close_fdsF) sysauditrrAplatform subprocessPopenwaitOSErrorr8r"r#r$cmdlinep ` r rzGenericBrowser.opens #S)))9+!7!7!7!7,0I!7!7!77 |BQB5( >$W--$W===vvxx<    55 sAB BBNr?rrr r@r:rr r r rrsA,,444      r rceZdZdZddZdS)rzHClass for all browsers which are to be started in the background.rTcs>|jgfd|jDz}tjd tjdddkrt j|}nt j|dd}|duS#t$rYdSwxYw)NcrDrErFrHrKr rLz*BackgroundBrowser.open..rMr rCrNrOT)rPstart_new_sessionF) rrArQrRrSrTrUpollrWrXr[r rzBackgroundBrowser.opens9+!7!7!7!7,0I!7!7!77 #S))) |BQB5( =$W--$W7;===FFHH$ %   55 sAB BBNr?rrr r@rr r r rrs2      r rcsBeZdZdZdZdZdZddgZdZdZ dZ d dZ d d Z dS) UnixBrowserz=Parent class for all Unix browsers with remote functionality.NFT%actionrcsg}|r(|jr!t|}|j|}|r|g}|jg|z|z}|s|jr tj}nd}t j|d||jr|pd|d} |r/ | d} | S#tj $rYdSwxYw|jr| dSdS|  S)NTrPstdinstdoutstderrr^iF) raise_optsintr backgroundrTDEVNULLrUredirect_stdoutrVZTimeoutExpiredr_) r8rAZremoter$r"Z raise_optZoptrYZinoutrZrc r _invokezUnixBrowser._invokes#  &do &II/),C %I9+ )D0  T_ &EEE  WE%)%9%Ce%Kt$)T C C C   VVAYYv ,   tt  _ vvxx tuvvxx< s9BB$#B$rcstjd|dkr|jn@|dkr|jn2|dkr|j|jn|jnt dd|zzfd|jD}d|D}||d |}|s*fd |jD}||d d Sd S) NrCrrr+zBad 'new' parameter to open(); zexpected 0, 1, or 2, got %scsdg|],}|dd-S)rrbrF)rIrJactionr"s r rL$UnixBrowser.open..sG--- D#&&..y&AA---r csg|]}||Sr r )rIrJr9r rLrps+++s++++r TcrDrErFrHrKr rLrps'@@@sCKKc**@@@r F) rQrR remote_actionremote_action_newwinremote_action_newtabr remote_argsrnrA)r8r"r#r$rAZsuccessros ` @r rzUnixBrowser.opens( #S))) !8 ='FF AX =.FF AX =( 32295;<== =-----+---++t+++,,tT9c:: @@@@di@@@D<<eU33 34r r6r?) rrr r@rgrirkrtrqrrrsrnrr r r rarasoGGJJOd#KM! ! ! ! Fr racs*eZdZdZddgZdZdZdZdZdS) Mozillaz$Launcher class for Mozilla browsers.rbrr5z -new-windowz-new-tabTN rrr r@rtrqrrrsrir r r rurus4..d#KM(%JJJr rucs2eZdZdZddgZddgZdZdZdZd Z d S) Netscapez$Launcher class for Netscape browser.-noraisez-raise-remoteopenURL(%s%action)r5 ,new-window,new-tabTN) rrr r@rgrtrqrrrsrir r r rwrw's?..h'J23KM(%JJJr rwcs.eZdZdZddgZddgZdZdZdZd S) Galeonz,Launcher class for Galeon/Epiphany browsers.rxr5rbr-nz-wTN) rrr r@rgrtrqrrrir r r r}r}2s866b!Jd#KMJJJr r}c*eZdZdZddgZdZdZdZdZdS)Chromez)Launcher class for Google Chrome browser.rbrr5 --new-windowTNrvr r r rr<s4//d#KM)JJJr rcr)Operaz!Launcher class for Opera browser.rbrr5rTNrvr r r rrHs4''d#KM)JJJr rcs.eZdZdZddgZdZdZdZdZdZ dS) Elinksz#Launcher class for Elinks browsers.ryrzr5r{r|FN) rrr r@rtrqrrrsrirkr r r rrRs<))23KM(%JOOOr rcr]) KonquerorzController for the KDE File Manager (kfm, or Konqueror). See the output of ``kfmclient --commands`` for more information on the Konqueror remote-control interface. rTcstjd||dkrd}nd}tj} tjd||gd|||}|dS#t $rYnwxYw tjdd |gd|||d }|dSn#t $rYnwxYw tjd d |gd|||d }|duS#t $rYd SwxYw)NrCr+ZnewTabZopenURL kfmclientT)rPrdrerf konquerorz--silentrckfmz-dF)rQrRrTrjrUrVrWr_)r8r"r#r$roZdevnullrZr3r rzKonqueror.opengsx #S))) !8 FFF$  +vs!;+/w(/AAAA FFHHH4     D   +z3!?+/w(/37999Avvxx t      D  & %s!3+/w(/37999AFFHH$ %   55 s5A A-,A-1B%% B21B26C)) C76C7Nr?r`r r r rr`s2 +&+&+&+&+&+&r rcs"eZdZdZdZddZdS)Grailcsddl}ddl}ddl}ddl}tj|d}|t j d}tj| || |dz}||}|sdS||j |j } |D]Q} | | | cS#t$r) t j| n#t$rYnwxYwYNwxYwdS)Nrz .grail-unixz-*)globpwdsockettempfiler.r/joinZ gettempdirZgetpwuidZgetuidZescapeZAF_UNIXZ SOCK_STREAMZconnectrWZunlink) r8rrrrZtempdirZuserZfilenameZmaybessZfnrmr _find_grail_rczGrail._find_grail_rcs[   ',,x2244,..||BIKK((+7<< G 4 4dkk$6G6G$6NOO8$$ 4 MM&.&*< = =  B  "    IbMMMMD    s66D ED/.E/ D<9E;D<<EEcs|}|sdS|||dS)Nrr)rZsendclose)r8rors r _remotez Grail._remotesA    ! ! 1 v  qr rTcstjd||r|d|z}n|d|z}|S)NrCzLOADNEW zLOAD )rQrRr)r8r"r#r$Zokr%r rz Grail.opensO #S)))  -j3.//BBgm,,B r Nr?)rrr rrrr r r rrsF4r rcsZtjdrtddtdtjdr tddtgddtjvr2tjdrtddtddtjvr7tjdr#tdt t dtjdrtddtdd D]4}tj|rt|dt|5d D]4}tj|rt|dt|5tjd r$td t t d n7tjd r#td t t d d D]4}tj|rt|dt|5tjdrtddtddD]4}tj|rt|dt|5tjdrtddtdtjdrtddtdtjdrtdtddSdS)Nzxdg-opengio)rrz--rZGNOME_DESKTOP_SESSION_IDz gvfs-openZKDE_FULL_SESSIONrz x-www-browser)firefoxZ iceweaselZiceape seamonkey)zmozilla-firefoxzmozilla-firebirdfirebirdmozillanetscaperr)ZgaleonZepiphanyZ skipstone)z google-chromechromeZchromiumzchromium-browseroperaZmosaicZgrail) r,r-rrr.environrrurwr}rrr)r r)r register_X_browsersrs,|JBT#4Z#@#@AAA|EN/0K0K0KLLMMM"RZ/DFL4M4MDd$5k$B$BCCCRZ'AFL,E,EAi;)?)?@@@ |O$$L$(9/(J(JKKKC66 <  6 WdGG$4$4 5 5 5+77 <  7 WdHW$5$5 6 6 6|EA 9U#3#34444 k " "Ai;)?)?@@@*55 <  5 WdF7OO 4 4 4|K  Dd$5k$B$BCCCO55 <  5 WdF7OO 4 4 4|G0$g///|H>4!28!">??? |BQB5 (="N3337<< ~?R S S ACC!:{I"GX7 D DG|G$$ D$(9'(B(BCCC D :>>) $ $ " 7H(I(I " /<BBDD'4SASTTT #**,,2244 )/%% &z'DoWij     ! ! ! :>>& ! ! =|M** Mn].K.KLLL|G$$ A$w(?(?@@@|H%% ;4)9)9:::|F## ?~f'='=>>>|E"" =nU&;&;<<<BJ Uj+11"*== # U UG"} U!'T:::q6UWdN7,C,CtTTTT U U  U Us#AH"H%$H%rNrOcseZdZddZdS)rrTcs|tjd| tj|dS#t$rYdSwxYw)NrCTF)rQrRr.Z startfilerWr;rr rzWindowsDefault.open^sW I' - - -  S!!! t    uu s - ;;Nr?)rrr rr r r rr]s(      r rrcrB)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. csftj|jjdtd||_dS)Nz3 is deprecated in 3.11 use MacOSXOSAScript instead.r+Z stacklevelwarningsZwarn __class__rZDeprecationWarningrr7r9r r:zMacOSX.__init__ysF MT^4:::;MZ[ ] ] ] ]DIIIr rTcstjd|d|vrd|z}tt|}|jdkrd|ddz}n@|jdkrd }nd |d z z}d |ddz}d |jd|d|d}t jdd}|dS||| }| S)NrCz:zfile:ropen location "%s""%22ZOmniWebr5z toWindow %drz OpenURL "%s"ztell application "zK" activate z z% end tell osascriptwF) rQrRrhZboolrrGr.popenwriter) r8r"r#r$scriptZtoWindowr2osapiperl r rz MacOSX.open~s I' - - -#: "ckd3ii..CyI% E- C0G0GG9 )9!HH -a8H$s{{3'>'>>,0999ccc888E h{C00G u MM& ! ! !B6Mr Nr?r\r r r rrosA           r rcs^eZdZdfd ZedZejdZd dZxZS) rrcsJt|dSr6)Zsuperr:)r8rrrKr r:zMacOSXOSAScript.__init__s! GG  T " " " " "r cs|tj|jjd|jjdtd|jSNz!._name is deprecated in 3.11 use z.name instead.r+rr)r8r)r _nameMacOSXOSAScript._namesW MT^4JJ"&."9JJJ, < < < <9 r cstj|jjd|jjdtd||_dSrr)r8Zvalr9r rrsZ MT^4JJ"&."9JJJ, < < < <DIIIr rTcs|jdkrd|ddz}n d|j|ddfz}tjdd}|dS|||}| S) Nrrrrz tell application "%s" activate open location "%s" end rrF)rrGr.rrr)r8r"r#r$rrrlr3r rzMacOSXOSAScript.opensyI% <- C0G0GG  3;;sE#:#:; <h{C00G u MM& ! ! !B6Mr )rr?) rrr r:ZpropertyrZsetterrZ __classcell__)rs@r rrs # # # # # #                   r rcs\ddl}dtjdz} |tjddd\}}na#|j$rT}t |tjt |tjtjdYd}~nd}~wwxYwd}|D]\}}|dkrd}|dkrd}t|dkr/t |tjtjd|d}t||t d dS) NrzDUsage: %s [-n | -t] url -n: open new window -t: open new tabrZntd)Zfiler~z-tr+z) getoptrQZargvZerrorZprintrfZexitZlenr) rZusageZoptsrAZmsgZnew_winZoZar"rr mainrsAMMM (1+ &E]]38ABB<77 dd < c #### e#*%%%%  G$$1 9 $gg $Y#! 4yyA~ e#*%%%%  q'Cg $KKKKKs+A B%A B  B%Z__main__r6r?),r@r.rr,rQrTZ threadingrZ__all__Z ExceptionrZRLockrrrrrrrrrrZobjectr4rrrarurwr}rZChromiumrrrrrrrSrrrrrr r r rsDEE  J J J     I         #e # # # # #5555D&',D!!!!!&!!!&[8&LLLLL+LLL^k{[[ K     [   2&2&2&2&2& 2&2&2&j,,,,,K,,,l@'@'@'DFUFUFU^<u          <8V////////b#####+###L0 z DFFFFF  r