ó o©ÐOc@s~dZddlZddlZddlZddlZddlZddlmZddlm Z ddkZ e Z dejfd„ƒYZ e ƒZ dejfd „ƒYZd efd „ƒYZd efd „ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZieej6eej6eej6eej6eej6eej6eej 6eej!6eej"6eej#6eej$6eej%6eej&6eej'6eej(6Z)dej*fd„ƒYZ+d d&d!„ƒYZ,d"d'd#„ƒYZ-d$d(d%„ƒYZ.dS()sSupport for python object introspection and exploration. Note that Explorers, what with their list of attributes, are much like manhole.coil.Configurables. Someone should investigate this further. (TODO) Also TODO: Determine how much code in here (particularly the function signature stuff) can be replaced with functions available in the L{inspect} module available in Python 2.1. iÿÿÿÿN(tpb(treflectitPoolcBseZd„ZRS(cCsxt|ƒ}||jkr&|j|Stjt|ƒtƒ}tj|iƒ}||j|<|j|||ƒ|SdS(N( tidtdatat typeTabletgetttypetExplorerGenericttypest InstanceTypet__init__(tselftobjectt identifiertoidtklasste((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyt getExplorers   (t__name__t __module__R(((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyRstExplorercBsJeZddgZgZdgZdZdZd„Zd„Z d„Z RS(RRt get_refcountcCs‹||_||_t|ƒ|_g|_tj|jd|jƒg|_tj|jd|jƒg|_tj|jd|jƒdS(Nt propertiestattributeGroupst accessors( R RRRRtaccumulateClassListt __class__RR(R R R((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR 5s       cCsƒdddg}|j|jƒ|j|jƒi}x!|D]}t||ƒ||eZdgZdgZdgZd„Zd„Zd„ZRS(tlentelementst get_elementscCs8tj|||ƒ||_t|ƒ|_g|_dS(N(RR tseqR0R1(R R3R((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR ms cCsit|jƒ|_g}xJt|jƒD]9}d|j|f}|jtj|j||ƒƒq(W|S(Ns%s[%s](R0R3txrangeRtappendt explorerPoolR(R tltiR((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR2us $cCs |jƒS(N(R2(R R!((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pytview_get_elements€s(RRRRRR R2R9(((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR/hs      tExplorerMappingcBsJeZdgZdgZddgZd„Zd„Zd„Zd„ZRS(R0tkeystget_keystget_itemcCs8tj|||ƒ||_t|ƒ|_g|_dS(N(RR tdctR0R;(R R>R((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR Šs cCsr|jjƒ}t|ƒ|_g}xGt|jƒD]6}d|j|f}|jtj|||ƒƒq4W|S(Ns %s.keys()[%s](R>R;R0R4RR5R6R(R R;R7R8R((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR<“s!cCs |jƒS(N(R<(R R!((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyt view_get_keysŸscCs]t|ƒtjkr!|j}n|j|}d|jt|ƒf}tj||ƒ}|S(Ns%s[%s]( RR R R R>RR+R6R(R R!R$titemR((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyt view_get_item£s   ( RRRRRR R<R?RA(((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR:…s    tExplorerBuiltincBs&eZdZdddgZd„ZRS(s @ivar name: the name the function was defined as @ivar doc: function's docstring, or C{None} if unavailable @ivar self: if not C{None}, the function is a method of this object. tdoctnameR cCs;tj|||ƒ|j|_|j|_|j|_dS(N(RR t__doc__RCRRDt__self__R (R tfunctionR((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR ¶s  (RRRERR (((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyRB¯stExplorerInstancecBs,eZdZdgZddgZd„ZRS(sq Attribute groups: - B{methods} -- dictionary of methods - B{data} -- dictionary of data members Note these are only the *instance* methods and members -- if you want the class methods, you'll have to look up the class. TODO: Detail levels (me, me & class, me & class ancestory) @ivar klass: the class this is an instance of. RtmethodsRc Csòtj|||ƒi}i}x›t|ƒD]}|ddkrHq,ntj||gdƒ}t||ƒ}t|ƒ}|tjkr£t j ||ƒ||ntj||gdƒ}t||ƒ}t|ƒ}|tj krÁt j ||ƒ||t j ||ƒ||W|j|_ t j|ƒ|_||_||_t j |j|dƒ|_t|ddƒ|_dS(NiRJR RKs .__bases__R(RR RRLRMRNRRR ROR6RRDtinspecttgetdocRCRRIt __bases__RVR)RW( R ttheClassRRQRIR8RRRSRT((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR òs*      (RRRERRR (((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyRUås  tExplorerFunctioncBs&eZdddddgZd„ZRS(RDRCtfiletlinet signaturec Csctj|||ƒ|j}|j}|jd@o5d}|jd@oHd}|||}t|j| ƒ}|jrèd} xjt|t |jƒ|ƒD]I} |j| } t j | d|| fƒ} |j | | ƒ| d} q˜Wn|r|j |dƒn|r |j|d|ƒn|j|_||_tj|ƒ|_|j|_|j|_dS(Niiiis%s.func_defaults[%d](RR t func_codet co_argcounttco_flagst Signaturet co_varnamest func_defaultsR4R0R6Rt set_defaultt set_keywordt set_varlistRRDR_RXRYRCt co_filenameR]tco_firstlinenoR^( R RGRtcodetargcountt takesListt takesKeywordstnR_ti_dR8tdefault((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR s2        (RRRR (((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR\stExplorerMethodcBseZddgZd„ZRS(R RcCs¤|j}t|ƒtjkr-|jj}ntj|||ƒt|ƒ|_tj |j |dƒ|_ tj |j |dƒ|_ |j r |jjƒndS(Ns .im_classs.im_self(tim_funcRR R t__call__R\R RR6Rtim_classRtim_selfR R_t discardSelf(R tmethodRRG((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR Ds    (RRRR (((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyRr=s tExplorerModulecBs5eZdZdddgZdddgZd„ZRS(sÄ @ivar name: the name the module was defined as @ivar doc: documentation string for the module @ivar file: the file the module is defined in Attribute groups: - B{classes} -- the public classes provided by the module - B{functions} -- the public functions provided by the module - B{data} -- the public data members provided by the module ("Public" is taken to be "anything that doesn't start with _") RDRCR]tclassest functionsRc CsGtj|||ƒi}i}i}xÍ|jjƒD]¼\}}|ddkrWq5nd||f}t|ƒtjkr•tj||ƒ||.st_watchEmitChangedN(RR R t TypeErrorRtaddMethodNamesToDictRR}R;RRRt_MonkeysSetattrMixinROR)RRvt _WatchMonkeytinstall( R R RRžR>tkRQtclazzNStclazzRDtmtmonkey((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyRs,         (RRRŸR(((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR™ùs RªcBs8eZdZdZd„Zd„Zd„Zd„ZRS(s¶I hang on a method and tell you what I see. TODO: Aya! Now I just do browseObject all the time, but I could tell you what got called with what when and returning what. cCs ||_dS(s7Make a monkey to hang on this instance object. N(RP(R RP((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR RscCs_t|j|dƒ}||k r[tj||j|jjƒ|jj|<||f|_ndS(s?Install myself on my instance in place of this method. N(RRPR)R RORR}t oldMethod(R tmethodIdentifierR±((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR«Ws  "cCse|jdkrdS|jddkr@t|j|jdƒn!t|j|jd|jdƒdS(s]Remove myself from this instance and restore the original method. (I hope.) Nii(R±R)tdelattrRPtsetattr(R ((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyt uninstallcs cOs=|jdr)t|jd||ƒ}nd}|jƒ|S(s@Pretend to be the method I replaced, and ring the bell. iN(R±tapplyR)R¦(R RPR–tkwtrval((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyRtrs   N( RRRER)R±R R«RµRt(((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyRªJs   R©cBseZdZd„ZRS(sDA mix-in class providing __setattr__ for objects being watched. cCsTt|jjddƒr9|jjdj|||ƒn ||j|<|jƒdS(s-Set the attribute and ring the bell. it __setattr__N(thasattrRRZR¹R}R¦(R R¬tv((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR¹s  (RRRER¹(((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pyR©~s((((/RERXRMR&R tUserDictttwisted.spreadRttwisted.pythonRR‰RŠRR6t CacheableRRR-R/R:RBRHRUR\RrRyR RROR€RtBuiltinFunctionTypetListTypet TupleTypetDictTypeR†tNoneTypetIntTypet FloatTypetLongTypet ComplexTypeRtCopyableRcR™RªR©(((s</usr/lib/python2.7/dist-packages/twisted/manhole/explorer.pytsL0   ) *()/-               eQ4