mò
¦Ec           @   s  d  Z  d Z d Z d Z d k l Z d k l Z d k l Z l	 Z	 l
 Z
 l Z l Z l Z l Z l Z d k Z d k Z d k l Z l Z l Z l Z d	 k l Z l Z d
 k l Z d k l Z d k l Z h  e i d <e i d <e i d <e i  d <e i! d <e i" d <e i# d <e i$ d <Z% y d e% e i& <Wn n Xy d e% e i' <Wn n Xy d e% e i( <Wn n Xy d e% e) <Wn n Xy d e% e* <Wn n Xy d e% e <Wn n Xh  Z+ d e f d „  ƒ  YZ, e, i- i. e, ƒ d e f d „  ƒ  YZ/ e/ i- i. e/ ƒ d e f d „  ƒ  YZ0 e0 i- i. e0 ƒ d „  Z1 d „  Z2 d „  Z3 d „  Z4 d „  Z5 h  Z6 d „  Z7 e% d „ Z8 d „  Z9 d „  Z: d „  Z; d „  Z< d „  Z= d  „  Z> y d! k? l@ Z@ e@ ZA Wn eB j
 o d" „  ZA n Xd S(#   sM   analyse object for methods (names, arguments, documentation) and
permissions.t
   programmert   scriptert   web(   s   FILTER_ROLES(   s   FILTER_METHODS(   s   isclasss   ismethods
   isfunctions   ismethoddescriptors   getmros
   getargspecs   formatargspecs   getcommentsN(   s   ClassSecurityInfos   ACCESS_PUBLICs   ACCESS_PRIVATEs   ACCESS_NONE(   s   aq_bases   Implicit(   s   Acquired(   s   ComputedAttribute(   s   DateTimei   t   Docc        
   B   s}  t  Z d  Z e Z e ƒ  Z e i d d d d d d d d d	 ƒ	 e e d
 „ Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z h  d e <d e <d e <d e <d e <d e <d e <d e <d e <d e <d e <d e <d  e <d! e <i h  d e <d" e <d# e <d e <d$ e <i d% „ Z d& „  Z d' „  Z d( „  Z RS()   sœ  determine the documentation of an object.

  The documentation is described by a 'Doc' instance.
  It maintains.

   path -- the physical path of the documented object or 'None'

   title -- the title of the documented object or ''

   obj -- the documented object

   classes -- a two level sequence structure:

     1. classes, the object is build from, in message resolution order (mro).

        each class is described by a 'ClassDoc' instance

     2. for each class, the attributes defined by the class

        each attribute is described by a 'AttributeDoc' instance.

  The documentation does not include instance level attributes
  (they are too many). However, it does provide
  summary information about access to unprotected attributes
  in the doc for the pseudo class '-- Instance --'.
  This information is not accurate, as the
  '__allow_access_to_unprotected__subobjects__'
  evaluation is not precise.
  t
   ObjToDoc__t	   DocType__t   DocMethodRe__t   Patht   Titlet   __getitem__t   __len__t   tpValuest   tpIdc         C   s  | |  _ | |  _ | |  _ y d i | i ƒ  ƒ } Wn t
 j
 o t | ƒ } n X| p
 d } n | |  _ y t | ƒ i } WnB t
 j
 o6 y t | ƒ i } WqÈ t
 j
 o d } qÈ Xn X| |  _ | } t | t ƒ o8 | t j o
 d } q| t j o
 d } qd } n d  }	 t | d d  ƒ p# t | d d  ƒ p t | d d  ƒ }
 |
 d  j	 o$ t |
 ƒ o |
 ƒ  }
 n |
 }	 n |	 d  j o
 d	 }	 n g  |  _ | |  _ |	 |  _ | o t i | ƒ i  |  _! | |  _" h  |  _# |  i$ ƒ  |  _% t& | ƒ } t( d
 ƒ } | i* t+ d |  i, ƒ  d | ƒƒ |  i i- | ƒ x! t. | ƒ D] } |  i0 | ƒ qTW|  `" |  `# |  `% d  S(   Nt   /t    i
   iöÿÿÿi    t   getIdt   idt   __name__s	   -- Doc --s   -- Instance --s   -- unprotected attributes --t   obj(1   R   t   selft   _ObjToDoc__t   detail_typet
   _DocType__t   method_filtert   _DocMethodRe__t   joint   getPhysicalPatht   patht   AttributeErrort   reprt   _Patht   aq_baset   titleR   t   _Titlet   tt
   isinstancet
   basestringt   DETAIL_PROGRAMMERt
   DETAIL_WEBt   Nonet   namet   getattrt   it   callablet   _classest   _typet   _namet   ret   compilet   matcht   _method_filtert   _objt   _attributest   _makeUnprotectedCheckert   _checkt	   _getClasst   ct   ClassDoct   ict   _appendt   AttributeDoct
   _attrRolest   appendt   _getMrot   clt   _analyseClass(   R   R   R   R   R@   R:   R    R   R8   R(   R*   R"   (    (    tC   /home2/kennisonb/webapps/zope/Zope/Products/DocFinderTab/analyse.pyt   __init__j   sd    			   
	   	 
 

8 
 
					"  c         C   s   |  i S(   N(   R   R   (   R   (    (    RB   R   £   s    c         C   s   |  i S(   N(   R   R   (   R   (    (    RB   R   ¤   s    c         C   s   |  i S(   N(   R   R   (   R   (    (    RB   R   ¥   s    c         C   s   |  i S(   N(   R   R   (   R   (    (    RB   R   ¦   s    c         C   s   |  i S(   N(   R   R!   (   R   (    (    RB   R   §   s    c         C   su   t  | t ƒ o |  i | Sn |  i d j o2 h  } |  _ x" |  i D] } | | | i	 <qF Wn |  i | i
 |  ƒ S(   s4   allow access by both integer as well as class names.N(   R#   t   kt   intR   R,   t
   _classDictR'   t   cdR8   R.   t   __of__(   R   RD   R8   RG   (    (    RB   R	   ª   s      
  c         C   s   t  |  i ƒ S(   s   the length of the classes.N(   t   lenR   R,   (   R   (    (    RB   R
   ³   s     c         C   s+   g  } |  i D] } | | i |  ƒ q ~ S(   s"   tuple of classes for tree display.N(   t   _[1]R   R,   R8   RH   (   R   RJ   R8   (    (    RB   R   ¸   s     c         C   s   |  i S(   N(   R   R.   (   R   (    (    RB   R   ¼   s    t   __doc__t
   __module__t*   __allow_access_to_unprotected_subobjects__t   __dict__t   __weakref__t	   __slots__t   __slotnames__t   __implements__t   __implements_advice_data__t   __implemented__t   __provides__t   __providedBy__t   showDocumentationt   analyseDocumentationt   __nonzero__t   __str__t   __call__c         C   sÕ  t  | i t | d d ƒ t | ƒ t | ƒ ƒ }	 |  i	 } | i }
 |  i } |  i } |  i } x@| i i ƒ  D]/\ } } | d d j p | | ƒ o qm n |
 | ƒ o qm n d | | <|  i d j o* | d d j o | | ƒ o qm qö n | o | | ƒ o qm n t | | d | | | ƒ ƒ } |  i d j o t | ƒ o qm n t | | | | ƒ } |  i d j o | i ƒ  o qm n |	 i | ƒ qm W| o |	 o d Sn |	 i  ƒ  |  i! i" |	 ƒ d S(	   s   analyse *c*.RK   i÷ÿÿÿt	   __roles__i   i    t   _iûÿÿÿN(#   R9   R8   R   R)   R'   t   _getLoct   _getCommentRG   R   R4   t
   attributest   has_keyt   seenR6   t   checkR3   t   oR2   t   filterRN   t   itemsRD   t   vt   _omitR-   t   _allowt   rt	   _isPrivatR<   t   aR   R;   t   _finishR,   R>   (   R   R8   Rh   Ri   Rl   Re   Rc   Rg   Rd   RG   Rb   R`   Rj   RD   (    (    RB   RA   À   s6     0   
     
c         C   s    t  |  i d t ƒ } t  |  i d d ƒ } t | t t f ƒ o! | p
 t	 } n | d „ } n< t | t ƒ o | i | t	 d „ } n | | t	 d „ } | S(   NR\   RM   i    c         C   s   | S(   N(   t   roles(   R(   t   valueRn   (    (    RB   Rc   ó   s    c         C   s   | |  ƒ o | Sn | S(   N(   t   allowR(   Rn   t   priv(   R(   Ro   Rp   Rn   Rq   (    (    RB   Rc   õ   s     c         C   s   | |  | ƒ o | Sn | S(   N(   Rp   R(   Ro   Rn   Rq   (   R(   Ro   Rp   Rn   Rq   (    (    RB   Rc   ù   s     (   R)   R   R3   t   ACCESS_PUBLICRn   Rp   R#   RE   t   boolt   ACCESS_PRIVATERc   t   dictt   get(   R   Rn   Rp   Rc   (    (    RB   R5   î   s     
c         C   sy   t  |  i d t ƒ } t  |  i d d ƒ } t | t t f ƒ o | p
 t	 } qu n! t | t
 ƒ o
 d } n d } | S(   NR\   RM   i    s   Restricted (Dict)s   Restricted (Func)(   R)   R   R3   Rr   Rn   Rp   R#   RE   Rs   Rt   Ru   (   R   Rn   Rp   (    (    RB   R=   ÿ   s      
c         C   s   |  i S(   N(   R   R   (   R   (    (    RB   R   	  s    (   R   RL   RK   R'   RF   t   ClassSecurityInfot   _secInfot   declarePublict   DETAIL_SCRIPTERRC   R   R   R   R   R   R	   R
   R   R   Ra   RA   R5   R=   (    (    (    RB   R   C   s&    	9										À.		
R9   c        
   B   s·   t  Z d  Z e ƒ  Z e i d d d d d d d d d	 ƒ	 e Z e e e d
 „ Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sš   the documentation of a class.

  It consists of a 'Name', 'Doc', 'Module' and a list of attributes,
  that can also be accessed via the attribute name.
  R	   R
   R   R   t   NameR   t   Modulet   Commentt   FullNamec         C   s1   | |  _ | |  _ | |  _ g  |  _ | |  _	 d  S(   N(
   R(   R   R.   t   doct   _doct   modt   _modt   _attrst   commentt   _comment(   R   R(   R   R   R„   (    (    RB   RC     s
    				c         C   su   t  | t ƒ o |  i | Sn |  i d j o2 h  } |  _ x" |  i D] } | | | i	 <qF Wn |  i | i
 |  ƒ S(   s3   allow access by both integer as well as attr names.N(   R#   RD   RE   R   Rƒ   t	   _AttrDictR'   RG   R8   R.   RH   (   R   RD   R8   RG   (    (    RB   R	   &  s      
  c         C   s   t  |  i ƒ S(   s   the length of the classes.N(   RI   R   Rƒ   (   R   (    (    RB   R
   /  s     c         C   s+   g  } |  i D] } | | i |  ƒ q ~ S(   s%   tuple of attributes for tree display.N(   RJ   R   Rƒ   Rl   RH   (   R   RJ   Rl   (    (    RB   R   4  s     c         C   s   |  i S(   s   use name as id.N(   R   R.   (   R   (    (    RB   R   8  s     c         C   s   |  i S(   s   the class name.N(   R   R.   (   R   (    (    RB   R{   =  s     c         C   s   |  i S(   s   the class doc.N(   R   R€   (   R   (    (    RB   R   A  s     c         C   s   |  i S(   s#   the module the class is defined in.N(   R   R‚   (   R   (    (    RB   R|   E  s     c         C   s   |  i S(   s!   the comment preceeding the class.N(   R   R…   (   R   (    (    RB   R}   I  s     c         C   s   d |  i ƒ  |  i ƒ  f S(   s4   the full class name (to be used with 'showCodeFor').s   %s.%sN(   R   R|   R{   (   R   (    (    RB   R~   M  s     c         C   s   |  i i | ƒ d S(   s   append *attr*.N(   R   Rƒ   R>   t   attr(   R   R‡   (    (    RB   R;   R  s     c         C   s   |  i i t d „ ƒ d S(   s   finish class definition.c         C   s   | |  i | i ƒ S(   N(   t   cmpt   a1R.   t   a2(   R‰   RŠ   Rˆ   (    (    RB   t   <lambda>Y  s    N(   R   Rƒ   t   sortRˆ   (   R   (    (    RB   Rm   W  s     (   R   RL   RK   Rw   Rx   Ry   R'   R†   RC   R	   R
   R   R   R{   R   R|   R}   R~   R;   Rm   (    (    (    RB   R9     s"    												R<   c           B   sº   t  Z d  Z e ƒ  Z e i d d d d d d d d d	 d
 d ƒ d Z e e d „ Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sd   the documentation of an attribute.

  It consists of a 'Name', 'Roles', 'Args', 'Doc' and 'Type'.
  R   R   R{   t   Rolest   ArgsR   t   Typet	   DocOrTypeR}   t
   PermissionR~   i    c   	      C   sÌ   d } } } } | t j	 oP y t | ƒ } Wn n Xy t | ƒ } Wn n Xt | ƒ } t	 | ƒ } n y t
 | ƒ } Wn n X| |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   NR   (   t	   argumentsR   R„   t   typeRo   t   _markert   _findArgSpect   _getDocR_   t   _getTypet	   _getRolesRn   R(   R   R.   t   _rolest
   _argumentsR€   R-   R   R3   R…   (	   R   R(   Rn   Ro   R   R„   R   R’   R“   (    (    RB   RC   n  s.          						c         C   s   |  i S(   s   the attribute nameN(   R   R.   (   R   (    (    RB   R{   „  s     c         C   s   |  i S(   s   the attribute rolesN(   R   R™   (   R   (    (    RB   R   ˆ  s     c         C   s   |  i S(   s   the attribute argumentsN(   R   Rš   (   R   (    (    RB   RŽ   Œ  s     c         C   s   |  i S(   s   the attribute documentationN(   R   R€   (   R   (    (    RB   R     s     c         C   s   |  i S(   s   the attribute typeN(   R   R-   (   R   (    (    RB   R   ”  s     c         C   s   f  S(   N(    (   R   (    (    RB   R   ˜  s    c         C   s   |  i S(   s   use name as id.N(   R   R.   (   R   (    (    RB   R   ›  s     c         C   s   |  i ƒ  p
 |  i ƒ  S(   s&   either the Doc (prefered) or the Type.N(   R   R   R   (   R   (    (    RB   R   Ÿ  s     c         C   s    d |  i i i ƒ  |  i ƒ  f S(   s4   the full class name (to be used with 'showCodeFor').s   %s.%sN(   R   t   aq_innert	   aq_parentR~   R{   (   R   (    (    RB   R~   £  s     c         C   sÄ   |  i o |  i Sn d
 } |  i d
 j	 oƒ |  i } | d  d j o
 d } n t |  i | d ƒ } | d
 j	 o8 y$ | d i	 d d !i
 d d ƒ } Wqª d	 } qª Xq® n | |  _ d |  _ | S(   sQ   return the permission protecting the attribute, 'None' if not directly protected.i   s   -- R   R\   i   iõÿÿÿR]   t    s   -- explicit --N(   R   t   _knownPermissiont   _permissionR'   t   pR3   R.   R(   t   _lookupt   _pt   replace(   R   R    R(   (    (    RB   R‘   §  s      
 	 
$ c         C   s   |  i S(   s%   the comment preceeding the attribute.N(   R   R…   (   R   (    (    RB   R}   ¶  s     (   R   RL   RK   Rw   Rx   Ry   Rž   R”   R'   RC   R{   R   RŽ   R   R   R   R   R   R~   R‘   R}   (    (    (    RB   R<   `  s$    											c         C   s   |  t j p
 |  t j S(   N(   t   roleRt   t   ACCESS_NONE(   R¤   (    (    RB   Rk   ¿  s    c         C   s   t  |  d d ƒ S(   s&   return location (module) of class *c*.RL   N(   R)   R8   R'   (   R8   (    (    RB   R^   Ã  s     c         C   s    y t  |  ƒ SWn d Sn Xd S(   s    return comment preceeding *obj*.R   N(   t   getcommentsR   (   R   (    (    RB   R_   Ç  s
       c         C   sa   t  |  ƒ i } | d j o d |  i i | f } n( | d j o d |  i i | f } n | S(   s-   return a nice representation of the *v* type.t   instances   %s %ss   instance methodN(   R“   Rg   R   t   tnt	   __class__t   im_class(   Rg   R¨   (    (    RB   R—   Í  s     c         C   s5   h  } t |  d | ƒ | j	 o |  i Sn |  i Sd S(   s   return the class of *obj*.t   _klassN(   t   mR)   R   R«   R©   (   R   R¬   (    (    RB   R7   ×  s
     c         C   s8   t  i |  ƒ } | d j o t |  ƒ } t  |  <n | S(   s,   *class_* s method resolution order (cached).N(   t	   _MROCacheRv   t   class_t   mroR'   t   getmro(   R®   R¯   (    (    RB   R?   á  s
     c         C   sç   |  t j o d Sn |  d j o d Sn t |  t ƒ o d Sn | i t |  ƒ ƒ p t |  ƒ o d Sn t |  t	 t
 f ƒ o |  i |  ƒ i Sn t oA t |  ƒ p t |  ƒ p t |  ƒ o |  i p d SqÜ qà n |  i S(   s   return the docstring of *obj*.s   Acquisition.AcquiredR'   t   DateTimeR   t   methodN(   R   t   AcquiredR'   R#   R±   t   simple_typesRa   R“   t   _isNonPrimitivet   staticmethodt   classmethodt   __get__RK   t   FILTER_METHODSt
   isfunctiont   ismethodt   ismethoddescriptor(   R   R´   (    (    RB   R–   ê  s      $'
 c         C   s¥   t  oU |  t j o
 d }  q¡ |  t j o
 d }  q¡ |  t j o
 d }  q¡ t |  ƒ }  nF |  t j o
 d }  n/ |  t j o
 d }  n |  t j o
 d }  n |  S(   s   return nice names for *roles*.t   publict   privatet   noneRr   Rt   R¥   N(   t   FILTER_ROLESRn   Rr   Rt   R¥   t   _filterRoles(   Rn   (    (    RB   R˜   ý  s       
 
 
 
 
 
c         C   s€   t  |  t t f ƒ p |  Sn d „  } h  } x) |  D]! } | | ƒ p d | | <q4 q4 W| i ƒ  }  |  i ƒ  d d i	 |  ƒ S(   s   filter out faux roles.c         C   s   |  i d ƒ o |  i d ƒ S(   NR]   t   _Permission(   R¤   t
   startswitht   endswith(   R¤   (    (    RB   t   fauxRole  s    i   s   (%s)s   , N(
   R#   Rn   t   listt   tupleRÅ   t   uniqueR¤   t   keysRŒ   R   (   Rn   R¤   RÈ   RÅ   (    (    RB   RÁ     s     	 
c         C   sa   h  } t |  d | ƒ } | i | | ƒ } | | j	 o |  | f Sn t t |  ƒ | | ƒ } | S(   s@   emulate Pythons name lookup; return pair (class,attr) or 'None'.RN   N(	   R¬   R)   R   t   odRv   t   keyRg   t   _lookupClassHierarchyR7   (   R   RË   RÊ   R¬   Rg   (    (    RB   R¡     s      c         C   sK   xD t  |  ƒ D]6 } | i i | | ƒ } | | j	 o | | f Sq q Wd  S(   N(	   R?   R8   R@   RN   Rv   RD   R¬   Rg   R'   (   R8   RD   R¬   R@   Rg   (    (    RB   RÌ   '  s      c         C   s   |  S(   N(   R   (   R   (    (    RB   t   _id.  s    c         C   s}   t  |  ƒ o t |  d t ƒ }  n t |  t t f ƒ o |  i |  ƒ }  n t |  ƒ o |  i	 }  n t
 t |  ƒ Œ  d d !S(   s?   the argument specification for *maybeFunction* or an exception.RC   i   iÿÿÿÿN(   t   isclasst   maybeFunctionR)   RÍ   R#   R¶   R·   R¸   R»   t   im_funct   formatargspect
   getargspec(   RÏ   (    (    RB   R•   0  s     (   s	   typeCheckc         C   s   d S(   Ni   (    (   Ro   (    (    RB   Rµ   >  s    (C   RK   R%   Rz   R&   t   Products.DocFinderTab.configRÀ   R¹   t   inspectRÎ   R»   Rº   R¼   R°   RÒ   RÑ   R¦   R/   t   typest   AccessControl.SecurityInfoRw   Rr   Rt   R¥   t   AcquisitionR   t   ImplicitR³   t   ComputedAttributeR±   t
   StringTypet   IntTypet   LongTypet	   FloatTypet	   TupleTypet   ListTypet   DictTypet   NoneTypeR´   t   UnicodeTypet   BooleanTypet   ComplexTypet   sett	   frozensetR”   R   Rx   t   applyR9   R<   Rk   R^   R_   R—   R7   R­   R?   R–   R˜   RÁ   R¡   RÌ   RÍ   R•   t   ZPublisher.BaseRequestt	   typeCheckRµ   t   ImportError(-   R?   R^   Ré   R•   R±   R%   RÁ   Rk   RÑ   RÀ   Rµ   R7   R—   R¡   R¦   R¥   R9   RÌ   R/   R¹   R´   Rº   RÒ   RØ   RÙ   R”   R   RÎ   R   Rw   R¼   R°   RÕ   Rz   RÍ   R<   Rt   Rr   R­   R&   R³   R˜   R_   R»   R–   (    (    RB   t   ?   s~   7f            ËK\				
							
			

