
~Mc        )   @   sM  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 Z	 y d d l
 m Z Wn e k
 r e Z n Xe e j d   Z y d d l m Z Wn! e k
 r d d l m Z n Xd d l m Z d d l m Z d d l m Z d d	 l m Z d
 de d     YZ d e f d     YZ d e f d     YZ d df d     YZ e Z  d e f d     YZ! d dg d     YZ" d   Z# d Z$ d Z% d Z& d   Z' d   Z( d   Z) d   Z* d   Z+ d   Z, d    Z- e- Z. d! e/ f d"     YZ0 d# e1 f d$     YZ2 d% e2 f d&     YZ3 d' e2 f d(     YZ4 d)   Z5 d*   Z6 d+   Z7 e e d, d- d d   e7  Z7 d.   Z8 d/   Z9 d0   Z: d1   Z; d2   Z< e e d, d3 d d  d4  d d5   Z> e e d, d3 d d  d4  d d6   Z? d d7  Z@ d8   ZA d d9  ZB d d:  ZC d d d;  ZD d d<  ZE d d=  ZF d>   ZG d?   ZH d@   ZI dA   ZJ dB   ZK eH d d d d d dC  ZL dD   ZM d# d% d' dE dF dG d
 d d d d d dH dI dJ dK dL dM dN dO dP dQ dR dS dT dU dV dW dX dY dZ d[ d\ d] d^ d_ d` da db dc dd g) ZN d S(h   st   
Standardized versions of various cool and/or strange things that you can do
with Python's reflection capabilities.
iN(   t   dequet    (   t   StringIO(   t
   unsignedID(   t
   deprecated(   t   _fullyQualifiedName(   t   Versiont   Settablec           B   s    e  Z d  Z d   Z d   Z RS(   sQ  
    A mixin class for syntactic sugar.  Lets you assign attributes by
    calling with keyword arguments; for example, C{x(a=b,c=d,y=z)} is the
    same as C{x.a=b;x.c=d;x.y=z}.  The most useful place for this is
    where you don't want to name a variable, but you do want to set
    some attributes; for example, C{X()(y=z,a=b)}.
    c         K   s   |  |   d  S(   N(    (   t   selft   kw(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   __init__/   s    c         K   s1   x* | j    D] \ } } t |  | |  q W|  S(   N(   t   itemst   setattr(   R   R	   t   keyt   val(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   __call__2   s    (   t   __name__t
   __module__t   __doc__R
   R   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR   '   s   	t   AccessorTypec           B   s   e  Z d  Z d   Z RS(   s;  Metaclass that generates properties automatically.

    This is for Python 2.2 and up.

    Using this metaclass for your class will give you explicit accessor
    methods; a method called set_foo, will automatically create a property
    'foo' that uses set_foo as a setter method. Same for get_foo and del_foo.

    Note that this will only work on methods that are present on class
    creation. If you add methods after the class is defined they will not
    automatically become properties. Likewise, class attributes will only
    be used if they are present upon class creation, and no getter function
    was set - if a getter is present, the class attribute will be ignored.

    This is a 2.2-only alternative to the Accessor mixin - just set in your
    class definition::

        __metaclass__ = AccessorType

    c      	   C   sk  t  j |  | | |  i  } d d d g } xs | j   D]e } t |  |  } xM t d  D]? } | j | |  rZ | | j | d d  d  d  g  | <qZ qZ Wq8 Wx | j   D] \ } \ }	 }
 } |	 d  k rt	 |  |  r t |  |  } | | d  }	 q| d  }	 n  |
 d  k r)| d  }
 n  | d  k rD| d	  } n  t
 |  | t |	 |
 | d
   q Wd  S(   Nt   get_t   set_t   del_i   i   c         S   s"   | |  j  k r |  j  | S| Sd  S(   N(   t   __dict__(   t   thist   valuet   name(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   getter]   s    c         S   s.   | |  j  k r |  j  | St d |   d  S(   Ns   no such attribute %r(   R   t   AttributeError(   R   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR   c   s    c         S   s   | |  j  | <d  S(   N(   R   (   R   R   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   setteri   s    c         S   s   |  j  | =d  S(   N(   R   (   R   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   delerl   s    R   (   t   typeR
   t   keyst   getattrt   ranget
   startswitht
   setdefaultt   NoneR   t   hasattrR   t   property(   R   R   t   basest   dt	   accessorst   prefixst   kt   vt   iR   R   R   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR
   N   s&    ."(   R   R   R   R
   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR   8   s   t   PropertyAccessorc           B   s&   e  Z d  Z e Z d   Z d   Z RS(   s  A mixin class for Python 2.2 that uses AccessorType.

    This provides compatability with the pre-2.2 Accessor mixin, up
    to a point.

    Extending this class will give you explicit accessor methods; a
    method called set_foo, for example, is the same as an if statement
    in __setattr__ looking for 'foo'.  Same for get_foo and del_foo.

    There are also reallyDel and reallySet methods, so you can
    override specifics in subclasses without clobbering __setattr__
    and __getattr__, or using non-2.1 compatible code.

    There is are incompatibilities with Accessor - accessor
    methods added after class creation will *not* be detected. OTOH,
    this method is probably way faster.

    In addition, class attributes will only be used if no getter
    was defined, and instance attributes will not override getter methods
    whereas in original Accessor the class attribute or instance attribute
    would override the getter method.
    c         C   s   | |  j  | <d  S(   N(   R   (   R   R,   R-   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt	   reallySet   s    c         C   s   |  j  | =d  S(   N(   R   (   R   R,   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt	   reallyDel   s    (   R   R   R   R   t   __metaclass__R0   R1   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR/   q   s   	t   Accessorc           B   s;   e  Z d  Z d   Z d   Z d   Z d   Z d   Z RS(   s  
    Extending this class will give you explicit accessor methods; a
    method called C{set_foo}, for example, is the same as an if statement
    in L{__setattr__} looking for C{'foo'}.  Same for C{get_foo} and
    C{del_foo}.  There are also L{reallyDel} and L{reallySet} methods,
    so you can override specifics in subclasses without clobbering
    L{__setattr__} and L{__getattr__}.

    This implementation is for Python 2.1.
    c         C   sC   d | } t  |  j |  r/ t |  |  |  S|  j | |  d  S(   Ns   set_%s(   R&   t	   __class__R!   R0   (   R   R,   R-   t   kstring(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   __setattr__   s    
c         C   sO   d | } t  |  j |  r, t |  |    St d t |  j  | f   d  S(   Ns   get_%ss#   %s instance has no accessor for: %s(   R&   R4   R!   R   t   qual(   R   R,   R5   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   __getattr__   s    
c         C   sA   d | } t  |  j |  r0 t |  |    d  S|  j |  d  S(   Ns   del_%s(   R&   R4   R!   R1   (   R   R,   R5   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   __delattr__   s
    
c         C   s=   | d k r, |  j  j   |  j  j |  n | |  j  | <d S(   s   
        *actually* set self.k to v without incurring side-effects.
        This is a hook to be overridden by subclasses.
        R   N(   R   t   cleart   update(   R   R,   R-   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR0      s    c         C   s   |  j  | =d S(   s   
        *actually* del self.k without incurring side-effects.  This is a
        hook to be overridden by subclasses.
        N(   R   (   R   R,   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR1      s    (   R   R   R   R6   R8   R9   R0   R1   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR3      s   
				t   Summerc           B   s   e  Z d  Z d   Z RS(   s  
    Extend from this class to get the capability to maintain 'related
    sums'.  Have a tuple in your class like the following::

        sums=(('amount','credit','credit_total'),
              ('amount','debit','debit_total'))

    and the 'credit_total' member of the 'credit' member of self will
    always be incremented when the 'amount' member of self is
    incremented, similiarly for the debit versions.
    c         C   sq  xW|  j  D]L} | d } | d } | d } | | k r y t |  |  } Wn d } n X| | } t |  |  rVt |  |  }	 |	 d k	 r y t |	 |  }
 Wn d }
 n Xt |	 | |
 |  q qVq
 | | k r
 t |  |  rVt |  |  } t |  | d  t |  |  } t j |  | |  t |  | |  t j |  | |  qVq
 q
 Wt j |  | |  d S(   s   This method does the work.i    i   i   g        N(   t   sumsR!   R&   R%   R   R3   R0   (   R   R,   R-   t   sumt   attrt   objt   objattrt   oldvalt   difft   obt	   oldobjvalt   xt   y(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR0      s6    




  
(   R   R   R   R0   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR<      s   t   QueueMethodc           B   s    e  Z d  Z d   Z d   Z RS(   s-    I represent a method that doesn't exist yet.c         C   s   | |  _  | |  _ d  S(   N(   R   t   calls(   R   R   RI   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR
      s    	c         G   s   |  j  j |  j | f  d  S(   N(   RI   t   appendR   (   R   t   args(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR      s    (   R   R   R   R
   R   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyRH      s   	c   
      C   s   t  j d t d d |  j } |  j } | j } | j |  } |  j } g  } | j d | | f  | r | t	 |  } | j d |  | j d | |   | j d  xD t
 | |  D]/ } | | }	 | j d | |	 | | f  q Wn  | S(	   sA   
    this is more documentation for myself than useful code.
    sH   [v2.5] Use inspect.getargspec instead of twisted.python.reflect.funcinfot
   stackleveli   s$   The function %s accepts %s argumentss   It requires %s argumentss   The arguments required are: %ss   additional arguments are:s   %s which has a default of(   t   warningst   warnt   DeprecationWarningt	   func_codet	   func_namet   co_argcountt   co_varnamest   func_defaultsRJ   t   lenR"   (
   t   functiont   codeR   t   argct   argvt   defaultst   outt   requiredR.   t   j(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   funcinfo   s(    				
&i    i   i   c         C   sU   t  t j |  |  j   d |  j } t |  |  k	 rQ t d |  | f   n  | S(   Nt   .s   Couldn't find %s as %s.(   t   strt   picklet   whichmoduleR   t   namedObjectt	   Exception(   t   funct   qualName(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   fullFuncName!  s    &c         C   s   |  j  d |  j S(   s#   Return full import path of a class.R_   (   R   R   (   t   clazz(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR7   (  s    c         C   sV   t  |   t j k s t d  t |  j  } t | |  j d   } | d  k rR |  S| S(   Ns   must be a class...(	   R   t   typest	   ClassTypet   AssertionErrort   namedModuleR   R!   R   R%   (   Rh   t   modulet	   currclass(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt
   getcurrent-  s    c         C   s$   t  |  d  r |  j St |   Sd S(   st   Return the class or type of object 'obj'.
    Returns sensible result for oldstyle and newstyle instances and types.R4   N(   R&   R4   R   (   R@   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   getClass6  s    c         C   s   t  |   t j k s* t  |  t j k r7 t |  |  S|  j } t |  } t |  } t | |  r | | k rw t S| |  _ t	 Sn t
 Sd  S(   N(   R   Ri   t   InstanceTypeRj   t
   isinstanceR4   Ro   t
   issubclasst   WASt   ISt   ISNT(   t   instRh   t   clt   cl2(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   isinstA  s    *		c         C   sI   t  |   } |  j d  d } | } x | D] } t | |  } q, W| S(   s   Return a module given its name.R_   i   (   t
   __import__t   splitR!   (   R   t   topLevelt   packagest   mt   p(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyRl   Q  s    c         C   s9   |  j  d  } t d j | d    } t | | d  S(   s,   Get a fully named module-global object.
    R_   i(   R|   Rl   t   joinR!   (   R   t
   classSplitRm   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyRc   [  s    t   _NoModuleFoundc           B   s   e  Z d  Z RS(   s2   
    No module was found because none exists.
    (   R   R   R   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR   f  s   t   InvalidNamec           B   s   e  Z d  Z RS(   sG   
    The given name is not a dot-separated list of Python objects.
    (   R   R   R   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR   l  s   t   ModuleNotFoundc           B   s   e  Z d  Z RS(   s_   
    The module associated with the given name doesn't exist and it can't be
    imported.
    (   R   R   R   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR   r  s   t   ObjectNotFoundc           B   s   e  Z d  Z RS(   s_   
    The object associated with the given name doesn't exist and it can't be
    imported.
    (   R   R   R   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR   y  s   c         C   s   y y t  |   SWn| t k
 r t j   \ } } } xJ | r | j j d } | d k sg | |  k rv | | |  n  | j } q9 Wt    n XWn t j	 j
 |  d    n Xd S(   s  
    Import the given name as a module, then walk the stack to determine whether
    the failure was the module not existing, or some code in the module (for
    example a dependent import) failing.  This can be helpful to determine
    whether any actual application code was run.  For example, to distiguish
    administrative error (entering the wrong module name), from programmer
    error (writing buggy code in a module that fails to import).

    @raise Exception: if something bad happens.  This can be any type of
    exception, since nobody knows what loading some arbitrary code might do.

    @raise _NoModuleFound: if no module was found.
    R   N(   R{   t   ImportErrort   syst   exc_infot   tb_framet	   f_globalsR%   t   tb_nextR   t   modulest   pop(   t
   importNamet   excTypet   excValuet   excTracebackt   execName(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   _importAndCheckStack  s    	c         C   s  |  s t  d   n  |  j d  } d | k rF t  d |  f   n  d } | } x | s | r d j |  } y t |  } Wq t k
 r | j   q XqV t |  d k r t d |  f   qV t	 d |  f   qV W| } x! | d D] } t
 | |  } q W| S(	   s  
    Retrieve a Python object by its fully qualified name from the global Python
    module namespace.  The first part of the name, that describes a module,
    will be discovered and imported.  Each subsequent part of the name is
    treated as the name of an attribute of the object specified by all of the
    name which came before it.  For example, the fully-qualified name of this
    object is 'twisted.python.reflect.namedAny'.

    @type name: L{str}
    @param name: The name of the object to return.

    @raise InvalidName: If the name is an empty string, starts or ends with
        a '.', or is otherwise syntactically incorrect.

    @raise ModuleNotFound: If the name is syntactically correct but the
        module it specifies cannot be imported because it does not appear to
        exist.

    @raise ObjectNotFound: If the name is syntactically correct, includes at
        least one '.', but the module it specifies cannot be imported because
        it does not appear to exist.

    @raise AttributeError: If an attribute of an object along the way cannot be
        accessed, or a module along the way is not found.

    @return: the Python object identified by 'name'.
    s   Empty module nameR_   R   sO   name must be a string giving a '.'-separated list of Python identifiers, not %ri   s   No module named %rs   %r does not name an objectN(   R   R|   R%   R   R   R   R   RU   R   R   R!   (   R   t   namest   topLevelPackaget   moduleNamest	   trialnameR@   t   n(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   namedAny  s.    	c         J   s  | j  d  s |  | d <n  | | } d | } e | | d  } e j } d } | j  |  s e j |  } | | | <d | _ n  | | } | j d 7_ d e | j  }	 | d |	 }
 e j |
  } | e j |
 <e | |	 |  | j	 } | | | U| |  S(	   sf   macro(name, source, **identifiers)

    This allows you to create macro-like behaviors in python.
    R   s   <%s (macro)>t   execs   twisted.python.reflect.macrosi    i   t   macro_R_   (
   t   has_keyt   compileR   R   t   newRm   t   countR`   R   R   (   R   t   filenamet   sourcet   identifierst	   codeplaceRW   t   smt   tprmt   macrost	   macronamet   tprmmt   mymodt   dict(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   macro  s*    

	

		
t   Twistedi   c         C   s    y |  j  SWn t |   SXd  S(   N(   R4   R   (   RF   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   _determineClass	  s    c         C   sH   t  |   } y | j SWn* y t |  SWqD d t |  SXn Xd  S(   Ns   <BROKEN CLASS AT 0x%x>(   R   R   R`   R   (   RF   t   c(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   _determineClassName  s    c         C   sg   y |  |  SWnR t    } t j d |  t |  } | j   } d | t |  |  j | f SXd S(   s;   
    Helper function for L{safe_repr} and L{safe_str}.
    t   files(   <%s instance at 0x%x with %s error:
 %s>N(   R   t	   tracebackt	   print_excR   t   getvalueR   R   (   t	   formattert   ot   iot	   classNamet   tbValue(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   _safeFormat  s    	c         C   s   t  t |   S(   s   
    safe_repr(anything) -> string

    Returns a string representation of an object, or a string containing a
    traceback, if that object's __repr__ raised an exception.
    (   R   t   repr(   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt	   safe_repr-  s    c         C   s   t  t |   S(   s   
    safe_str(anything) -> string

    Returns a string representation of an object, or a string containing a
    traceback, if that object's __str__ raised an exception.
    (   R   R`   (   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   safe_str8  s    i   s   inspect.getmroc         C   s   g  } t  |  | |  | S(   s   allYourBase(classObj, baseClass=None) -> list of all base
    classes that are subclasses of baseClass, unless it is None,
    in which case all bases will be added.
    (   t   _accumulateBases(   t   classObjt	   baseClasst   l(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   allYourBaseE  s    c         C   s   t  |  | |  d  S(   N(   R   (   R   R   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   accumulateBasesP  s    c         C   sS   xL |  j  D]A } | d  k s+ t | |  r; | j |  n  t | | |  q
 Wd  S(   N(   t	   __bases__R%   Rs   RJ   R   (   R   R   R   t   base(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR   U  s    c         C   s    i  } t  |  | |  | j   S(   sA   A list of method names with a given prefix in a given class.
    (   t   addMethodNamesToDictR    (   R   t   prefixt   dct(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   prefixedMethodNames\  s    c         C   s   x$ |  j  D] } t | | | |  q
 W| d k sB | |  j  k r xt |  j j   D]` \ } } | t |  } t |  t j k rR | t |   | k rR t |  rR d | | <qR qR Wn  d S(   s  
    addMethodNamesToDict(classObj, dict, prefix, baseClass=None) -> dict
    this goes through 'classObj' (and its bases) and puts method names
    starting with 'prefix' in 'dict' with a value of 1. if baseClass isn't
    None, methods will only be added if classObj is-a baseClass

    If the class in question has the methods 'prefix_methodname' and
    'prefix_methodname2', the resulting dict should look something like:
    {"methodname": 1, "methodname2": 1}.
    i   N(	   R   R   R%   R   R   RU   R   Ri   t   FunctionType(   R   R   R   R   R   R   t   methodt   optName(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR   d  s    c         C   s    i  } t  |  | |  | j   S(   s?   A list of methods with a given prefix on a given instance.
    (   t   accumulateMethodst   values(   R@   R   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   prefixedMethods{  s    c         C   s   | s |  j  } n  x$ | j D] } t |  | | |  q Wxz | j j   D]i \ } } | t |  } t |  t j k rI | t |   | k rI t |  rI t	 |  |  | | <qI qI Wd S(   s   accumulateMethods(instance, dict, prefix)
    I recurse through the bases of instance.__class__, and add methods
    beginning with 'prefix' to 'dict', in the form of
    {'methodname':*instance*method_object}.
    N(
   R4   R   R   R   R   RU   R   Ri   R   R!   (   R@   R   R   t   curClassR   R   R   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR     s    c         C   sb   x! |  j  D] } t | | |  q
 W| d k s? | |  j  k r^ | j |  j j | i    n  d S(   s  Accumulate all attributes of a given name in a class heirarchy into a single dictionary.

    Assuming all class attributes of this name are dictionaries.
    If any of the dictionaries being accumulated have the same key, the
    one highest in the class heirarchy wins.
    (XXX: If "higest" means "closest to the starting class".)

    Ex::

    | class Soy:
    |   properties = {"taste": "bland"}
    |
    | class Plant:
    |   properties = {"colour": "green"}
    |
    | class Seaweed(Plant):
    |   pass
    |
    | class Lunch(Soy, Seaweed):
    |   properties = {"vegan": 1 }
    |
    | dct = {}
    |
    | accumulateClassDict(Lunch, "properties", dct)
    |
    | print dct

    {"taste": "bland", "colour": "green", "vegan": 1}
    N(   R   t   accumulateClassDictR%   R;   R   t   get(   R   R?   t   adictR   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR     s    c         C   sb   x! |  j  D] } t | | |  q
 W| d k s? | |  j  k r^ | j |  j j | g    n  d S(   s   Accumulate all attributes of a given name in a class heirarchy into a single list.

    Assuming all class attributes of this name are lists.
    N(   R   t   accumulateClassListR%   t   extendR   R   (   R   R?   t   listObjR   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR     s    c         C   s
   |  | k S(   N(    (   t   at   b(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   isSame  s    c         C   s
   |  | k S(   N(    (   R   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   isLike  s    c         C   s   t  t j |  t d  S(   Ns   sys.modules(   t   objgrepR   R   R   (   t   goal(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   modgrep  s    c         C   s1   t  |   | k p0 t |  t j  o0 |  j | k S(   N(   R   Rr   Ri   Rq   R4   (   t   startR   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   isOfType  s    c         C   s   t  |  | t  S(   N(   R   R   (   R   t   t(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   findInstances  s    c      
   C   s}  | d k r g  } n  | d k r* i  } n  | |  |  rI | j |  n  t |   | k rx | t |   |  k rx d Sn  | d k	 r | d k r d S| d 8} n  |  | t |   <t |  t j  rEx|  j   D]n \ } }	 t | | | | d t |	  d | | | |  t |	 | | | d t |  d | | | |  q Wn4t |  t	 t
 t f  rxt t |    D]; }
 t |  |
 | | | d t |
  d | | | |  qpWnt |  t j  r9t |  j | | | d | | | |  t |  j | | | d	 | | | |  t |  j | | | d
 | | | |  n@t |  d  rxD |  j j   D]3 \ } }	 t |	 | | | d | | | | |  qXWt |  t j  ryt |  j | | | d | | | |  qyn t |  t j  rt |    | | | d | | | |  nq t |  t j t j t j t j t t j t j t j  f  syt! |   j" d k r]n | ryd Gt! |   G|  GHn  | S(   s9   An insanely CPU-intensive process for finding stuff.
    Ni    i   t   {t   }t   [t   ]s   .im_selfs   .im_funcs	   .im_classR   R_   s
   .__class__s   ()t   wrapper_descriptort   method_descriptort   member_descriptort   getset_descriptors   unknown type(   R   R   R   R   (#   R%   RJ   t   idRr   Ri   t   DictionaryTypeR   R   R   t   listt   tupleR    t   xrangeRU   R`   t
   MethodTypet   im_selft   im_funct   im_classR&   R   Rq   R4   t   weakreft   ReferenceTypet   StringTypest   IntTypeR   t   BuiltinMethodTypet	   RegexTypet	   FloatTypet   NoneTypet   FileTypeR   R   (   R   R   t   eqt   patht   pathst   seent   showUnknownst   maxDepthR,   R-   t   idx(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyR     sT    		18<&&)+,)	c         C   s   t  j j |   } t  j j |   } | sC t  j j |  d   } n  t  j j |  d } xV t  j j |  } t  j j t  j j | d   r d t  j j |  | f } q\ Pq\ | S(   s  
    Convert a name in the filesystem to the name of the Python module it is.

    This is agressive about getting a module name back from a file; it will
    always return a string.  Agressive means 'sometimes wrong'; it won't look
    at the Python path or try to do any error checking: don't use this method
    unless you already know that the filename you're talking about is a Python
    module.
    ii    s   __init__.pys   %s.%s(   t   osR   t   abspatht   basenamet   splitextt   dirnamet   existsR   (   t   fnt   fullNameR   t   modName(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   filenameToModuleName
  s    
!Rv   Rt   Ru   t   OriginalAccessorR^   Rg   R7   Ro   Rp   Rz   Rl   Rc   t
   namedClassR   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  t   fullyQualifiedName(    (    (    (O   R   R   R  Ri   Ra   R   R   t   reRM   R   t   collectionsR    R   R   R   R   R   t	   cStringIOR   t   twisted.python.utilR   t   twisted.python.deprecateR   R   R  t   twisted.python.versionsR   R   R   t   objectR/   R3   R  R<   RH   R^   Rv   Rt   Ru   Rg   R7   Ro   Rp   Rz   Rl   Rc   R  Rd   R   t
   ValueErrorR   R   R   R   R   R   R   R   R   R   R   R%   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  t   __all__(    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/reflect.pyt   <module>   s   
9%3+									
		!	@	$!					
	$					/				