
&9_[c           @  s  d  Z  d d l m Z d d g Z d d l Z d d l Z d d l Z d d l Z d d l m	 Z	 d d l
 Z
 d d l 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 d l m Z d d l m Z d d l m Z d d l m Z d d l m  Z  d d l! m" Z" d d l# m$ Z$ m% Z% m& Z& d d l' m( Z( m) Z) m* Z* d d l+ m, Z, d d l- m. Z. d d l/ m0 Z0 d d l1 m2 Z2 d d l3 m4 Z4 d   Z5 e
 j6 j7 j  Z8 e9 j: j  Z; d   e
 j< e
 j= e
 j6 e> f D Z? e@ eA  ZB e@ eC jD  ZE e$ ZF e jG ZH d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ g ZI d0   ZJ d1   ZK d2   ZL d3 d4  ZM d5   ZN d6   ZO d7   ZP eQ d8  ZR d9   ZS d:   ZT d;   ZU d e. f d<     YZV d S(=   s   Tools for inspecting Python objects.

Uses syntax highlighting for presenting the various information elements.

Similar in spirit to the inspect module, but all calls take a name argument to
reference the name under which an object is being read.
i(   t   print_functiont	   Inspectort   InspectColorsN(   t   dedent(   t   izip_longest(   t   zip_longest(   t   page(   t   pretty(   t   skip_doctest_py3(   t
   PyColorize(   t   openpy(   t	   py3compat(   t   safe_hasattr(   t   compress_user(   t   indent(   t   list_namespace(   t
   TermColorst   ColorSchemet   ColorSchemeTable(   t   cast_unicodet   string_typest   PY3(   t	   signature(   t	   Colorable(   t	   highlight(   t   PythonLexer(   t   HtmlFormatterc         C  s   t  |  t   t d t   S(   Nt	   noclasses(   R   R   R   t   True(   t   code(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   pylight3   s    c         C  s   h  |  ] } t  j |   q S(    (   t   inspectt   getdoc(   t   .0t   t(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pys	   <setcomp>:   s   	 t	   type_namet
   base_classt   string_formt	   namespacet   lengtht   filet
   definitiont	   docstringt   sourcet   init_definitiont   class_docstringt   init_docstringt   call_deft   call_docstringt   ismagict   isaliast   isclasst   argspect   foundt   namec          K  s)   t  t t d g   } | j |   | S(   s1   Make an object info dict with all fields present.N(   t   dictR   t   info_fieldst   Nonet   update(   t   kwt   infodict(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   object_infoV   s    c         C  s   t  |   } | d k r d S| j d  r/ d St j j |  sE d St j | d   } t j	 | j
  \ } } Wd QX| Sd S(   sn   Get encoding for python source file defining obj

    Returns None if obj is not defined in a sourcefile.
    s   .sos   .dlls   .pydt   rbN(   s   .sos   .dlls   .pyd(   t	   find_fileR9   t   endswitht   ost   patht   isfilet	   stdlib_iot   openR
   t   detect_encodingt   readline(   t   objt   ofilet   buffert   encodingt   lines(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   get_encoding]   s    c         C  s   y |  j    } Wn t k
 r# n Xt | t  r@ t j |  Sy2 t j  |   } t |   } t j | d | SWn t k
 r   d SXd S(   s=  Stable wrapper around inspect.getdoc.

    This can't crash because of attribute problems.

    It also attempts to call a getdoc() method on the given object.  This
    allows objects which provide their docstrings via non-standard mechanisms
    (like Pyro proxies) to still be inspected by ipython's ? system.
    RK   N(
   R    t	   Exceptiont
   isinstanceR   R   t   cleandocRM   R   R   R9   (   RH   t   dst   docstrRK   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyR    t   s    
t    c         C  s  t  |  t  rg  } x d d d g D] } t |  |  } | d k	 r% t |  } | rb d | n d } | j t d j d | | f  d |  t j	 |  r | j t
 t |    q | j t d | | t |  f d |  q% q% W| rd	 j |  Sd Sn t |   }  y t j |   } WnN t k
 rzt |  d
  r{y t j |  j  } Wqwt k
 rsd SXq{n Xt |   } t | d | Sd S(   sl  Wrapper around inspect.getsource.

    This can be modified by other projects to provide customized source
    extraction.

    Parameters
    ----------
    obj : object
        an object whose source code we will attempt to extract
    oname : str
        (optional) a name under which the object is known

    Returns
    -------
    src : unicode or None

    t   fgett   fsett   fdels   %s.RS   s   # RK   s
   %s%s = %s
s   
t	   __class__N(   RO   t   propertyt   getattrR9   RM   t   appendR   t   joinR   t
   isfunctionR   t	   getsourceR   t   _get_wrappedt	   TypeErrort   hasattrRW   (   RH   t   onamet   sourcest   attrnamet   fnRK   t   oname_prefixt   src(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyR]      s<    	
	c         C  s:   t  j |   p9 t  j |   p9 t |  t  p9 t |  t  S(   s   True if obj is a function ()(   R   R\   t   ismethodRO   t   _builtin_func_typet   _builtin_meth_type(   RH   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   is_simple_callable   s    c         C  sH   t  |  d  r( t |   r( |  j }  n  t r; t j |   St j |   S(   s   Wrapper around :func:`inspect.getfullargspec` on Python 3, and
    :func:inspect.getargspec` on Python 2.
    
    In addition to functions and methods, this can also handle objects with a
    ``__call__`` attribute.
    t   __call__(   R   Rj   Rk   R   R   t   getfullargspect
   getargspec(   RH   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyRm      s    c         C  s&   t  j |  d |  d |  d |  d  S(   s   Format argspect, convenience wrapper around inspect's.

    This takes a dict instead of ordered arguments and calls
    inspect.format_argspec with the arguments in the necessary order.
    t   argst   varargst   varkwt   defaults(   R   t   formatargspec(   R4   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   format_argspec   s    c         C  s   |  j  d  } | d k r$ d } na y | d d d k } Wn t t f k
 rU n X| rq | d d | d <n  |  d t |  } |  j  d  } | d k r |  j  d  } n  | d k r |  j  d	 d
  } n  | | f S(   sD  Extract call tip data from an oinfo dict.

    Parameters
    ----------
    oinfo : dict

    format_call : bool, optional
      If True, the call line is formatted and returned as a string.  If not, a
      tuple of (name, argspec) is returned.

    Returns
    -------
    call_info : None, str or (str, dict) tuple.
      When format_call is True, the whole call information is formattted as a
      single string.  Otherwise, the object's name and its argspec dict are
      returned.  If no call information is available, None is returned.

    docstring : str or None
      The most relevant docstring for calling purposes is returned, if
      available.  The priority is: call docstring for callable instances, then
      constructor docstring for classes, then main object's docstring otherwise
      (regular functions).
    R4   Rn   i    t   selfi   R6   R0   R.   R*   RS   N(   t   getR9   t   KeyErrort
   IndexErrorRs   (   t   oinfot   format_callR4   t	   call_linet   has_selft   doc(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   call_tip   s     	c         C  sI   |  } d } x6 t  |  d  rD |  j }  | d 7} | d k r | Sq W|  S(   sN  Get the original object if wrapped in one or more @decorators

    Some objects automatically construct similar objects on any unrecognised
    attribute access (e.g. unittest.mock.call). To protect against infinite loops,
    this will arbitrarily cut off after 100 levels of obj.__wrapped__
    attribute access. --TK, Jan 2016
    i    t   __wrapped__i   id   (   R   R~   (   RH   t   orig_objt   i(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyR^   "  s    	
c         C  s   t  |   }  d } y t j |   } WnS t k
 rt t |  d  r{ y t j |  j  } Wqq t k
 rm qq Xq{ n n Xt |  S(   s\  Find the absolute path to the file where an object was defined.

    This is essentially a robust wrapper around `inspect.getabsfile`.

    Returns None if no file can be found.

    Parameters
    ----------
    obj : any Python object

    Returns
    -------
    fname : str
      The absolute path to the file where the object was defined.
    RW   N(   R^   R9   R   t
   getabsfileR_   R`   RW   R   (   RH   t   fname(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyR?   4  s    
c         C  sx   t  |   }  y] y t j |   d } Wn? t k
 rg t |  d  r^ t j |  j  d } qh d } n XWn d SX| S(   sU  Find the line number in a file where an object was defined.

    This is essentially a robust wrapper around `inspect.getsourcelines`.

    Returns None if no file can be found.

    Parameters
    ----------
    obj : any Python object

    Returns
    -------
    lineno : int
      The line number where the object definition starts.
    i   RW   N(   R^   R   t   getsourcelinesR_   R`   RW   R9   (   RH   t   lineno(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   find_source_linesW  s    c           B  s  e  Z e e j d  d d d d  Z d d  Z d   Z d   Z	 d   Z
 d d  Z e d d d	   Z d d
  Z d d  Z d d  Z d d  Z d   Z d d d d d  Z d d d d e d  Z d d d d d  Z d d d d  Z g  e e d  Z RS(   t   NoColori    c         C  sr   t  t |   j d | d |  | |  _ t j d d d |  d |  |  _ |  j j |  _ | |  _ |  j	 |  d  S(   Nt   parentt   configt   outt   strt   style(
   t   superR   t   __init__t   color_tableR	   t   Parsert   parsert   formatt   str_detail_levelt   set_active_scheme(   Rt   R   t   code_color_tablet   schemeR   R   R   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyR   y  s    	!	RS   c         C  s3   y$ | t  t |   } t |  SWn d SXd S(   s   Return the call signature for any callable object.

        If any exception is generated, None is returned instead and the
        exception is suppressed.N(   R   R   R   R9   (   Rt   RH   Ra   t   hdef(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   _getdef  s
    c         C  s#   d |  j  j j | |  j  j j f S(   s*   Return a header string with proper colors.s   %s%s%s(   R   t   active_colorst   headert   normal(   Rt   t   h(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   __head  s    c         C  s'   |  j  j |  |  j j  j |  d  S(   N(   R   R   R   (   Rt   R   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyR     s    c         C  s6   t  d | d d | r+ t  d |  n t    d S(   s-   Generic message when no information is found.s   No %s foundt   endt    s   for %sN(   t   print(   Rt   t   msgRa   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   noinfo  s    c         C  s   t  |  s t d  d Sd } t j |  rA |  j d  } n+ t j rl t |  t j	 k rl | j
 } n  |  j | |  } | d k r |  j d |  n t | |  j |  d d d S(   sw   Print the call signature for any callable object.

        If the object is a class, print the constructor information.s   Object is not callable.NRS   s   Class constructor information:
s   definition headerR   R   (   t   callableR   R   R3   t   _Inspector__headR   R   t   typet   typest   InstanceTypeRk   R   R9   R   R   (   Rt   RH   Ra   R   t   output(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   pdef  s    
c   	      C  sS  |  j  } g  } t |  } | r< | |  j d |  } n  | rk | j | d   | j t |   n  t j |  r t | d  r t | j  } | d	 k	 r | j | d   | j t |   q nP t | d  r t | j
  } | r | j | d   | j t |   q n  | s9|  j d |  n t j d j |   d	 S(
   s  Print the docstring for any object.

        Optional:
        -formatter: a function to run the docstring through for specially
        formatted docstrings.

        Examples
        --------

        In [1]: class NoInit:
           ...:     pass

        In [2]: class NoDoc:
           ...:     def __init__(self):
           ...:         pass

        In [3]: %pdoc NoDoc
        No documentation found for NoDoc

        In [4]: %pdoc NoInit
        No documentation found for NoInit

        In [5]: obj = NoInit()

        In [6]: %pdoc obj
        No documentation found for obj

        In [5]: obj2 = NoDoc()

        In [6]: %pdoc obj2
        No documentation found for obj2
        s
   plain/texts   Class docstring:R   s   Init docstring:Rk   s   Call docstring:t   documentations   
N(   R   R    Ru   RZ   R   R   R3   R`   R   R9   Rk   R   R   R[   (	   Rt   RH   Ra   t	   formattert   headRL   RQ   t   init_dst   call_ds(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   pdoc  s*    #	c         C  ss   t  j   y t | d | } Wn t k
 r9 d } n X| d k rY |  j d |  n t j |  j |   d S(   s$   Print the source code for an object.Ra   R+   N(   t	   linecachet
   checkcacheR]   RN   R9   R   R   R   (   Rt   RH   Ra   Rf   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   psource  s    

c         C  s   t  |  } | d k r, |  j d |  d St |  } | j d
  rX t d |  nO t j j |  s{ t d |  n, t	 j	 |  j
 t j | d t  | d	  d S(   s0   Show the whole file where an object was defined.R(   Ns   .sos   .dlls   .pyds    File %r is binary, not printing.s%   File %r does not exist, not printing.t   skip_encoding_cookiei   (   s   .sos   .dlls   .pyd(   R   R9   R   R?   R@   R   RA   RB   RC   R   R   R
   t   read_py_filet   False(   Rt   RH   Ra   R   RI   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   pfile  s    c         C  s   g  } |  j  } | d k r4 t d   | D  } n  xy | D]q \ } } t | j    d k rv | | d  d } n | | d j |   } | j t |  t |   q; Wd j |  S(   s
  Formats a list of fields for display.

        Parameters
        ----------
        fields : list
          A list of 2-tuples: (field_title, field_content)
        title_width : int
          How many characters to pad titles to. Default to longest title.
        i    c         s  s%   |  ] \ } } t  |  d  Vq d S(   i   N(   t   len(   R!   t   titlet   _(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pys	   <genexpr>%  s    i   t   :s   
(   R   t   maxR   t
   splitlinest   ljustRZ   R   R[   (   Rt   t   fieldst   title_widthR   R   R   t   content(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   _format_fields  s    
	!c         C  s~   t  |  } i | d 6d | d d 6} | d k r8 | S| |  } t | t  sm i | d 6d | d d 6St | |  Sd S(   sF  Return a mime bundle representation of the input text.

        - if `formatter` is None, the returned mime bundle has
           a `text/plain` field, with the input text.
           a `text/html` field with a `<pre>` tag containing the input text.

        - if `formatter` is not None, it must be a callable transforming the
          input text into a mime bundle. Default values for `text/plain` and
          `text/html` representations are the ones described above.

        Note:

        Formatters returning strings are supported but this behavior is deprecated.

        s
   text/plains   <pre>s   </pre>s	   text/htmlN(   R   R9   RO   R7   (   Rt   t   textR   Rq   t	   formatted(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   _mime_format.  s    c   
      C  s   | d } d } t  t |    \ } } t d   | D  } xy t | |  D]h \ } } | j d  } d | k r{ d n d }	 | |  j | d  | t |  d |	 | d 7} qN W| | d <| S(   Ns
   text/plainRS   c         s  s   |  ] } t  |  Vq d  S(   N(   R   (   R!   R   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pys	   <genexpr>[  s    s   
R   R   (   t   listt   zipR   t   stripR   R   (
   Rt   t   bundlet
   text_plainR   t   headst   bodiest   _lenR   t   bodyt   delim(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   format_mimeU  s    
9
c   	        s   j  | d | d   d |   i g  d 6d d 6} d+    f d  }  f d   }   d	 rv | | d
 d  n3  d r | d k r | | d d |  n | | d d |  | | d d  n  d s t |  ry| | d d |  | | d d |  | d k r0  d r0| | d d |  n& | | d d |  | | d d |  | | d d  | | d d  n0| | d d |  | | d d |  | | d d  t j rt | t j  r  d r| | d  d  n  | | d! d    d" d# k r| | d$ d"  n  | | d% d&  | | d d  | d k r]| | d d |  n | | d d |  | | d' d( |  | | d d |  | | d) d* |   j |  S(,   s$   Retrieve an info dict and format it.Ra   t   infot   detail_levels
   text/plainRS   s	   text/htmlc           sn     | } | d  k	 rj  j | |  } |  d j | | d f  |  d c d | d | d d 7<n  d  S(   Ns
   text/plains	   text/htmls   <h1>s   </h1>
s   
(   R9   R   RZ   (   R   R   t   keyR   t   fieldt   formatted_field(   R   Rt   (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   append_fieldo  s
    
c           s!   i   j  |   d 6t |   d 6S(   Ns
   text/plains	   text/html(   R   R   (   R   (   Rt   (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   code_formatterv  s    R2   t   ReprR%   R1   i    t   SourceR+   t	   DocstringR*   t   FileR(   R3   t	   SignatureR)   s   Init signatureR,   s   Init docstringR.   t   TypeR#   s   Call signatureR/   R$   s
   Base Classs   String formR&   t   Interactivet	   Namespacet   LengthR'   s   Class docstringR-   s   Call docstringR0   N(	   t   _infoR9   Rj   R   R   RO   R   R   R   (	   Rt   RH   Ra   R   R   R   t   _mimeR   R   (    (   R   Rt   s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt	   _get_infoe  sN    !


&c         C  s<   |  j  | | | | |  } | s+ | d =n  t j |  d S(   s  Show detailed information about an object.

        Optional arguments:

        - oname: name of the variable pointing to the object.

        - formatter: callable (optional)
              A special formatter for docstrings.

              The formatter is a callable that takes a string as an input
              and returns either a formatted string or a mime type bundle
              in the form of a dictionnary.

              Although the support of custom formatter returning a string
              instead of a mime type bundle is deprecated.

        - info: a structure with some information fields which may have been
          precomputed already.

        - detail_level: if set to 1, more information is given.
        s	   text/htmlN(   R   R   (   Rt   RH   Ra   R   R   R   t   enable_html_pager(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   pinfo  s    
c         C  sD   | d k	 r% t j d t d d n  |  j | d | d | d | S(   sN   DEPRECATED. Compute a dict with detailed information about an object.
        sm   The `formatter` keyword argument to `Inspector.info`is deprecated as of IPython 5.0 and will have no effects.t
   stackleveli   Ra   R   R   N(   R9   t   warningst   warnt   DeprecationWarningR   (   Rt   RH   Ra   R   R   R   (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyR     s    	c      	   C  s}  t  |  } | d0 k r- d } d } d } n | j } | j } | j } | r t |  s y d | d }	 Wq d t |  }	 q Xq d t |  }	 | j r |	 d | j 7}	 q n! t |  }	 |	 d0 k r d }	 n  t	 d	 | d
 t
 d | d |  }
 d } t | d d  } | r$d } n | r3d } n	 | j } | |
 d <y | j } t |  |
 d <Wn n X| |  j k ry t |  } d } | rt |  | k r| |  d | | } d d t | j    j d   | j d  D  } n  | |
 | <WqqXn  | r%| |
 d <n  y t t |   |
 d <Wn n Xt } t |  } | d0 k rpt
 } n@ | j d1  rt
 } n | j d  rd } n  t |  |
 d  <| r(t j   yQ t | t  s| rt | |  } | d0 k	 r| j   } n  | |
 d! <n  Wq(t k
 r$q(Xn  |	 rS|
 j d! d0  d0 k rS|	 |
 d" <n  t j  |  rFt
 |
 d# <y |  j! | |  } Wn t" k
 rd0 } n Xy | j# } Wn t" k
 rd0 } n[ X| d0 k ry |  j! | |  } Wqt" k
 rqXn  t |  } | t$ k rd0 } n  | r0| |
 d$ <n  | r| |
 d% <qny|  j! | |  } | rk| |
 d& <n  |	 ry t% | d'  } Wn d0 } n Xt |  } | t& k rd0 } n  | r|	 | k r| |
 d( <qn  y( t | j#  } | t$ k rd0 } n  Wn t" k
 rd0 } n X| r,| |
 d% <n  t' | d)  rt( |  r|  j! | j) |  } | r| |
 j d&  k r| |
 d* <n  t | j)  } | t* k rd0 } n  | r| |
 d+ <qn  t j  |  rt% | d, d0  } n t |  r| } n d0 } | d0 k	 rsy t+ |  } Wn t, t" f k
 r3qsXt	 | j-    |
 d- <} d. | k rs| j. d/  | d. <qsn  t/ |
   S(2   sL  Compute a dict with detailed information about an object.

        Optional arguments:

        - oname: name of the variable pointing to the object.

        - info: a structure with some information fields which may have been
          precomputed already.

        - detail_level: if set to 1, more information is given.
        i    RS   s!   Alias to the system command:
  %si   s   Alias: s	   Alias to s   
Docstring:
s   <no docstring>R6   R5   R2   R1   i   i   i   s   Magic functions   System aliasR#   R$   R%   s    <...> s   
R   c         s  s   |  ] } | j    Vq d  S(   N(   R   (   R!   t   q(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pys	   <genexpr>  s    R&   R'   s   .sos   .dlls   .pyds   <string>s9   Dynamically generated function. No source code available.R(   R+   R*   R3   R,   R.   R)   RW   R-   Rk   R/   R0   R   R4   Rp   t   keywordsN(   s   .sos   .dlls   .pyd(0   R   R9   R1   R2   R&   R   R   t   __doc__R    R7   R   t   intt   __name__RW   R   R   t
   expandtabsR[   t   splitR   R?   R@   R   R   R   RO   RX   R]   t   rstripRN   Ru   R   R3   R   t   AttributeErrorR   t   _object_init_docstringRY   t   _builtin_type_docstringsR   Rj   Rk   t   _func_call_docstringRm   R_   t   _asdictt   popR=   (   Rt   RH   Ra   R   R   t   obj_typeR1   R2   t   ospaceRQ   R   t
   string_maxt   shalft   obj_type_namet   bclasst   ostrt   str_headt   binary_fileR   Rf   t   init_deft   obj_initR   t   deflnt   clst   class_dsR/   R   t   callable_objR4   t   argspec_dict(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyR     s   						!			
	  			



	
	
		c      	   C  sH  d } d } | j    } t |  }	 |	 d k r= | d } n+ |	 d k rX | \ } } n t d |   x9 | D]1 }
 |
 | k ro t d |
 | j   f   qo qo Wt   t   } } xn | D]f } | | } t |  | k r q n  | j t |   t | | | d | d	 | } | j |  q Wt	 j	 d
 j
 t |    d S(   sM  Search namespaces with wildcards for objects.

        Arguments:

        - pattern: string containing shell-like wildcards to use in namespace
          searches and optionally a type specification to narrow the search to
          objects of that type.

        - ns_table: dict of name->namespaces for search.

        Optional arguments:

          - ns_search: list of namespace names to include in search.

          - ignore_case(False): make the search case-insensitive.

          - show_all(False): show all names, including those starting with
            underscores.
        t   allRS   i   i    i   s)   invalid argument string for psearch: <%s>s'   invalid namespace <%s>. Valid names: %st   ignore_caset   show_alls   
N(   R   R   t
   ValueErrort   keyst   sett   idt   addR   R:   R   R[   t   sorted(   Rt   t   patternt   ns_tablet	   ns_searchR  R  t   type_patternt   filtert   cmdst   len_cmdsR6   t   search_resultt   namespaces_seent   ns_namet   nst   tmp_res(    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   psearch  s0    

N(   R   t
   __module__R   R	   t   ANSICodeColorsR9   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R   R  (    (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyR   w  s.   			:'	P	(W   R   t
   __future__R    t   __all__R   R   R   RA   t   textwrapR   R   t   ioRD   t	   itertoolsR   t   ImportErrorR   t   IPython.coreR   t   IPython.lib.prettyR   t   IPython.testing.skipdoctestR   t   IPython.utilsR	   R
   R   t   IPython.utils.dir2R   t   IPython.utils.pathR   t   IPython.utils.textR   t   IPython.utils.wildcardR   t   IPython.utils.coloransiR   R   R   t   IPython.utils.py3compatR   R   R   t   IPython.utils.signaturesR   t   IPython.utils.colorableR   t   pygmentsR   t   pygments.lexersR   t   pygments.formattersR   R   t   FunctionTypeRk   R   t   objectR   R   t
   ModuleTypet
   MethodTypeRX   R   R   R  Rh   R   t   upperRi   t   ColorsR  R   R8   R=   RM   R    R]   Rj   Rm   Rs   R   R}   R^   R?   R   R   (    (    (    s4   lib/python2.7/site-packages/IPython/core/oinspect.pyt   <module>   sp   						?			
5		#	 