;ò
ÎÑAHc           @   sï  d  Z  d k l Z d e i d Z e i Z d d g Z d k Z d k	 Z	 d k
 Z
 d k Z d k Z d k Z d k Z d k Z d k l Z d k l Z l Z l Z l Z d	 k l Z d
 k l Z d k Te i d  d d f j o/ d k	 l Z l Z l Z d „  Z e e	 _ n e  Z! e" d h  d e! i# <d e! i# <ƒ Z# e" d h  d e! i$ <d e! i% <ƒ Z& e" d h  d e! i' <d e! i% <ƒ Z( e) e# e& e( g d ƒ Z* d „  Z+ e, d „ Z- d e i f d „  ƒ  YZ. d f  d „  ƒ  YZ/ 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.

$Id: OInspect.py 2843 2007-10-15 21:22:32Z fperez $
(   s   Releases   %s <%s>s   Fernandos	   Inspectors   InspectColorsN(   s
   PyColorize(   s   pages   indents   Terms   mkdict(   s   itpl(   s   list_namespace(   s   *i   i   (   s   ismodules
   getabsfiles   modulesbyfilec         C   s°  t  |  ƒ o |  Sn t |  d ƒ o t i i |  i ƒ Sn y t |  ƒ } Wn t	 j
 o t
 Sn X| t j o t i i t | ƒ Sn xJ t i i ƒ  D]9 } t | d ƒ o# | i t t i i t | ƒ ƒ <q› q› W| t j o t i i t | ƒ Sn t i d } t |  d ƒ o t
 Sn t | |  i ƒ o+ t | |  i ƒ } | |  j o | Sqan t i d } t | |  i ƒ o+ t | |  i ƒ } | |  j o | Sq¬n d S(   sA   Return the module an object was defined in, or None if not found.s
   __module__s   __file__s   __main__s   __name__s   __builtin__N(   s   ismodules   objects   hasattrs   syss   moduless   gets
   __module__s
   getabsfiles   files	   TypeErrors   Nones   modulesbyfiles   valuess   modules   __name__s   oss   paths   realpaths   mains   getattrs
   mainobjects   builtins   builtinobject(   s   objects   builtins   modules   files   builtinobjects
   mainobjects   main(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys	   getmodule.   s:     	 's   NoColors   headers   normals   Linuxs   LightBGc         C   sl   t  } y t i |  ƒ } Wn n Xy |  i ƒ  } Wn n( X| t  j o
 | } n d | | f } | Sd S(   s8  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.s   %s
%sN(   s   Nones   dss   inspects   getdocs   objs   ds2(   s   objs   ds2s   ds(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   getdocn   s     
c         C   s    | o t Sn t i |  ƒ Sd S(   s½  Wrapper around inspect.getsource.

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

    Inputs:

    - obj: an object whose source code we will attempt to extract.

    Optional inputs:

    - is_binary: whether the object is known to come from a binary source.
    This implementation will skip returning any output for binary objects, but
    custom extractors may know how to meaningfully process them.N(   s	   is_binarys   Nones   inspects	   getsources   obj(   s   objs	   is_binary(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys	   getsource‹   s     s
   myStringIOc           B   s   t  Z d  Z d „  Z RS(   s)   Adds a writeln method to normal StringIO.c         O   s!   |  i | | Ž  |  i d ƒ d S(   s$   Does a write() and then a write('
')s   
N(   s   selfs   writes   args   kw(   s   selfs   args   kw(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   writeln¥   s     (   s   __name__s
   __module__s   __doc__s   writeln(    (    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys
   myStringIO£   s    c           B   sž   t  Z d d „ Z d „  Z d d „ Z d „  Z d „  Z d „  Z d d	 „ Z d e	 d
 „ Z
 d d „ Z d d „ Z d e	 e	 d d „ Z g  e e d „ Z RS(   Ni    c         C   sJ   | |  _  t i | d d ƒ|  _ |  i i |  _ | |  _ |  i | ƒ d  S(   Ns   outs   str(
   s   color_tables   selfs
   PyColorizes   Parsers   code_color_tables   parsers   formats   str_detail_levels   set_active_schemes   scheme(   s   selfs   color_tables   code_color_tables   schemes   str_detail_level(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   __init__«   s
    		c         C   sr   t  i | ƒ o
 | } n' t  i | ƒ o | i } n
 t d ‚ t  i | i ƒ \ } } } | | | | i f Sd S(   sÑ  Get the names and default values of a function's arguments.

        A tuple of four things is returned: (args, varargs, varkw, defaults).
        'args' is a list of the argument names (it may contain nested lists).
        'varargs' and 'varkw' are the names of the * and ** arguments or None.
        'defaults' is an n-tuple of the default values of the last n arguments.

        Modified version of inspect.getargspec from the Python Standard
        Library.s   arg is not a Python functionN(   s   inspects
   isfunctions   objs   func_objs   ismethods   im_funcs	   TypeErrors   getargss	   func_codes   argss   varargss   varkws   func_defaults(   s   selfs   objs   argss   varargss   func_objs   varkw(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   __getargspec³   s    	 
	s    c         C   s0   y | t i |  i | ƒ Œ  SWn t Sn Xd S(   sŸ   Return the definition header for any callable object.

        If any exception is generated, None is returned instead and the
        exception is suppressed.N(   s   onames   inspects   formatargspecs   selfs   _Inspector__getargspecs   objs   None(   s   selfs   objs   oname(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   __getdefÇ   s
     c         C   s'   d |  i i i | |  i i i f Sd S(   s*   Return a header string with proper colors.s   %s%s%sN(   s   selfs   color_tables   active_colorss   headers   hs   normal(   s   selfs   h(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   __headÒ   s     c         C   s'   |  i i | ƒ |  i i i | ƒ d  S(   N(   s   selfs   color_tables   set_active_schemes   schemes   parser(   s   selfs   scheme(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   set_active_scheme×   s    c         C   s!   d | G| o d | GHn Hd S(   s-   Generic message when no information is found.s   No %s founds   for %sN(   s   msgs   oname(   s   selfs   msgs   oname(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   noinfoÛ   s
     c         C   sÃ   t  | ƒ o d GHd Sn d } t i | ƒ o |  i d ƒ } | i } n$ t | ƒ t	 i
 j o | i } n |  i | | ƒ } | t j o |  i d | ƒ n t i | I|  i | ƒ Id S(   sz   Print the definition header for any callable object.

        If the object is a class, print the constructor information.s   Object is not callable.Ns    s   Class constructor information:
s   definition header(   s   callables   objs   headers   inspects   isclasss   selfs   _Inspector__heads   __init__s   types   typess   InstanceTypes   __call__s   _Inspector__getdefs   onames   outputs   Nones   noinfos   Terms   couts   format(   s   selfs   objs   onames   headers   output(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   pdefã   s     c   	      C   sú   |  i } t | ƒ } | o | | ƒ } n t i | ƒ o t | i	 ƒ } t d ƒ } nm t | ƒ t i j p t | t ƒ o t | d ƒ o0 t | i ƒ } | o t d ƒ } qÇ | } n | } | t j o |  i d | ƒ d Sn t | ƒ d S(   sž   Print the docstring for any object.

        Optional:
        -formatter: a function to run the docstring through for specially
        formatted docstrings.sV   $head("Class Docstring:")
$indent(ds)
$head("Constructor Docstring"):
$indent(init_ds)s   __call__sR   $head("Class Docstring:")
$indent(ds)
$head("Calling Docstring:")
$indent(call_ds)s   documentationN(   s   selfs   _Inspector__heads   heads   getdocs   objs   dss	   formatters   inspects   isclasss   __init__s   init_dss   itpls   outputs   types   typess   InstanceTypes
   isinstances   objects   hasattrs   __call__s   call_dss   Nones   noinfos   onames   page(	   s   selfs   objs   onames	   formatters   heads   init_dss   call_dss   outputs   ds(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   pdocú   s$     	6
c         C   sK   t  i ƒ  y t | ƒ } Wn |  i d | ƒ n Xt |  i	 | ƒ ƒ d S(   s$   Print the source code for an object.s   sourceN(
   s	   linecaches
   checkcaches	   getsources   objs   srcs   selfs   noinfos   onames   pages   format(   s   selfs   objs   onames   src(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   psource  s     
c         C   s¶   y t  i | ƒ \ } } Wn |  i d | ƒ n€ Xt  i | ƒ } | i
 d ƒ p | i
 d ƒ o d | GHnD t i i | ƒ o d | GHn# t |  i t | ƒ i ƒ  ƒ | ƒ d S(   s0   Show the whole file where an object was defined.s   files   .sos   .dlls    File %r is binary, not printing.s%   File %r does not exist, not printing.N(   s   inspects   getsourceliness   objs   sourceliness   linenos   selfs   noinfos   onames
   getabsfiles   ofiles   endswiths   oss   paths   isfiles   pages   formats   opens   read(   s   selfs   objs   onames   linenos   ofiles   sourcelines(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   pfile&  s      c   $      C   s/  t  | ƒ } |  i } | t j o d } d } d }" n | i } | i	 } | i }" | oq t | ƒ o0 y d | d } WqÇ d t | ƒ } qÇ Xqî d t | ƒ } | i o | d | i 7} qî n$ t | ƒ } | t j o
 d } n | t j	 o | | ƒ } n t ƒ  } d	 } t | d
 d ƒ } | o
 d } n | o
 d } n
 | i } | i | d ƒ | ƒ y* | i }  | i | d ƒ t |  ƒ ƒ Wn n X| |  i j oØ yÊ t | ƒ } d } | o t  | ƒ | j oS | |  d | | } d d t  | i! ƒ  ƒ i" t# t$ i% | i& d ƒ ƒ ƒ } n | i' d ƒ d j o
 d }	 n d }	 | i d | | ƒ |	 | f ƒ WqŒqŒXn |" o | i | d ƒ |" ƒ n y- t t  | ƒ ƒ } | i | d ƒ | ƒ Wn n Xt* } y® y t, i- | ƒ }! Wn9 t/ j
 o- t0 | d ƒ o t, i- | i ƒ }! q=n X|! i1 d ƒ o
 d }! n |! i1 d ƒ p |! i1 d ƒ o
 t2 } n | i | d ƒ |! ƒ Wn t2 } n X|  i3 | | ƒ } | o$ | i6 | d ƒ |  i7 | ƒ ƒ n | o
 | d j o! | i | d  ƒ t8 | ƒ ƒ n | oò t9 i: ƒ  t* } y– y t< | | ƒ } Wn9 t/ j
 o- t0 | d ƒ o t< | i | ƒ } q„n X| t j	 o6 |  i7 | ƒ } | i6 | d! ƒ | i? ƒ  ƒ t2 } n Wn t@ j
 o	 } n X| o | o! | i | d" ƒ t8 | ƒ ƒ qn t, iB | ƒ oè y | iC } Wn tE j
 o t }# } nA X|  i3 | | ƒ }# t | ƒ } | o | iH d# ƒ o
 t } n |# p | oj | i | d$ ƒ ƒ |# o$ | i6 | d ƒ |  i7 |# ƒ ƒ n | o! | i | d  ƒ t8 | ƒ ƒ qq
nÿ| tI iJ j p tK | tL ƒ oÞ| o© y tM | d ƒ } Wn t } n Xt | ƒ } | o- | iH d% ƒ p | iH d& ƒ p | iH d' ƒ o
 t } n | o
 | | j o! | i | d( ƒ t8 | ƒ ƒ qÜn y4 t | iC ƒ } | o | iH d# ƒ o
 t } n Wn tE j
 o t } n X| o! | i | d) ƒ t8 | ƒ ƒ n t0 | d* ƒ o¢ |  i3 | iP | ƒ }
 |
 t j	 o$ | i | d+ ƒ |  i7 |
 ƒ ƒ n t | iP ƒ } | o | iH d, ƒ o
 t } n | o! | i | d- ƒ t8 | ƒ ƒ qq
n | iS ƒ  } | o tU | ƒ n d. S(/   s…  Show detailed information about an object.

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

        - formatter: special formatter for docstrings (see pdoc)

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

        - detail_level: if set to 1, more information is given.
        i    s    s!   Alias to the system command:
  %si   s   Alias: s	   Alias to s   
Docstring:
s   <no docstring>iÈ   i   i   s   Magic functions   System aliass   Type:		s   Base Class:	s   String Form:s    <...> s   
s    iÿÿÿÿs   	s   %s%s%ss   Namespace:	s	   Length:		s	   __class__s   <string>s9   Dynamically generated function. No source code available.s   .sos   .dlls   File:		s   Definition:	s   Docstring:
s   Source:
s%   Docstring [source file open failed]:
s   x.__init__(...) initializess   
Constructor information:s   function(code, globals[,s"   instancemethod(function, instance,s   module(name[,s   Class Docstring:
s   Constructor Docstring:
s   __call__s
   Call def:	s   x.__call__(...) <==> x(...)s   Call docstring:
N(V   s   types   objs   obj_types   selfs   _Inspector__heads   headers   infos   Nones   ismagics   isaliass   ospaces	   namespaces   callables   dss   strs   __doc__s   getdocs	   formatters
   myStringIOs   outs
   string_maxs   ints   shalfs   obj_type_names   __name__s   writelns	   __class__s   bclasss   detail_levels   str_detail_levels   ostrs   str_heads   lens
   expandtabss   joins   maps   strings   strips   splits   finds   str_seps   lengths   Falses   binary_files   inspects
   getabsfiles   fnames	   TypeErrors   hasattrs   endswiths   Trues   _Inspector__getdefs   onames   deflns   writes   formats   indents	   linecaches
   checkcaches   source_successs	   getsources   srcs   sources   rstrips	   Exceptions   msgs   isclasss   __init__s   obj_inits   AttributeErrors   init_defs   init_dss
   startswiths   typess   InstanceTypes
   isinstances   objects   getattrs   clss   class_dss   __call__s   call_defs   call_dss   getvalues   outputs   page($   s   selfs   objs   onames	   formatters   infos   detail_levels   binary_files   str_heads   headers   str_seps   call_defs   obj_type_names   obj_inits   ismagics   outs   obj_types   sources
   string_maxs   msgs   deflns   clss   isaliass   shalfs   source_successs   outputs   class_dss   init_dss   ostrs   dss   srcs   call_dss   lengths   bclasss   fnames   ospaces   init_def(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   pinfo:  s    	
			

	

		! <
$ 
 

$!
%
$) 
7
%!$
)c      
   C   s  d }	 d }
 | i ƒ  } t | ƒ } | d j o | d }
 n. | d j o | \ }
 }	 n t d | ƒ ‚ x; | D]3 } | | j o  t d | | i ƒ  f ƒ ‚ qs qs Wg  } xI | D]A } | | } t t | |	 |
 d | d	 | ƒƒ } | i | ƒ q· W| i ƒ  t d
 i | ƒ ƒ d S(   sO  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.
        s   alls    i   i    i   s)   invalid argument string for psearch: <%s>s'   invalid namespace <%s>. Valid names: %ss   ignore_cases   show_alls   
N(   s   type_patterns   filters   patterns   splits   cmdss   lens   len_cmdss
   ValueErrors	   ns_searchs   names   ns_tables   keyss   search_results   ns_names   nss   lists   list_namespaces   ignore_cases   show_alls   tmp_ress   extends   sorts   pages   join(   s   selfs   patterns   ns_tables	   ns_searchs   ignore_cases   show_alls   len_cmdss   names   nss   type_patterns   filters   ns_names   cmdss   tmp_ress   search_result(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   psearch  s0      $ 

(   s   __name__s
   __module__s   __init__s   _Inspector__getargspecs   _Inspector__getdefs   _Inspector__heads   set_active_schemes   noinfos   pdefs   Nones   pdocs   psources   pfiles   pinfos   Falses   psearch(    (    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys	   Inspectorª   s   				 à(0   s   __doc__s   IPythons   Releases   authorss
   __author__s   licenses   __license__s   __all__s   __builtin__s   inspects	   linecaches   strings   StringIOs   typess   oss   syss
   PyColorizes   IPython.genutilss   pages   indents   Terms   mkdicts   IPython.Itpls   itpls   IPython.wildcards   list_namespaces   IPython.ColorANSIs   version_infos   ismodules
   getabsfiles   modulesbyfiles	   getmodules
   TermColorss   Colorss   ColorSchemes   NoColors   LightReds   Normals   LinuxColorss   Reds   LightBGColorss   ColorSchemeTables   InspectColorss   getdocs   Falses	   getsources
   myStringIOs	   Inspector(    s
   myStringIOs   __builtin__s	   getsources
   getabsfiles
   PyColorizes   __all__s   NoColors   LightBGColorss   Terms   strings   __license__s   inspects   list_namespaces
   __author__s   syss   Releases   mkdicts   typess   InspectColorss   getdocs   indents   StringIOs   ismodules   modulesbyfiles	   linecaches   Colorss	   getmodules	   Inspectors   LinuxColorss   oss   pages   itpl(    (    s@   /nyx/web/d/b/dbachman/work/src/ipython-0.8.4/IPython/OInspect.pys   ?
   s>   											 '''		