
    "e                     T    d Z ddlZddlZddlmZ  G d d      Zdadad Zd Z	d	dZ
y)
aB  
The UserModuleDeleter and runfile methods are copied from
Spyder and carry their own license agreement.
http://code.google.com/p/spyderlib/source/browse/spyderlib/widgets/externalshell/sitecustomize.py

Spyder License Agreement (MIT License)
--------------------------------------

Copyright (c) 2009-2012 Pierre Raybaut

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
    N)execfilec                   &    e Zd ZdZddZd ZddZy)UserModuleDeleterz
    User Module Deleter (UMD) aims at deleting user modules
    to force Python to deeply reload them during import

    pathlist [list]: ignore list in terms of module path
    namelist [list]: ignore list in terms of module name
    Nc                 ,   |g }|| _         |g }|| _        	 dd l}dd l}| j                  j	                  t
        j                  j                  |j                               t        t        j                  j                               | _        y #  Y 1xY w)Nr   )namelistpathlistpydev_pysrcinspectappendospathdirname__file__listsysmoduleskeysprevious_modules)selfr   r   r	   r
   s        9/usr/lib/python3/dist-packages/_pydev_bundle/pydev_umd.py__init__zUserModuleDeleter.__init__1   sy    H H 	'MM  1E1E!FG !%S[[%5%5%7 8	s   A
B Bc                     t         j                  g| j                  z   D ]  }|j                  |      s y t	        |j                  d            t	        | j                        z  S )NT.)r   prefixr   
startswithsetsplitr   )r   modnamemodpathr   s       r   is_module_ignoredz#UserModuleDeleter.is_module_ignored@   sW    ZZL4==0 	@D!!$'	@ w}}S)*S-???    c           	         g }t        t        j                        }|j                         D ]  \  }}|dk(  r!t	        ||       t	        | j
                         || j
                  vs;t        |dd      }|K| j                  ||      r^|j                  |       t        j                  |=  |r(|r%t	        dddddj                  |      z   d	       yyy)
z
        Del user modules to force Python to deeply reload them

        Do not del modules which are considered as system modules, i.e.
        modules installed in subdirectories of Python interpreter's binary
        Do not del C modules
        aaaaar   Nz[4;33mzUMD has deletedz[24mz: z, z[0m)
dictr   r   itemsprintr   getattrr    r   join)r   verboselogmodules_copyr   moduler   s          r   runzUserModuleDeleter.runG   s     CKK(+113 	-OGV'!gv&d++,d333!&*d;? --gw?JJw'G,	- s5F59DIIcN5JL M 7r!   )NN)F)__name__
__module____qualname____doc__r   r    r-    r!   r   r   r   (   s    9@Mr!   r   c                     | a y )N)_get_globals_callback)get_globalss    r   _set_globals_functionr6   i   s    'r!   c                      t         
t               S 	 ddlm}  | j	                  d      }|t        |d      r|j                  S | S # t        $ r 	 ddl}|j                  } n	#    Y nxY wY Sw xY w)z3Return current Python interpreter globals namespaceNr   )__dict____ipythonshell__user_ns)r4   __main__r8   ImportErrorgethasattrr:   )	namespacer;   shells      r   _get_globalsrA   n   sy    ($&&	6 01	!:==    	$--		s)   A 	A,A A, A&$A,+A,c                    	 t        | d      r| j                  d      } t        j
                  j                  dd      j                         dk(  rt        @t        j
                  j                  dd      }||j                  d      }t        |	      anGt        j
                  j                  d
d      j                         dk(  }t        j                  |       |!t        |t        t        f      st        d      |
t               }d|v r|d   }nd}| |d<   | gt         _        |4|j                         D ]!  }t         j"                  j%                  |       # |3	 t        |d      r|j                  d      }t	        j&                  |       t)        | |       dgt         _        ||d= y||d<   y# t        t        f$ r Y w xY w# t        t        f$ r Y `w xY w)z\
    Run filename
    args: command line arguments (string)
    wdir: working directory
    decodezutf-8PYDEV_UMD_ENABLED trueNPYDEV_UMD_NAMELIST,)r   PYDEV_UMD_VERBOSE)r)   z"expected a character buffer objectr   )r>   rC   UnicodeError	TypeErrorr   environr=   lower__umd__r   r   r-   
isinstancebytesstrrA   r   argvr   chdirr   )filenameargswdirr?   r   r)   old_fileargs           r   runfilerY      s   8X&w/H 
zz~~)2.446&@?zz~~&:DAH##>>#.':Gjjnn%8"=CCEOGKKK(
4% ><== N	YZ($IjzCH::< 	!CHHOOC 	!	tX&{{7+ 	Xy!tCHj! (	*K )$ : i( 		s#   F8 "G 8G
GG G )NNN)r1   r   r   _pydev_bundle._pydev_execfiler   r   rN   r4   r6   rA   rY   r2   r!   r   <module>r[      s?   @  	 2
9M 9Mx  (
0.)r!   