mň
­fIc           @   s  d  Z  d k Z d k Z d k Z d   Z d   Z d   Z d   Z d   Z d   Z	 d d  Z d	   Z d
   Z d   Z d e f d     YZ d   Z d e f d     YZ d   Z d   Z d   Z d   Z d   Z e   d   Z e d j o e   n d S(   s@	  Append module search paths for third-party packages to sys.path.

****************************************************************
* This module is automatically imported during initialization. *
****************************************************************

In earlier versions of Python (up to 1.5a3), scripts or modules that
needed to use site-specific modules would place ``import site''
somewhere near the top of their code.  Because of the automatic
import, this is no longer necessary (but code that does it still
works).

This will append site-specific paths to the module search path.  On
Unix, it starts with sys.prefix and sys.exec_prefix (if different) and
appends lib/python<version>/site-packages as well as lib/site-python.
On other platforms (mainly Mac and Windows), it uses just sys.prefix
(and sys.exec_prefix, if different, but this is unlikely).  The
resulting directories, if they exist, are appended to sys.path, and
also inspected for path configuration files.

A path configuration file is a file whose name has the form
<package>.pth; its contents are additional directories (one per line)
to be added to sys.path.  Non-existing directories (or
non-directories) are never added to sys.path; no directory is added to
sys.path more than once.  Blank lines and lines beginning with
'#' are skipped. Lines starting with 'import' are executed.

For example, suppose sys.prefix and sys.exec_prefix are set to
/usr/local and there is a directory /usr/local/lib/python1.5/site-packages
with three subdirectories, foo, bar and spam, and two path
configuration files, foo.pth and bar.pth.  Assume foo.pth contains the
following:

  # foo package configuration
  foo
  bar
  bletch

and bar.pth contains:

  # bar package configuration
  bar

Then the following directories are added to sys.path, in this order:

  /usr/local/lib/python1.5/site-packages/bar
  /usr/local/lib/python1.5/site-packages/foo

Note that bletch is omitted because it doesn't exist; bar precedes foo
because bar.pth comes alphabetically before foo.pth; and spam is
omitted because it is not mentioned in either path configuration file.

After these path manipulations, an attempt is made to import a module
named sitecustomize, which can perform arbitrary additional
site-specific customizations.  If this import fails with an
ImportError exception, it is silently ignored.

Nc          G   s4   t  i i t  i i |     } | t  i i |  f S(   N(   t   ost   patht   abspatht   joint   pathst   dirt   normcase(   R   R   (    (    t!   /mit/python/lib/python2.4/site.pyt   makepathA   s    c          C   sS   xL t  i i   D]; }  y t i i |  i  |  _ Wq t j
 o
 q q Xq Wd S(   s6   Set all module' __file__ attribute to an absolute pathN(	   t   syst   modulest   valuest   mR    R   R   t   __file__t   AttributeError(   R   (    (    R   t   abs__file__E   s      c          C   sn   g  } t   }  xN t i D]C } t |  \ } } | |  j o | i |  |  i	 |  q q W| t i (|  S(   sK    Remove duplicate entries from sys.path along with making them
    absoluteN(
   t   Lt   sett   known_pathsR	   R   R   R   t   dircaset   appendt   add(   R   R   R   R   (    (    R   t   removeduppathsM   s     	
 
c          C   s_   d k  l } d |   t i f }  t i i t i i t i d  |   }  t i i	 |   d S(   sb   Append ./build/lib.<platform> in case we're running in the build dir
    (especially for Guido :-)(   s   get_platforms   build/lib.%s-%.3si˙˙˙˙N(
   t   distutils.utilt   get_platformR	   t   versiont   sR    R   R   t   dirnameR   (   R   R   (    (    R   t   addbuilddira   s
     (c          C   st   t    }  xd t i D]Y } y: t i i |  o# t |  \ } } |  i	 |  n Wq t
 j
 o
 q q Xq W|  S(   sD   Return a set containing all existing directory entries from sys.pathN(   R   t   dR	   R   R   R    t   isdirR   R   R   t	   TypeError(   R   R   R   (    (    R   t   _init_pathinfoi   s     	
 c   	      B   s6  | d j o e   d } n d } e i i |  |  } y e
 | d  } Wn e j
 o d Sn Xz­ xŚ | D] } | i d  o qp n | i d  o | d Uqp n | i   } e |  |  \ } } | | j o4 e i i |  o! e i i |  | i |  qp qp WWd | i   X| o
 d } n | S(   so   Add a new path to known_paths by combining sitedir and 'name' or execute
    sitedir if it starts with 'import'i   i    t   rUNt   #t   import(   R   t   NoneR    t   resetR    R   R   t   sitedirt   namet   fullnamet   opent   ft   IOErrort   linet
   startswitht   rstripR   R   R   t   existsR	   R   R   t   close(	   R&   R'   R   R%   R*   R   R(   R,   R   (    (    R   t
   addpackageu   s8     
	   
c         C   sä   | d j o t   } d } n d } t |   \ }  } | | j o t i i	 |   n y t
 i |   } Wn t
 i j
 o d Sn X| i   x9 | D]1 } | i t
 i d  o t |  | |  q q W| o
 d } n | S(   sT   Add 'sitedir' argument to sys.path if missing and handle .pth files in
    'sitedir'i   i    Nt   pth(   R   R$   R    R%   R   R&   t   sitedircaseR	   R   R   R    t   listdirt   namest   errort   sortR'   t   endswitht   extsepR1   (   R&   R   R%   R'   R5   R3   (    (    R   t
   addsitedir   s(     	
	
 
c         C   s  t  i g } t  i t  i j o | i t  i  n x[| D]S} | oFt  i d j o t i i | d d  g } nq t i
 d j oB t i i | d d t  i d  d  t i i | d d	  g } n | t i i | d d  g } t  i d
 j o^ d | j oM t i i d  } | o0 | i t i i | d d t  i d  d   qPqTn x6 | D]* } t i i |  o t | |   q[q[Wq: q: Wd S(   s8   Add site-packages (and possibly site-python) to sys.patht   os2emxt   riscost   Libs   site-packagest   /t   libt   pythoni   s   site-pythont   darwins   Python.frameworkt   HOMEt   Libraryt   PythonN(   s   os2emxs   riscos(   R	   t   prefixt   prefixest   exec_prefixR   t   platformR    R   R   t   sitedirst   sepR   t   environt   gett   homeR&   R   R:   R   R$   (   R   R&   RF   RI   RE   RM   (    (    R   t   addsitepackagesŤ   s:      %
 c          C   sq   t  i i t i d d  }  t  i d i d  } | d o | i	 |   n |  | d <d i |  t  i d <d S(   sE  The OS/2 EMX port has optional extension modules that do double duty
    as DLLs (and must use the .DLL file extension) for other extensions.
    The library search path needs to be amended so these will be found
    during module import.  Use BEGINLIBPATH so that these are at the start
    of the library search path.

    R=   s   lib-dynloadt   BEGINLIBPATHt   ;i˙˙˙˙N(
   R    R   R   R	   RE   t   dllpathRK   t   splitt   libpathR   (   RQ   RS   (    (    R   t   setBEGINLIBPATHĎ   s     
c          C   sN   t  i d j o
 d }  n! t  i d j o
 d }  n d }  |  t _ t _ d S(   sn   Define new built-ins 'quit' and 'exit'.
    These are simply strings that display a hint on how to exit.

    t   :s   Use Cmd-Q to quit.s   \s   Use Ctrl-Z plus Return to exit.s   Use Ctrl-D (i.e. EOF) to exit.N(   R    RJ   t   exitt   __builtin__t   quit(   RV   (    (    R   t   setquitŕ   s     

t   _Printerc           B   s>   t  Z d  Z d Z f  f  d  Z d   Z d   Z d   Z RS(   sn   interactive prompt objects for printing the license text, a list of
    contributors and the copyright notice.i   c         C   s1   | |  _ | |  _ | |  _ | |  _ d  |  _
 d  S(   N(   R'   t   selft   _Printer__namet   datat   _Printer__datat   filest   _Printer__filest   dirst   _Printer__dirsR$   t   _Printer__lines(   R[   R'   R]   R_   Ra   (    (    R   t   __init__ô   s
    				c         C   sÝ   |  i o d  Sn d  } x |  i D]{ } xf |  i D][ } t i	 i
 | |  } y* t | d  } | i   } | i   PWq2 t j
 o q2 Xq2 W| o Pq" q" W| p |  i } n | i d  |  _ t |  i  |  _ d  S(   NR!   s   
(   R[   Rc   R$   R]   Rb   R   R`   t   filenameR    R   R   t   filet   fpt   readR0   R+   R^   RR   t   lent   _Printer__linecnt(   R[   Rg   R]   Re   R   (    (    R   t   __setupű   s*    

 
 
		c         C   sM   |  i   t |  i  |  i j o d i |  i  Sn d |  i f d Sd  S(   Ns   
s!   Type %s() to see the full %s texti   (   R[   t   _Printer__setupRi   Rc   t   MAXLINESR   R\   (   R[   (    (    R   t   __repr__  s    
c         C   sÇ   |  i   d } d } xŞ y1 x* t | | |  i  D] } |  i | GHq3 WWn t j
 o Pq X| |  i 7} d  } x5 | d  j o' t |  } | d j o
 d  } qw qw W| d j o Pq q Wd  S(   Ns0   Hit Return for more, or q (and Return) to quit: i    i   t    t   q(   Ro   Rp   (   R[   Rl   t   promptt   linenot   rangeRm   t   iRc   t
   IndexErrorR$   t   keyt	   raw_input(   R[   Rt   Rr   Rv   Rq   (    (    R   t   __call__  s(    
    (   t   __name__t
   __module__t   __doc__Rm   Rd   Rl   Rn   Rx   (    (    (    R   RZ   î   s    		c          C   s­   t  d t i  t _ t i d  d j o t  d d  t _ n t  d d  t _ t i i t i	  }  t  d d t i d	 d
 g t i i |  t i  |  t i g  t _ d S(   s,   Set 'copyright' and 'credits' in __builtin__t	   copyrighti   t   javat   creditss?   Jython is maintained by the Jython developers (www.jython.org).s       Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
    for supporting Python development.  See www.python.org for more information.t   licenses+   See http://www.python.org/%.3s/license.htmls   LICENSE.txtt   LICENSEN(   RZ   R	   R|   RW   RH   R~   R    R   R   R   t   hereR   R   t   pardirt   curdirR   (   R   (    (    R   t   setcopyright+  s     	t   _Helperc           B   s    t  Z d  Z d   Z d   Z RS(   sY   Define the built-in 'help'.
    This is a wrapper around pydoc.help (with a twist).

    c         C   s   d S(   NsH   Type help() for interactive help, or help(object) for help about object.(    (   R[   (    (    R   Rn   C  s    c         O   s   d  k  } | i | |   S(   N(   t   pydoct   helpt   argst   kwds(   R[   R   R   R   (    (    R   Rx   F  s    	(   Ry   Rz   R{   Rn   Rx   (    (    (    R   R   =  s    	c           C   s   t    t _ d  S(   N(   R   RW   R   (    (    (    R   t	   sethelperJ  s    c          C   s   t  i d j o d k } d k } | i   d }  |  i d  oT y | i |   Wq t j
 o0 d k	 } | i
 | i |  <d | i i |  <q Xq n d S(   sˇ   On Windows, some default encodings are not provided by Python,
    while they are always available as "mbcs" in each locale. Make
    them usable by aliasing to "mbcs" in such a case.t   win32Ni   t   cpt   mbcs(   R	   RH   t   localet   codecst   getdefaultlocalet   encR-   t   lookupt   LookupErrort	   encodingst   _unknownt   _cachet   aliases(   R   R   R   R   (    (    R   t	   aliasmbcsM  s     	c          C   s(   d }  |  d j o t i |   n d S(   s   Set the string encoding used by the Unicode implementation.  The
    default is 'ascii', but if you're willing to experiment, you can
    change this.t   asciiN(   t   encodingR	   t   setdefaultencoding(   R   (    (    R   t   setencoding\  s       c          C   s'   y d k  }  Wn t j
 o n Xd S(   s,   Run custom site specific code, if available.N(   t   sitecustomizet   ImportError(   R   (    (    R   t   execsitecustomizep  s
     c          C   sÄ   t    t   }  t i d j o5 t i o+ t i i t i d  d j o t   n t	 |   }  t i
 d j o t   n t   t   t   t   t   t   t t d  o
 t ` n d  S(   Nt   posixi˙˙˙˙t   ModulesR;   R   (   R   R   t   paths_in_sysR    R'   R	   R   t   basenameR   RN   RH   RT   RY   R   R   R   R   R   t   hasattrR   (   R˘   (    (    R   t   mainx  s    	:c          C   s.   d GHx t  i D] }  d |  f GHq Wd GHd  S(   Ns   sys.path = [s       %r,t   ](   R	   R   R   (   R   (    (    R   t   _test  s
    
 t   __main__(   R{   R	   R    RW   R   R   R   R   R    R1   R$   R:   RN   RT   RY   t   objectRZ   R   R   R   R   R   R   RĽ   R§   Ry   (   R   R   R   RW   R:   R1   RY   R   RN   RZ   RT   R    R   RĽ   R§   R   R   R   R	   R   R   R    (    (    R   t   ?:   s2   										$		=							