³ò
Á›\Kc           @   sá  d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d d d d d g Z d e f d	 „  ƒ  YZ	 h  Z
 g  Z d d
 d „ Z d d „ Z d d
 d „ Z d „  Z d „  Z d
 d „ Z e i d  d j o d „  Z n
 d „  Z d „  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d  „  ƒ  YZ e Z d! e f d" „  ƒ  YZ d# e f d$ „  ƒ  YZ d% e f d& „  ƒ  YZ d' e f d( „  ƒ  YZ  d) e f d* „  ƒ  YZ! d+ „  Z" e i# i d, ƒ o e" ƒ  n e i# i d- ƒ oÇ e d. ƒ o e d. d e d. ƒ ƒ n e d/ ƒ o e d/ d e d/ ƒ ƒ n e d0 ƒ o e d0 d e d0 ƒ ƒ n e d1 ƒ o e d1 d e d1 ƒ ƒ n e d2 ƒ o e d2 d e d2 ƒ ƒ qæn e i d  d j ok d3 e f d4 „  ƒ  YZ$ g  Z h  Z
 x5 dL D]- Z% e e% ƒ o e e% d e e% ƒ ƒ q#q#We d; e$ ƒ n y d d k& Z& Wn e' j
 o n+ Xd< e f d= „  ƒ  YZ( e d> e( d? d ƒe i d@ j o3 dA e f dB „  ƒ  YZ) e dA d e) dC ƒ d ƒ n e i d  dD j o? e d9 ƒ o2 g  Z h  Z
 e dE d e dF d9 dG g ƒ d ƒ n dH e i# j ob e i# dH i* e i+ ƒ Z, e, i- ƒ  x, e, D]$ Z. e. dI j o e e. d ƒ q„q„Wd Z. [. [, n dJ „  Z/ e0 dK j o e/ ƒ  n d S(M   s?   Interfaces for launching and remotely controlling Web browsers.iÿÿÿÿNt   Errort   opent   open_newt   open_new_tabt   gett   registerc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s    /usr/lib/python2.5/webbrowser.pyR       s   i   c         C   sY   | | g t  |  i ƒ  <| d j o t i |  ƒ n" | d j  o t i d |  ƒ n d S(   s9   Register a browser connector and, optionally, connection.i    N(   t	   _browserst   lowert	   _tryordert   appendt   insert(   t   namet   klasst   instancet   update_tryorder(    (    s    /usr/lib/python2.5/webbrowser.pyR      s
    c         C   s  |  d j	 o |  g } n t } xÎ | D]Æ } d | j o@ t i | ƒ } | d d j o t | d  ƒ Sqí t | ƒ Sq' y t | i ƒ  } Wn t j
 o t	 | ƒ } n X| d d j	 o | d Sq' | d d j	 o | d ƒ  Sq' q' Wt
 d ƒ ‚ d S(   sC   Return a browser launcher instance appropriate for the environment.s   %siÿÿÿÿt   &i   i    s!   could not locate runnable browserN(   t   NoneR
   t   shlext   splitt   BackgroundBrowsert   GenericBrowserR   R	   t   KeyErrort   _synthesizeR    (   t   usingt   alternativest   browsert   command(    (    s    /usr/lib/python2.5/webbrowser.pyR      s&     i    c         C   s?   x8 t  D]0 } t | ƒ } | i |  | | ƒ o t Sq q Wt S(   N(   R
   R   R   t   Truet   False(   t   urlt   newt	   autoraiseR   R   (    (    s    /usr/lib/python2.5/webbrowser.pyR   :   s     c         C   s   t  |  d ƒ S(   Ni   (   R   (   R   (    (    s    /usr/lib/python2.5/webbrowser.pyR   A   s    c         C   s   t  |  d ƒ S(   Ni   (   R   (   R   (    (    s    /usr/lib/python2.5/webbrowser.pyR   D   s    c      	   C   sü   |  i  ƒ  d } t | ƒ p d d g Sn t i i | ƒ } y t | i ƒ  } Wn t j
 o d d g Sn X| d } | op | i ƒ  | i j oZ d d k	 } | i	 | ƒ } |  | _
 t i i |  ƒ | _ t |  d | | ƒ d | g Sn d d g S(   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].

    i    i   iÿÿÿÿN(   R   t
   _iscommandR   t   ost   patht   basenameR   R	   R   t   copyR   R   (   R   R   t   cmdR   R   t
   controllerR&   (    (    s    /usr/lib/python2.5/webbrowser.pyR   H   s"    
	i   t   winc         C   sk   |  i  ƒ  }  t i i |  ƒ o |  i d ƒ o t Sn x- d D]% } t i i |  | ƒ o t Sq> q> Wt S(   Ns   .exes   .bat(   s   .exes   .bat(   s   .exes   .bat(   R	   R#   R$   t   isfilet   endswithR   R   (   R'   t   ext(    (    s    /usr/lib/python2.5/webbrowser.pyt   _isexecutablei   s    # c         C   sc   t  i i |  ƒ oL t  i |  ƒ t i } | t i @p | t i @p | t i @o t Sq_ n t	 S(   N(
   R#   R$   R*   t   statt   ST_MODEt   S_IXUSRt   S_IXGRPt   S_IXOTHR   R   (   R'   t   mode(    (    s    /usr/lib/python2.5/webbrowser.pyR-   r   s
    *c         C   s   t  |  ƒ o t Sn t i i d ƒ } | p t Sn xD | i t i ƒ D]0 } t i i	 | |  ƒ } t  | ƒ o t SqI qI Wt S(   sS   Return True if cmd is executable or can be found on the executable
    search path.t   PATH(
   R-   R   R#   t   environR   R   R   t   pathsepR$   t   join(   R'   R$   t   dt   exe(    (    s    /usr/lib/python2.5/webbrowser.pyR"   y   s     t   BaseBrowserc           B   sD   e  Z d  Z d g Z d d „ Z d d d „ Z d „  Z d „  Z RS(	   s3   Parent class for all browsers. Do not use directly.s   %st    c         C   s   | |  _  | |  _ d  S(   N(   R   R%   (   t   selfR   (    (    s    /usr/lib/python2.5/webbrowser.pyt   __init__   s    	i    i   c         C   s
   t  ‚ d  S(   N(   t   NotImplementedError(   R<   R   R    R!   (    (    s    /usr/lib/python2.5/webbrowser.pyR   “   s    c         C   s   |  i  | d ƒ S(   Ni   (   R   (   R<   R   (    (    s    /usr/lib/python2.5/webbrowser.pyR   –   s    c         C   s   |  i  | d ƒ S(   Ni   (   R   (   R<   R   (    (    s    /usr/lib/python2.5/webbrowser.pyR   ™   s    (   R   R   t   __doc__t   argsR=   R   R   R   (    (    (    s    /usr/lib/python2.5/webbrowser.pyR:   Š   s   		R   c           B   s&   e  Z d  Z d „  Z d d d „ Z RS(   sV   Class for all browsers started with a command
       and without remote functionality.c         C   s_   t  | t ƒ o | |  _ d g |  _ n | d |  _ | d |  _ t i i |  i ƒ |  _ d  S(   Ns   %si    i   (   t
   isinstancet
   basestringR   R@   R#   R$   R%   (   R<   R   (    (    s    /usr/lib/python2.5/webbrowser.pyR=   ¡   s    	i    i   c      
   C   s£   |  i  g g  } |  i D] } | | i d | ƒ q ~ } yK t i d  d j o t i | ƒ } n t i | d t ƒ} | i ƒ  SWn t	 j
 o t
 Sn Xd  S(   Ns   %si   R)   t	   close_fds(   R   R@   t   replacet   syst   platformt
   subprocesst   PopenR   t   waitt   OSErrorR   (   R<   R   R    R!   t   _[1]t   argt   cmdlinet   p(    (    s    /usr/lib/python2.5/webbrowser.pyR   «   s    *(   R   R   R?   R=   R   (    (    (    s    /usr/lib/python2.5/webbrowser.pyR      s   	
R   c           B   s   e  Z d  Z d d d „ Z RS(   sH   Class for all browsers which are to be started in the
       background.i    i   c   	      C   sÝ   |  i  g g  } |  i D] } | | i d | ƒ q ~ } y… t i d  d j o t i | ƒ } nK t t d d  ƒ } | p t t d d  ƒ } n t i | d t
 d | ƒ} | i ƒ  d  j SWn t j
 o t Sn Xd  S(   Ns   %si   R)   t   setsidt   setpgrpRC   t
   preexec_fn(   R   R@   RD   RE   RF   RG   RH   t   getattrR#   R   R   t   pollRJ   R   (	   R<   R   R    R!   RK   RL   RM   RN   RO   (    (    s    /usr/lib/python2.5/webbrowser.pyR   ¼   s    *(   R   R   R?   R   (    (    (    s    /usr/lib/python2.5/webbrowser.pyR   ¸   s   t   UnixBrowserc           B   sV   e  Z d  Z d Z d d g Z d Z d Z d Z e	 Z
 e Z d „  Z d d d „ Z RS(   s=   Parent class for all Unix browsers with remote functionality.s   %actions   %sc         C   s   g  } | oA |  i  o7 t t | ƒ ƒ } |  i  | } | o | g } qN n |  i g | | } | p
 |  i o t t i d ƒ } n d  } t	 t d d  ƒ } | p t	 t d d  ƒ } n t
 i | d t d | d |  i o | p d  d | d | ƒ}	 | oa t i d	 ƒ |	 i ƒ  }
 |
 d  j o2 t i d
 ƒ |	 i ƒ  }
 |
 d  j o t Sq[n |
 Sn9 |  i o# |	 i ƒ  d  j o t Sqœt Sn |	 i ƒ  Sd  S(   Ns   r+RO   RP   RC   t   stdint   stdoutt   stderrRQ   i   i   (   t
   raise_optst   intt   boolR   t
   backgroundt   fileR#   t   devnullR   RR   RG   RH   R   t   redirect_stdoutt   timet   sleepRS   R   RI   (   R<   R@   t   remoteR!   t	   raise_optt   optRM   t   inoutRO   RN   t   rc(    (    s    /usr/lib/python2.5/webbrowser.pyt   _invoke×   s<     	
i    i   c   
      C   s&  | d j o |  i  } nf | d j o |  i } nL | d j o* |  i d  j o |  i } q |  i } n t d d | ƒ ‚ g  } |  i D]% } | | i d | ƒ i d | ƒ q ~ } |  i | t | ƒ } | pG g  }	 |  i	 D] } |	 | i d | ƒ qå ~	 } |  i | t
 t
 ƒ Sn t Sd  S(   Ni    i   i   s   Bad 'new' parameter to open(); s   expected 0, 1, or 2, got %ss   %ss   %action(   t   remote_actiont   remote_action_newwint   remote_action_newtabR   R    t   remote_argsRD   Rf   R   R@   R   (
   R<   R   R    R!   t   actionRK   RL   R@   t   successt   _[2](    (    s    /usr/lib/python2.5/webbrowser.pyR     s"    50N(   R   R   R?   R   RX   Rj   Rg   Rh   Ri   R   R[   R   R^   Rf   R   (    (    (    s    /usr/lib/python2.5/webbrowser.pyRT   Ì   s   	,t   Mozillac           B   s>   e  Z d  Z d d g Z d d g Z d Z d Z d Z e Z	 RS(   s-   Launcher class for Mozilla/Netscape browsers.s   -noraises   -raises   -remotes   openURL(%s%action)R;   s   ,new-windows   ,new-tab(
   R   R   R?   RX   Rj   Rg   Rh   Ri   R   R[   (    (    (    s    /usr/lib/python2.5/webbrowser.pyRn     s   t   Galeonc           B   s8   e  Z d  Z d d g Z d d g Z d Z d Z e Z RS(   s,   Launcher class for Galeon/Epiphany browsers.s   -noraiseR;   s   %actions   %ss   -ns   -w(	   R   R   R?   RX   Rj   Rg   Rh   R   R[   (    (    (    s    /usr/lib/python2.5/webbrowser.pyRo   +  s   t   Operac           B   s>   e  Z d  Z d d g Z d d g Z d Z d Z d Z e Z	 RS(   s!   Launcher class for Opera browser.R;   s   -raises   -remotes   openURL(%s%action)s   ,new-windows	   ,new-page(
   R   R   R?   RX   Rj   Rg   Rh   Ri   R   R[   (    (    (    s    /usr/lib/python2.5/webbrowser.pyRp   6  s   t   Elinksc           B   s8   e  Z d  Z d d g Z d Z d Z d Z e Z e Z	 RS(   s#   Launcher class for Elinks browsers.s   -remotes   openURL(%s%action)R;   s   ,new-windows   ,new-tab(
   R   R   R?   Rj   Rg   Rh   Ri   R   R[   R^   (    (    (    s    /usr/lib/python2.5/webbrowser.pyRq   B  s   t	   Konquerorc           B   s   e  Z d  Z d d d „ Z RS(   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.
    i    i   c         C   s‰  | d j o
 d } n d } t  t i d ƒ } t t d d  ƒ } | p t t d d  ƒ } n y4 t i d | | g d t d	 | d
 | d | ƒ} Wn t j
 o n X| i	 ƒ  t Sy: t i d d | g d t d	 | d
 | d | d | ƒ} Wn t j
 o n X| i
 ƒ  d  j o t Sn y: t i d d | g d t d	 | d
 | d | d | ƒ} Wn t j
 o t Sn X| i
 ƒ  d  j Sd  S(   Ni   t   newTabt   openURLs   r+RO   RP   t	   kfmclientRC   RU   RV   RW   t	   konquerors   --silentRQ   t   kfms   -d(   R\   R#   R]   RR   R   RG   RH   R   RJ   RI   RS   R   (   R<   R   R    R!   Rk   R]   RO   RN   (    (    s    /usr/lib/python2.5/webbrowser.pyR   W  s@    

	(   R   R   R?   R   (    (    (    s    /usr/lib/python2.5/webbrowser.pyRr   P  s   t   Grailc           B   s)   e  Z d  „  Z d „  Z d d d „ Z RS(   c      
   C   s  d d  k  } d d  k } d d  k } d d  k } t i i | i ƒ  d ƒ } | i t i	 ƒ  ƒ d } t i i | | d ƒ } | i  | ƒ } | p d  Sn | i | i | i ƒ }	 xc | D][ }
 y |	 i |
 ƒ Wn= | i j
 o. y t i |
 ƒ Wqt j
 o qXqº X|	 Sqº Wd  S(   Niÿÿÿÿs   .grail-unixi    s   -*(   t   globt   pwdt   sockett   tempfileR#   R$   R7   t
   gettempdirt   getpwuidt   getuidR   t   AF_UNIXt   SOCK_STREAMt   connectt   errort   unlinkt   IOError(   R<   Ry   Rz   R{   R|   t   tempdirt   usert   filenamet   maybest   st   fn(    (    s    /usr/lib/python2.5/webbrowser.pyt   _find_grail_rc  s,    	 
c         C   s6   |  i  ƒ  } | p d Sn | i | ƒ | i ƒ  d S(   Ni    i   (   RŒ   t   sendt   close(   R<   Rk   RŠ   (    (    s    /usr/lib/python2.5/webbrowser.pyt   _remote§  s    
i    i   c         C   s5   | o |  i  d | ƒ } n |  i  d | ƒ } | S(   Ns   LOADNEW s   LOAD (   R   (   R<   R   R    R!   t   ok(    (    s    /usr/lib/python2.5/webbrowser.pyR   ¯  s    (   R   R   RŒ   R   R   (    (    (    s    /usr/lib/python2.5/webbrowser.pyRx   ‰  s   		c       	   C   sú  t  d ƒ on d }  t i |  ƒ } | i ƒ  i ƒ  } | i ƒ  } | d  j o* | o# t d d  t t	 i
 | ƒ ƒ ƒ q{ n t  d ƒ o t d d  t d ƒ ƒ n x5 d D]- } t  | ƒ o t | d  t | ƒ ƒ q© q© Wt  d ƒ o t d t t d ƒ ƒ n( t  d ƒ o t d t t d ƒ ƒ n x5 d D]- } t  | ƒ o t | d  t | ƒ ƒ q/q/Wt  d ƒ o t d d  t d ƒ ƒ n t  d ƒ o t d d  t d ƒ ƒ n t  d ƒ o t d d  t d ƒ ƒ n t  d ƒ o t d t d  ƒ n d  S(   Ns   gconftool-2sC   gconftool-2 -g /desktop/gnome/url-handlers/http/command 2>/dev/nullt   gnomes   x-www-browsers   mozilla-firefoxt   firefoxt	   iceweaselt   iceapes   mozilla-firebirdt   firebirdt	   seamonkeyt   mozillat   netscapeRw   Rv   t   galeont   epiphanyt	   skipstonet   operat   mosaict   grail(	   s   mozilla-firefoxR’   R“   R”   s   mozilla-firebirdR•   R–   R—   R˜   (   R™   Rš   (   R"   R#   t   popent   readt   stripRŽ   R   R   R   R   R   Rn   Rr   Ro   Rp   Rx   (   t   gct   outt   commdt   retncodeR   (    (    s    /usr/lib/python2.5/webbrowser.pyt   register_X_browsers¾  s>    '   t   DISPLAYt   TERMs   www-browsert   linkst   elinkst   lynxt   w3mt   WindowsDefaultc           B   s   e  Z d  d d „ Z RS(   i    i   c         C   s   t  i | ƒ t S(   N(   R#   t	   startfileR   (   R<   R   R    R!   (    (    s    /usr/lib/python2.5/webbrowser.pyR     s    (   R   R   R   (    (    (    s    /usr/lib/python2.5/webbrowser.pyR­   
  s   R’   R•   R–   R—   R˜   Rœ   s   windows-defaultt   InternetConfigc           B   s   e  Z d  d d „ Z RS(   i    i   c         C   s   t  i | ƒ t S(   N(   t   ict	   launchurlR   (   R<   R   R    R!   (    (    s    /usr/lib/python2.5/webbrowser.pyR   "  s    (   R   R   R   (    (    (    s    /usr/lib/python2.5/webbrowser.pyR¯   !  s   s   internet-configR   t   darwint   MacOSXc           B   s&   e  Z d  Z d „  Z d d d „ Z RS(   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.
        c         C   s   | |  _  d  S(   N(   R   (   R<   R   (    (    s    /usr/lib/python2.5/webbrowser.pyR=   4  s    i    i   c   	      C   s  d | j p t  ‚ d | j o d | } n t t | ƒ ƒ } |  i d j o d | i d d ƒ } nU |  i d j o
 d	 } n d
 | d } d | i d d ƒ } d |  i | | f } t i d d ƒ } | d  j o t Sn | i	 | ƒ | i
 ƒ  } | S(   Nt   't   :s   file:t   defaults   open location "%s"t   "s   %22t   OmniWebR;   s   toWindow %di   s   OpenURL "%s"s‰   tell application "%s"
                                activate
                                %s %s
                            end tellt	   osascriptt   w(   t   AssertionErrorRY   RZ   R   RD   R#   RŸ   R   R   t   writeRŽ   (	   R<   R   R    R!   t   scriptt   toWindowR'   t   osapipeRe   (    (    s    /usr/lib/python2.5/webbrowser.pyR   7  s"    
(   R   R   R?   R=   R   (    (    (    s    /usr/lib/python2.5/webbrowser.pyR³   *  s   		R¶   t   os2t   os2netscapet   starts   %st   BROWSERR;   c    	   
   C   s  d d  k  }  d t i d } y# |  i  t i d d ƒ \ } } Wn? |  i j
 o0 } t i | IJt i | IJt i d ƒ n Xd } xB | D]: \ } } | d j o
 d } q | d j o
 d } q q Wt | ƒ d j o t i | IJt i d ƒ n | d } t | | ƒ d	 GHd  S(
   NiÿÿÿÿsD   Usage: %s [-n | -t] url
    -n: open new window
    -t: open new tabi    i   t   ntds   -ns   -ti   s   (   t   getoptRE   t   argvRƒ   RW   t   exitt   lenR   (	   RÅ   t   usaget   optsR@   t   msgt   new_wint   ot   aR   (    (    s    /usr/lib/python2.5/webbrowser.pyt   mainz  s*    #  
 
t   __main__(   s   firefoxs   firebirds	   seamonkeys   mozillas   netscapes   opera(1   R?   R#   R   RE   R.   RG   R_   t   __all__t	   ExceptionR    R   R
   R   R   R   R   R   R   R   RF   R-   R"   t   objectR:   R   R   RT   Rn   t   NetscapeRo   Rp   Rq   Rr   Rx   R¦   R5   R­   R   R°   t   ImportErrorR¯   R³   R   R6   t   _userchoicest   reverseRM   RÏ   R   (    (    (    s    /usr/lib/python2.5/webbrowser.pys   <module>   s¤   		 			P95	3 0!	
 	