;ò
ÎÑAHc           @   sÀ   d  Z  d k Z d k Z d k Z d k Z h  a e i d e i ƒ Z e	 e
 e d „ Z d „  Z d k Z e i i ƒ  Z d d g a d d „ Z d d	 „ Z e i d
 e ƒ e i d e ƒ d S(   s?   
IPython extension: %lookfor command for searching docstrings

Ns   [a-z_]+\(.*[,=].*\)c      
      s³  h  ‰ xG | D]? } y# t | | | ƒ } ˆ i | ƒ Wq t j
 o q Xq Wg  } t
 |  ƒ i ƒ  i ƒ  ‰  ˆ  o d Sn x ˆ i ƒ  D]‚ \ } \ } } }	 | d d f j o q‹ n t } | i ƒ  } x& ˆ  D] } | | j o t } PqÓ qÓ W| o | i | ƒ q‹ q‹ Wh  d d <d d <d d <d d <‰ ‡  ‡ d †  ‰ ‡ ‡ d	 †  } | i | ƒ d
 d i ˆ  ƒ } | d t  | ƒ g } xÙ | D]Ñ } ˆ | \ } } } g  i } | i$ ƒ  i d ƒ D]' } | i$ ƒ  o | | i$ ƒ  ƒ qÌqÌ~ } y8 | d i$ ƒ  } t( i) | ƒ o | d i$ ƒ  } n Wn t* j
 o d } n X| i d | | f ƒ q–Wt  | ƒ d j o# t+ i, ƒ  } | d i | ƒ ƒ n d i | ƒ GHd S(   së  
    Search for objects whose documentation contains all given words.
    Shows a summary of matching objects, sorted roughly by relevance.

    Parameters
    ----------
    what : str
        String containing words to look for.

    module : str, module
        Module whose docstrings to go through.
    import_modules : bool
        Whether to import sub-modules in packages.
        Will import only modules in __all__
    regenerate: bool
        Re-generate the docstring cache

    Ns   modules   objects   funciè  s   classiüÿÿc            s  d } d i | i ƒ  i ƒ  i d ƒ d  ƒ } | t g  i } ˆ  D]! } | | j o | d ƒ qB qB ~ ƒ 7} | t g  i } ˆ  D]! } | |  j o | d ƒ q„ q„ ~ ƒ 7} | t |  ƒ d 7} | ˆ i | d ƒ 7} | |  i d ƒ d	 7} | t | d
 d ƒ 7} | Sd  S(   Ni    s   
i   iÈ   i   i   iüÿÿs   .i
   id   iœÿÿÿ(   s   rs   joins   docstrs   lowers   strips   splits	   first_docs   sums   appends   _[1]s   whatss   ws   names   lens   kind_relevances   gets   kinds   counts   maxs   index(   s   names   docstrs   kinds   indexs   _[1]s   rs	   first_docs   w(   s   whatss   kind_relevance(    sO   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/ipy_lookfor.pys	   relevanceK   s    (BBc            sJ   ˆ | ˆ  | Œ ˆ |  ˆ  |  Œ } | d j o | Sn t |  | ƒ Sd  S(   Ni    (   s	   relevances   bs   caches   as   drs   cmp(   s   as   bs   dr(   s   caches	   relevance(    sO   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/ipy_lookfor.pys   relevance_sort[   s    $ s   Search results for '%s's    s   -s   
i    i   s    s	   %s
    %si
   (.   s   caches   moduless   modules   _lookfor_generate_caches   import_moduless
   regenerates   cs   updates   ImportErrors   founds   strs   whats   lowers   splits   whatss	   iteritemss   names	   docstrings   kinds   indexs   Trues   oks   docs   ws   Falses   appends   kind_relevances	   relevances   relevance_sorts   sorts   joins   ss   lens	   help_texts   ixs   _[1]s   strips   lines   docliness	   first_docs   _function_signature_res   searchs
   IndexErrors   pydocs   getpagers   pager(   s   whats   moduless   import_moduless
   regenerates   ixs   whatss   modules   docliness	   help_texts   indexs   caches   kind_relevances	   relevances   ws	   docstrings   kinds   lines   pagers   relevance_sorts   cs   oks   names   docs   _[1]s   ss	   first_docs   found(    (   s   whatss   caches   kind_relevances	   relevancesO   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/ipy_lookfor.pys   lookfor   s^      	   	* Mc         C   sÒ  |  t j o
 d }  n t |  t ƒ o t |  ƒ }  n t |  ƒ t j o | o t t |  ƒ Sn h  } | t t |  ƒ <h  } d } |  i |  f g } x/| o'| i d ƒ \ }	 } t | ƒ | j o q› n t | t | ƒ <| d 7} d } t i | ƒ o#d } y | i } Wn t j
 o t } n X| o t | d ƒ o{ xx t i | i ƒ D]` } | t j	 o | d | j o qZn y t d |	 | d f ƒ WqZt j
 o
 qZqZXqZWn xÍ t i | ƒ D]J \ } } | t j	 o
 | | j o qÒn | i! d |	 | f | f ƒ qÒWno t i" | ƒ oG d } xU t i | ƒ D]) \ } } | i! d |	 | f | f ƒ qJWn t# | ƒ o
 d	 } n t i$ | ƒ }
 |
 t j	 o |
 | | f | |	 <q› q› W| Sd
 S(   s(  
    Generate docstring cache for given module.

    Parameters
    ----------
    module : str, None, module
        Module for which to generate docstring cache
    import_modules : bool
        Whether to import sub-modules in packages.
        Will import only modules in __all__
    regenerate: bool
        Re-generate the docstring cache

    Returns
    -------
    cache : dict {obj_full_name: (docstring, kind, index), ...}
        Docstring cache for the module, either cached one (regenerate=False)
        or newly generated.
        
    s   numpyi    i   s   objects   modules   __path__s   %s.%ss   classs   funcN(&   s   modules   Nones
   isinstances   strs
   __import__s   ids   _lookfor_cachess
   regenerates   caches   seens   indexs   __name__s   stacks   pops   names   items   Trues   kinds   inspects   ismodules   __all__s   _alls   AttributeErrors   import_moduless   hasattrs   pkgutils   iter_moduless   __path__s   ms   ImportErrors
   getmemberss   ns   vs   appends   isclasss   callables   getdocs   doc(   s   modules   import_moduless
   regenerates   seens   indexs   caches   _alls   stacks   kinds   names   docs   ms   ns   items   v(    (    sO   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/ipy_lookfor.pys   _lookfor_generate_cachez   sh      
  
  % %
s   numpys   scipys    c         C   s   t  | d t ƒd S(   s5  
    Search for objects whose documentation contains all given words.
    Shows a summary of matching objects, sorted roughly by relevance.

    Usage
    -----
    %lookfor +numpy  some words
    Search module 'numpy'

    %lookfor_modules numpy scipy
    Set default modules whose docstrings to search

    s   modulesN(   s   lookfors   args   _lookfor_modules(   s   selfs   arg(    (    sO   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/ipy_lookfor.pys	   lookfor_fÑ   s     c         C   s%   | o d Gt GHn | i ƒ  a d  S(   Ns$   Modules included in %lookfor search:(   s   args   _lookfor_moduless   split(   s   selfs   arg(    (    sO   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/ipy_lookfor.pys   lookfor_modules_fá   s     s   lookfors   lookfor_modules(   s   __doc__s   res   inspects   pkgutils   pydocs   _lookfor_cachess   compiles   Is   _function_signature_res   Nones   Trues   Falses   lookfors   _lookfor_generate_caches   IPython.ipapis   IPythons   ipapis   gets   ips   _lookfor_moduless	   lookfor_fs   lookfor_modules_fs   expose_magic(   s   pkgutils   ips   inspects   _function_signature_res   pydocs   res	   lookfor_fs   lookfors   IPythons   lookfor_modules_fs   _lookfor_generate_cache(    (    sO   /u/d/b/dbachman/=/lib/python2.3/site-packages/IPython/Extensions/ipy_lookfor.pys   ?   s   $	e	R	