AlkantarClanX12

Your IP : 18.119.125.61


Current Path : /proc/thread-self/root/proc/self/root/lib64/python2.7/
Upload File :
Current File : //proc/thread-self/root/proc/self/root/lib64/python2.7/ihooks.pyc

�
zfc@s�dZddlmZmZeddd�[ddlZddlZddlZddlZddd	d
ddd
dgZdZ	ddlm
Z
mZmZddlm
Z
mZmZe
ZeZddd��YZdefd��YZdefd��YZd	efd��YZd
efd��YZdefd��YZdefd��YZdZdadd�Zd�ZdS(s,	Import hook support.

Consistent use of this module will make it possible to change the
different mechanisms involved in loading modules independently.

While the built-in module imp exports interfaces to the built-in
module searching and loading algorithm, and it is possible to replace
the built-in function __import__ in order to change the semantics of
the import statement, until now it has been difficult to combine the
effect of different __import__ hacks, like loading modules from URLs
by rimport.py, or restricted execution by rexec.py.

This module defines three new concepts:

1) A "file system hooks" class provides an interface to a filesystem.

One hooks class is defined (Hooks), which uses the interface provided
by standard modules os and os.path.  It should be used as the base
class for other hooks classes.

2) A "module loader" class provides an interface to search for a
module in a search path and to load it.  It defines a method which
searches for a module in a single directory; by overriding this method
one can redefine the details of the search.  If the directory is None,
built-in and frozen modules are searched instead.

Two module loader class are defined, both implementing the search
strategy used by the built-in __import__ function: ModuleLoader uses
the imp module's find_module interface, while HookableModuleLoader
uses a file system hooks class to interact with the file system.  Both
use the imp module's load_* interfaces to actually load the module.

3) A "module importer" class provides an interface to import a
module, as well as interfaces to reload and unload a module.  It also
provides interfaces to install and uninstall itself instead of the
default __import__ and reload (and unload) functions.

One module importer class is defined (ModuleImporter), which uses a
module loader instance passed in (by default HookableModuleLoader is
instantiated).

The classes defined here should be used as base classes for extended
functionality along those lines.

If a module importer class supports dotted names, its import_module()
must return a different value depending on whether it is called on
behalf of a "from ... import ..." statement or not.  (This is caused
by the way the __import__ hook is used by the Python interpreter.)  It
would also do wise to install a different version of reload().

i����(twarnpy3ktwarns0the ihooks module has been removed in Python 3.0t
stackleveliNtBasicModuleLoadertHookstModuleLoadertFancyModuleLoadertBasicModuleImportertModuleImportertinstallt	uninstalli(tC_EXTENSIONt	PY_SOURCEtPY_COMPILED(t	C_BUILTINt	PY_FROZENt
PKG_DIRECTORYt_VerbosecBs8eZed�Zd�Zd�Zd�Zd�ZRS(cCs
||_dS(N(tverbose(tselfR((s/usr/lib64/python2.7/ihooks.pyt__init__KscCs|jS(N(R(R((s/usr/lib64/python2.7/ihooks.pytget_verboseNscCs
||_dS(N(R(RR((s/usr/lib64/python2.7/ihooks.pytset_verboseQscGs|jr|j|�ndS(N(Rtmessage(Rtargs((s/usr/lib64/python2.7/ihooks.pytnoteVs	cGs|r||GHn|GHdS(N((RtformatR((s/usr/lib64/python2.7/ihooks.pyRZs(t__name__t
__module__tVERBOSERRRRR(((s/usr/lib64/python2.7/ihooks.pyRIs
			cBs>eZdZdd�Zd�Zd�Zd�Zd�ZRS(s;Basic module loader.

    This provides the same functionality as built-in import.  It
    doesn't deal with checking sys.modules -- all it provides is
    find_module() and a load_module(), as well as find_module_in_dir()
    which searches just one directory, and can be overridden by a
    derived class to change the module search algorithm when the basic
    dependency on sys.path is unchanged.

    The interface is a little more convenient than imp's:
    find_module(name, [path]) returns None or 'stuff', and
    load_module(name, stuff) loads the module.

    cCsS|dkr"dg|j�}nx*|D]"}|j||�}|r)|Sq)WdS(N(tNonetdefault_pathtfind_module_in_dir(Rtnametpathtdirtstuff((s/usr/lib64/python2.7/ihooks.pytfind_modulers
cCstjS(N(tsysR"(R((s/usr/lib64/python2.7/ihooks.pyRzscCsI|dkr|j|�Sytj||g�SWntk
rDdSXdS(N(Rtfind_builtin_moduletimpR%tImportError(RR!R#((s/usr/lib64/python2.7/ihooks.pyR }s

cCsNtj|�r%ddddtffStj|�rJddddtffSdS(Nt(R(t
is_builtinRtBUILTIN_MODULEt	is_frozent
FROZEN_MODULE(RR!((s/usr/lib64/python2.7/ihooks.pyR'�s
cCsD|\}}}ztj||||�SWd|r?|j�nXdS(N(R(tload_moduletclose(RR!R$tfiletfilenametinfo((s/usr/lib64/python2.7/ihooks.pyR/�s
N(	RRt__doc__RR%RR R'R/(((s/usr/lib64/python2.7/ihooks.pyRas				cBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	dd�Zdd	�Zdd
�Z
dd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZeZd�ZejZRS(s�Hooks into the filesystem and interpreter.

    By deriving a subclass you can redefine your filesystem interface,
    e.g. to merge it with the URL space.

    This base class behaves just like the native filesystem.

    cCs
tj�S(N(R(tget_suffixes(R((s/usr/lib64/python2.7/ihooks.pyR5�R*cCs
tj|�S(N(R(t
new_module(RR!((s/usr/lib64/python2.7/ihooks.pyR6�R*cCs
tj|�S(N(R(R+(RR!((s/usr/lib64/python2.7/ihooks.pyR+�R*cCs
tj|�S(N(R(tinit_builtin(RR!((s/usr/lib64/python2.7/ihooks.pyR7�R*cCs
tj|�S(N(R(R-(RR!((s/usr/lib64/python2.7/ihooks.pyR-�R*cCs
tj|�S(N(R(tinit_frozen(RR!((s/usr/lib64/python2.7/ihooks.pyR8�R*cCs
tj|�S(N(R(tget_frozen_object(RR!((s/usr/lib64/python2.7/ihooks.pyR9�R*cCstj|||�S(N(R(tload_source(RR!R2R1((s/usr/lib64/python2.7/ihooks.pyR:�scCstj|||�S(N(R(t
load_compiled(RR!R2R1((s/usr/lib64/python2.7/ihooks.pyR;�scCstj|||�S(N(R(tload_dynamic(RR!R2R1((s/usr/lib64/python2.7/ihooks.pyR<�scCstj|||ddtf�S(NR*(R(R/R(RR!R2R1((s/usr/lib64/python2.7/ihooks.pytload_package�scCs;|j�}||kr ||S|j|�||<}|S(N(tmodules_dictR6(RR!tdtm((s/usr/lib64/python2.7/ihooks.pyt
add_module�s
cCstjS(N(R&tmodules(R((s/usr/lib64/python2.7/ihooks.pyR>�R*cCstjS(N(R&R"(R((s/usr/lib64/python2.7/ihooks.pyR�R*cCstjj|�S(N(tosR"tsplit(Rtx((s/usr/lib64/python2.7/ihooks.pyt
path_split�R*cCstjj||�S(N(RCR"tjoin(RREty((s/usr/lib64/python2.7/ihooks.pyt	path_join�R*cCstjj|�S(N(RCR"tisabs(RRE((s/usr/lib64/python2.7/ihooks.pyt
path_isabs�R*cCstjj|�S(N(RCR"texists(RRE((s/usr/lib64/python2.7/ihooks.pytpath_exists�R*cCstjj|�S(N(RCR"tisdir(RRE((s/usr/lib64/python2.7/ihooks.pyt
path_isdir�R*cCstjj|�S(N(RCR"tisfile(RRE((s/usr/lib64/python2.7/ihooks.pytpath_isfile�R*cCstjj|�S(N(RCR"tislink(RRE((s/usr/lib64/python2.7/ihooks.pytpath_islink�R*cGs
t|�S(N(topen(RRE((s/usr/lib64/python2.7/ihooks.pytopenfile�R*cCs
tj|�S(N(RCtlistdir(RRE((s/usr/lib64/python2.7/ihooks.pyRV�R*N( RRR4R5R6R+R7R-R8R9RR:R;R<R=RAR>RRFRIRKRMRORQRSRUtIOErrortopenfile_errorRVRCterrort
listdir_error(((s/usr/lib64/python2.7/ihooks.pyR�s4																				cBs_eZdZd
ed�Zd�Zd�Zd�Zd�Z	d�Z
dd�Zd	�ZRS(s�Default module loader; uses file system hooks.

    By defining suitable hooks, you might be able to load modules from
    other sources than the file system, e.g. from compressed or
    encrypted files, tar files or (if you're brave!) URLs.

    cCs)tj||�|pt|�|_dS(N(RRRthooks(RR[R((s/usr/lib64/python2.7/ihooks.pyR�scCs
|jj�S(N(R[R(R((s/usr/lib64/python2.7/ihooks.pyR�scCs
|jj�S(N(R[R>(R((s/usr/lib64/python2.7/ihooks.pyR>�scCs|jS(N(R[(R((s/usr/lib64/python2.7/ihooks.pyt	get_hooks�scCs
||_dS(N(R[(RR[((s/usr/lib64/python2.7/ihooks.pyt	set_hooks�scCsT|jj|�r(ddddtffS|jj|�rPddddtffSdS(NR*(R[R+RR,R-R.(RR!((s/usr/lib64/python2.7/ihooks.pyR'�s
icCs |dkr|j|�S|r�|jj||�}|jj|�r�|jd|d�}|r�|d}|r~|j�nd|ddtffSq�nx|jj�D]n}|\}}	}
|jj|||�}y&|jj	||	�}|||fSWq�|jj
k
rq�Xq�WdS(NRiR*(RR'R[RIROR R0RR5RURX(RR!R#tallow_packagestfullnameR$R1R3tsufftmodettypetfp((s/usr/lib64/python2.7/ihooks.pyR �s(


c
Cs-|\}}}|\}}}z�|tkr=|jj|�S|tkrY|jj|�S|tkr�|jj|||�}	n�|tkr�|jj|||�}	na|t	kr�|jj
|||�}	n:|tkr�|jj|||�}	nt
d||f�Wd|r|j�nX||	_|	S(Ns$Unrecognized module type (%r) for %s(R,R[R7R.R8RR<RR:R
R;RR=R)R0t__file__(
RR!R$R1R2R3R`RaRbR@((s/usr/lib64/python2.7/ihooks.pyR/s*	N(
RRR4RRRRR>R\R]R'R R/(((s/usr/lib64/python2.7/ihooks.pyR�s					cBseZdZd�ZRS(s8Fancy module loader -- parses and execs the code itself.cBs�|\}}\}}}|}d}	|ekr�|jd|d�}
|
s[ed|�n|
\}}}
|
\}}}|eefkr�|r�|j�ned||f�n|g}	|}|}|}n|ekr�|jj	|�}nw|ekr*ddl
}|jd�|j|�}n@|ekrW|j
�}e||d�}nej|||�S|jj|�}|	r�|	|_n||_y||jUWn/|jj�}||kr�||=n�nX|S(NRis No __init__ module in package %ss/Bad type (%r) for __init__ module in package %si����itexec(RRR R)R
RR0R.R[R9tmarshaltseektloadtreadtcompileRR/RAt__path__Rdt__dict__R>(RR!R$R1R2R`RaRbtrealfilenameR"t	initstufftinitfiletinitfilenametinitinfotinitsufftinitmodetinittypetcodeRftdataR@R?((s/usr/lib64/python2.7/ihooks.pyR/"sR
		
	
(RRR4R/(((s/usr/lib64/python2.7/ihooks.pyRscBszeZdZded�Zd�Zd�Zd�Zd�Z	iigd�Z
dd�Zd�Zd	�Z
d
�ZRS(ssBasic module importer; uses module loader.

    This provides basic import facilities but no package imports.

    cCs>tj||�|p"td|�|_|jj�|_dS(N(RRRRtloaderR>RB(RRwR((s/usr/lib64/python2.7/ihooks.pyRYscCs|jS(N(Rw(R((s/usr/lib64/python2.7/ihooks.pyt
get_loader^scCs
||_dS(N(Rw(RRw((s/usr/lib64/python2.7/ihooks.pyt
set_loaderascCs
|jj�S(N(RwR\(R((s/usr/lib64/python2.7/ihooks.pyR\dscCs|jj|�S(N(RwR](RR[((s/usr/lib64/python2.7/ihooks.pyR]gscCsat|�}||jkr&|j|S|jj|�}|sNtd|�n|jj||�S(NsNo module named %s(tstrRBRwR%R)R/(RR!tglobalstlocalstfromlistR$((s/usr/lib64/python2.7/ihooks.pyt
import_modulejscCsMt|j�}|jj||�}|s:td|�n|jj||�S(NsModule %s not found for reload(RzRRwR%R)R/(RtmoduleR"R!R$((s/usr/lib64/python2.7/ihooks.pytreloadss
cCs|jt|j�=dS(N(RBRzR(RR((s/usr/lib64/python2.7/ihooks.pytunloadzscCsgtj|_tj|_ttd�s3dt_ntj|_|j	t_|jt_|jt_dS(NR�(
t__builtin__t
__import__tsave_import_moduleR�tsave_reloadthasattrRR�tsave_unloadR~(R((s/usr/lib64/python2.7/ihooks.pyR	~scCs:|jt_|jt_|jt_tjs6t`ndS(N(R�R�R�R�R�R�R�(R((s/usr/lib64/python2.7/ihooks.pyR
�s
	N(RRR4RRRRxRyR\R]R~R�R�R	R
(((s/usr/lib64/python2.7/ihooks.pyRQs							
cBsbeZdZd
d
d
dd�Zdd�Zd�Zd�Zdd�Zdd�Z	d	�Z
RS(s)A module importer that supports packages.i����c
Csr|j||�}|j|t|��\}}|j||�}	|sL|St|	d�rn|j|	|�n|	S(NRk(tdetermine_parenttfind_head_packageRzt	load_tailR�tensure_fromlist(
RR!R{R|R}tleveltparenttqttailR@((s/usr/lib64/python2.7/ihooks.pyR~�scCs�|s|rdS|jd�}|dk	rO|r�|dkr�td�q�n�|jd�}|dkrndSd|kr�|}nEd|kr�|dkr�td�nd|d<dS|jd�d}||d<|dkrMt|�}xSt|dd�D]?}y|jdd|�}Wq�tk
r;td	��q�Xq�W|| }nytj|SWnBt	k
r�|dkr�t
d
|td�dStd|�nXdS(Nt__package__is(Attempted relative import in non-packageRRkt.ii����s2attempted relative import beyond top-level packages;Parent module '%s' not found while handling absolute imports=Parent module '%s' not loaded, cannot perform relative import(
Rtgett
ValueErrort
rpartitiontlentrangetrindexR&RBtKeyErrorRtRuntimeWarningtSystemError(RR{R�tpkgnametmodnametdotRE((s/usr/lib64/python2.7/ihooks.pyR��sF	




cCs�d|kr6|jd�}|| }||d}n|}d}|r^d|j|f}n|}|j|||�}|r�||fS|r�|}d}|j|||�}|r�||fSntd|�dS(NR�iR*s%s.%ssNo module named '%s'(tfindRt	import_itRR)(RR�R!titheadR�tqnameR�((s/usr/lib64/python2.7/ihooks.pyR��s&


cCs�|}x�|r�|jd�}|dkr9t|�}n|| ||d}}d|j|f}|j|||�}|s	td|�q	q	W|S(NR�iis%s.%ssNo module named '%s'(R�R�RR�R)(RR�R�R@R�R�tmname((s/usr/lib64/python2.7/ihooks.pyR��s	icCs�x�|D]�}|dkr\|sy
|j}Wntk
r?qVX|j||d�qqn|dkrt||�rd|j|f}|j|||�}|s�td|�q�qqWdS(Nt*is%s.%ssNo module named '%s'(t__all__tAttributeErrorR�R�RR�R)(RR@R}t	recursivetsubtalltsubnametsubmod((s/usr/lib64/python2.7/ihooks.pyR��s


cCs�|s
|S|s6y|j|SWq6tk
r2q6Xny|oE|j}Wntk
r]dSXt|�}|jj||�}|s�dSt|�}|jj||�}|r�t	|||�n|S(N(
RBR�RkR�RRzRwR%R/tsetattr(RtpartnametfqnameR�t
force_loadR"R$R@((s/usr/lib64/python2.7/ihooks.pyR��s(

cCs{t|j�}d|kr4|j||ddd�S|jd�}|| }|j|}|j||d||dd�S(NR�R�i(RzRR�RtrfindRB(RRR!R�tpnameR�((s/usr/lib64/python2.7/ihooks.pyR�s

N(RRR4RR~R�R�R�R�R�R�(((s/usr/lib64/python2.7/ihooks.pyR�s	
-		cCs#|ptpt�atj�dS(N(tdefault_importerRtcurrent_importerR	(timporter((s/usr/lib64/python2.7/ihooks.pyR	#scCstj�dS(N(R�R
(((s/usr/lib64/python2.7/ihooks.pyR
(s((R4twarningsRRR�R(RCR&R�RRRR
RRRR,R.RRRRRRRRR�R�R	R
(((s/usr/lib64/python2.7/ihooks.pyt<module>3s258P3?�