;
Ęâ"Ic               @   s  d  Z  d d l Z d d l Z y d d l m Z Wn$ e k
 o d d l m Z Yn Xd g Z d d d d d d  Z d d d d d d  Z	 d   Z
 d   Z d d	  Z d d d d
  Z e d k oL e e j  d k  o e d d e j qe j d =e e j d  n d S(   uZ  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(   u
   get_loaderu
   run_modulec          	   C   sQ   | d k	 o | j |  n | j d | d | d | d |  t |  |  | S(   u   Helper for _run_module_codeu   __name__u   __file__u
   __loader__u   __package__N(   u   Noneu   updateu   exec(   u   codeu   run_globalsu   init_globalsu   mod_nameu	   mod_fnameu
   mod_loaderu   pkg_name(    (    u"   /mit/python/lib/python3.0/runpy.pyu	   _run_code   s    c             C   sÃ   t  j |  } | j } t j d } | t j k }	 |	 o t j | }
 n | t j d <| t j | <z  t |  | | | | | |  Wd | t j d <|	 o |
 t j | <n t j | =X| j   S(   u   Helper for run_modulei    N(   u   impu
   new_moduleu   __dict__u   sysu   argvu   modulesu	   _run_codeu   copy(   u   codeu   init_globalsu   mod_nameu	   mod_fnameu
   mod_loaderu   pkg_nameu   temp_moduleu   mod_globalsu   saved_argv0u   restore_moduleu   saved_module(    (    u"   /mit/python/lib/python3.0/runpy.pyu   _run_module_code%   s"    	c             C   s6   y |  j  } Wn t k
 o d  SYn X| |  Sd  S(   N(   u   get_filenameu   AttributeErroru   None(   u   loaderu   mod_nameu   get_filename(    (    u"   /mit/python/lib/python3.0/runpy.pyu   _get_filenameD   s
    
c             C   sĄ   t  |   } | d  k o t d |    n | j |   o t d d |    n | j |   } | d  k o t d |    n t | |   } | | | f S(   Nu   No module named %su   %s is a package and cannot u   be directly executedu   No code object available for %s(   u
   get_loaderu   Noneu   ImportErroru
   is_packageu   get_codeu   _get_filename(   u   mod_nameu   loaderu   codeu   filename(    (    u"   /mit/python/lib/python3.0/runpy.pyu   _get_module_detailsM   s    c       
      C   sâ   y t  |   \ } } } Wno t k
 oc } zM | o t |  } n d t j d } d t j | f } t j |  WYd d } ~ Xn X|  j d  d } t j d j	 }	 | o | t j d <n t
 | |	 d d | | |  S(   u   Runs the designated module in the __main__ namespace

       These __*__ magic variables will be overwritten:
           __file__
           __loader__
    u   can't find '__main__.py' in %ri    u   %s: %sNu   .u   __main__(   u   _get_module_detailsu   ImportErroru   stru   sysu   argvu
   executableu   exitu
   rpartitionu   modulesu   __dict__u	   _run_codeu   None(
   u   mod_nameu	   set_argv0u   loaderu   codeu   fnameu   excu   infou   msgu   pkg_nameu   main_globals(    (    u"   /mit/python/lib/python3.0/runpy.pyu   _run_module_as_main_   s    !c             C   s   t  |   \ } } } | d k o
 |  } n |  j d  d } | o t | | | | | |  St | i  | | | | |  Sd S(   un   Execute a module's code without importing it

       Returns the resulting top level namespace dictionary
    u   .i    N(   u   _get_module_detailsu   Noneu
   rpartitionu   _run_module_codeu	   _run_code(   u   mod_nameu   init_globalsu   run_nameu	   alter_sysu   loaderu   codeu   fnameu   pkg_name(    (    u"   /mit/python/lib/python3.0/runpy.pyu
   run_module{   s    
u   __main__i   u!   No module specified for executionu   fileTF(   u   __doc__u   sysu   impu
   get_loaderu   ImportErroru   pkgutilu   __all__u   Noneu	   _run_codeu   _run_module_codeu   _get_filenameu   _get_module_detailsu   Trueu   _run_module_as_mainu   Falseu
   run_moduleu   __name__u   lenu   argvu   printu   stderr(    (    (    u"   /mit/python/lib/python3.0/runpy.pyu   <module>   s.   				
