ronnie
2022-10-14 1504bb53e29d3d46222c0b3ea994fc494b48e153
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
L\¬Qc@sƒdZddlmZmZedddƒ[ddlZddlZddlZddlZddd    d
d d d dgZdZ    ddlm
Z
m Z m Z ddlm Z mZmZe ZeZddd„ƒYZdefd„ƒYZdefd„ƒYZd    efd„ƒYZd
efd„ƒYZd efd„ƒ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(t C_EXTENSIONt    PY_SOURCEt PY_COMPILED(t    C_BUILTINt    PY_FROZENt PKG_DIRECTORYt_VerbosecBs8eZed„Zd„Zd„Zd„Zd„ZRS(cCs ||_dS(N(tverbose(tselfR((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt__init__KscCs|jS(N(R(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt get_verboseNscCs ||_dS(N(R(RR((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt set_verboseQscGs|jr|j|ŒndS(N(Rtmessage(Rtargs((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pytnoteVs    cGs|r||GHn|GHdS(N((RtformatR((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyRZs (t__name__t
__module__tVERBOSERRRRR(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt find_modulers  cCstjS(N(tsysR"(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyRzscCsI|dkr|j|ƒSytj||gƒSWntk
rDdSXdS(N(Rtfind_builtin_moduletimpR%t ImportError(RR!R#((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR }s    cCsNtj|ƒr%ddddtffStj|ƒrJddddtffSdS(Nt(R(t
is_builtinRtBUILTIN_MODULEt    is_frozent FROZEN_MODULE(RR!((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR'†s
cCsD|\}}}ztj||||ƒSWd|r?|jƒnXdS(N(R(t load_moduletclose(RR!R$tfiletfilenametinfo((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR/Žs
N(    RRt__doc__RR%RR R'R/(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyRas                  cBsøeZdZd„Zd„Zd„Zd„Zd„Zd„Zd„Z    dd„Z dd    „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((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR5¢scCs tj|ƒS(N(R(t
new_module(RR!((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR6£scCs tj|ƒS(N(R(R+(RR!((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR+¤scCs tj|ƒS(N(R(t init_builtin(RR!((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR7¥scCs tj|ƒS(N(R(R-(RR!((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR-¦scCs tj|ƒS(N(R(t init_frozen(RR!((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR8§scCs tj|ƒS(N(R(tget_frozen_object(RR!((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR9¨scCstj|||ƒS(N(R(t load_source(RR!R2R1((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR:©scCstj|||ƒS(N(R(t load_compiled(RR!R2R1((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR;«scCstj|||ƒS(N(R(t load_dynamic(RR!R2R1((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR<­scCstj|||ddtfƒS(NR*(R(R/R(RR!R2R1((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt load_package¯scCs;|jƒ}||kr ||S|j|ƒ||<}|S(N(t modules_dictR6(RR!tdtm((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt
add_module²s
  cCstjS(N(R&tmodules(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR>¹scCstjS(N(R&R"(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyRºscCstjj|ƒS(N(tosR"tsplit(Rtx((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt
path_split¼scCstjj||ƒS(N(RCR"tjoin(RREty((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt    path_join½scCstjj|ƒS(N(RCR"tisabs(RRE((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt
path_isabs¾scCstjj|ƒS(N(RCR"texists(RRE((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt path_existsÁscCstjj|ƒS(N(RCR"tisdir(RRE((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt
path_isdirÂscCstjj|ƒS(N(RCR"tisfile(RRE((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt path_isfileÃscCstjj|ƒS(N(RCR"tislink(RRE((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt path_islinkÄscGs
t|ŒS(N(topen(RRE((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pytopenfileÇscCs tj|ƒS(N(RCtlistdir(RRE((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyRVÉsN( RRR4R5R6R+R7R-R8R9RR:R;R<R=RAR>RRFRIRKRMRORQRSRUtIOErrortopenfile_errorRVRCterrort listdir_error(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR–s4                                                                                    cBs_eZdZd
ed„Zd„Zd„Zd„Zd„Z    d„Z
dd„Z d    „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((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyRØscCs |jjƒS(N(R[R(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyRÜscCs |jjƒS(N(R[R>(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR>ßscCs|jS(N(R[(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt    get_hooksâscCs ||_dS(N(R[(RR[((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt    set_hooksåscCsT|jj|ƒr(ddddtffS|jj|ƒrPddddtffSdS(NR*(R[R+RR,R-R.(RR!((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR ðs(  
 c
Cs-|\}}}|\}}}zë|tkr=|jj|ƒS|tkrY|jj|ƒS|tkr€|jj|||ƒ}    nˆ|tkr§|jj|||ƒ}    na|t    krÎ|jj
|||ƒ}    n:|t krõ|jj |||ƒ}    nt d||f‚Wd|r|jƒnX||    _|    S(Ns$Unrecognized module type (%r) for %s(R,R[R7R.R8R R<R R:R R;RR=R)R0t__file__(
RR!R$R1R2R3R`RaRbR@((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR/s*          N( RRR4RRRRR>R\R]R'R R/(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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
}|j dƒ|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?((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR/"sR                      
(RRR4R/(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyRscBszeZdZd ed„Zd„Zd„Zd„Zd„Z    iigd„Z
d d„Z d„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((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyRYscCs|jS(N(Rw(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt
get_loader^scCs ||_dS(N(Rw(RRw((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt
set_loaderascCs |jjƒS(N(RwR\(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR\dscCs|jj|ƒS(N(RwR](RR[((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR]gscCsat|ƒ}||jkr&|j|S|jj|ƒ}|sNtd|‚n|jj||ƒS(NsNo module named %s(tstrRBRwR%R)R/(RR!tglobalstlocalstfromlistR$((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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$((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pytreloadss
cCs|jt|jƒ=dS(N(RBRzR(RR((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pytunloadzscCsgtj|_tj|_ttdƒs3dt_ntj|_|j    t_|jt_|jt_dS(NR(
t __builtin__t
__import__tsave_import_moduleR€t save_reloadthasattrRRt save_unloadR~(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR    ~s      cCs:|jt_|jt_|jt_tjs6t`ndS(N(R„R‚RƒR…R€R‡R(R((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR
ˆs
       N(RRR4RRRRxRyR\R]R~R€RR    R
(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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@((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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
|t dƒ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&RBtKeyErrorRtRuntimeWarningt SystemError(RR{RŒtpkgnametmodnametdotRE((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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Ž((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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@((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/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((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR€s 
 N( RRR4RR~RˆR‰RŠR‹RŸR€(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyRs    
-          cCs#|ptptƒatjƒdS(N(tdefault_importerRtcurrent_importerR    (timporter((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR    #scCstjƒdS(N(R³R
(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyR
(s((R4twarningsRRR‚R(RCR&R¥RR R R RRRR,R.RRRRRRRRR²R³R    R
(((sN/tmp/ndk-User/buildhost/install/prebuilt/darwin-x86_64/lib/python2.7/ihooks.pyt<module>3s2     58P3?