Ñò
mÈKc           @   s  d  Z  d d k Z d d k Z y d d k l Z Wn# e j
 o d d k l Z n Xd g Z d d d d d d „ Z d d d d d d „ Z	 d „  Z
 d „  Z e d	 „ Z d d e d
 „ Z e d j oF e e i ƒ d j  o e i d IJqe i d =e e i d ƒ n d S(   sZ  runpy.py - locating and running Python code using the module namespace

Provides support for locating and running Python scripts using the Python
module namespace instead of the native filesystem.

This allows Python code to play nicely with non-filesystem based PEP 302
importers when locating support scripts as well as when importing modules.
iÿÿÿÿN(   t
   get_loadert
   run_modulec      	   B   sL   | d j	 o | i | ƒ n | i d | d | d | d | ƒ |  | U| S(   s   Helper for _run_module_codet   __name__t   __file__t
   __loader__t   __package__N(   t   Nonet   update(   t   codet   run_globalst   init_globalst   mod_namet	   mod_fnamet
   mod_loadert   pkg_name(    (    s   /usr/lib/python2.6/runpy.pyt	   _run_code   s    c         C   sÃ   t  i | ƒ } | i } t i d } | t i j }	 |	 o t i | }
 n | t i d <| t i | <z  t |  | | | | | | ƒ Wd | t i d <|	 o |
 t i | <n t i | =X| i ƒ  S(   s   Helper for run_modulei    N(   t   impt
   new_modulet   __dict__t   syst   argvt   modulesR   t   copy(   R   R
   R   R   R   R   t   temp_modulet   mod_globalst   saved_argv0t   restore_modulet   saved_module(    (    s   /usr/lib/python2.6/runpy.pyt   _run_module_code%   s"    	c         C   s?   x8 d D]0 } t  |  | d  ƒ } | d  j	 o | | ƒ Sq Wd  S(   Nt   get_filenamet   _get_filename(   R   s   _get_filename(   t   getattrR   (   t   loaderR   t   attrt   meth(    (    s   /usr/lib/python2.6/runpy.pyR   F   s     c         C   s¡   t  |  ƒ } | d  j o t d |  ƒ ‚ n | i |  ƒ o t d d |  ƒ ‚ n | i |  ƒ } | d  j o t d |  ƒ ‚ n t | |  ƒ } | | | f S(   Ns   No module named %ss   %s is a package and cannot s   be directly executeds   No code object available for %s(   R    R   t   ImportErrort
   is_packaget   get_codeR   (   R   R    R   t   filename(    (    s   /usr/lib/python2.6/runpy.pyt   _get_module_detailsN   s    c   
      C   sÐ   y t  |  ƒ \ } } } Wn] t j
 oQ } | o t | ƒ } n d t i d } d t i | f } t i | ƒ n X|  i d ƒ d } t i d i	 }	 | o | t i d <n t
 | |	 d d | | | ƒ S(   sœ   Runs the designated module in the __main__ namespace

       These __*__ magic variables will be overwritten:
           __file__
           __loader__
    s   can't find '__main__.py' in %ri    s   %s: %st   .t   __main__N(   R'   R#   t   strR   R   t
   executablet   exitt
   rpartitionR   R   R   R   (
   R   t	   set_argv0R    R   t   fnamet   exct   infot   msgR   t   main_globals(    (    s   /usr/lib/python2.6/runpy.pyt   _run_module_as_main`   s    c         C   s€   t  |  ƒ \ } } } | d j o
 |  } n |  i d ƒ d } | o t | | | | | | ƒ St | h  | | | | | ƒ Sd S(   sn   Execute a module's code without importing it

       Returns the resulting top level namespace dictionary
    R(   i    N(   R'   R   R-   R   R   (   R   R
   t   run_namet	   alter_sysR    R   R/   R   (    (    s   /usr/lib/python2.6/runpy.pyR   |   s    
R)   i   s!   No module specified for executioni    (   t   __doc__R   R   R    R#   t   pkgutilt   __all__R   R   R   R   R'   t   TrueR4   t   FalseR   R   t   lenR   t   stderr(    (    (    s   /usr/lib/python2.6/runpy.pyt   <module>   s.   			
