
    f                     l    d Z ddlZddlZddlmZ dgfdZ e       \  ZZd ZddZ	d Z
	 	 dd	Zdd
Zy)u   Support for wildcard pattern matching in object inspection.

Authors
-------
- Jörgen Stenarson <jorgen.stenarson@bostream.nu>
- Thomas Kluyver
    N)dir2lambdac                     t        t              D cg c]  }|j                  d      s| }}i i }}|D ]4  }|dd j                         }t	        t        |      }|||<   || vs0|||<   6 ||fS c c}w )zzReturn dictionaries mapping lower case typename (e.g. 'tuple') to type
    objects from the types package, and vice versa.TypeN)dirtypesendswithlowergetattr)dont_include_in_type2typestrtnametypenamelisttypestr2typetype2typestrnameobjs          Q/var/www/cvtools/html/venv/lib/python3.12/site-packages/IPython/utils/wildcard.pycreate_typestr2type_dictsr      s     (+5zLeU^^F5KELLL!#R,L %Sbz!eU# T33 $L% %% Ms
   A0A0c                     |dk(  ryt        |      t         k(  r|}nt        j                  |d      }|rt        | |      S y)a  is_type(obj, typestr_or_type) verifies if obj is of a certain type. It
    can take strings or actual python types for the second argument, i.e.
    'tuple'<->TupleType. 'all' matches all types.

    TODO: Should be extended for choosing more than one type.allTF)typer   get
isinstance)r   typestr_or_type	test_types      r   is_typer   &   sF     %O$#	 $$_e<	#y))    c                 T    |xs% | j                  d      xs | j                  d       S )zCReturn true for strings starting with single _ if show_all is true.___)
startswith)strshow_alls     r   show_hiddenr%   6   s'    Fs~~d+F3>>#3F/FFr   c                 h    i }t        |       D ]  }	 t        | |      ||<    |S # t        $ r Y "w xY w)zwProduce a dictionary of an object's attributes. Builds on dir2 by
    checking that a getattr() call actually succeeds.)r   r   AttributeError)r   nskeys      r   dict_dirr*   :   sL     
BCy 
S#&2c7
 I  s   %	11c                    |j                  dd      j                  dd      }|r(t        j                  |dz   t        j                        nt        j                  |dz         t	        fd| j                         D              S )z<Filter a namespace dictionary by name pattern and item type.*z.*?.$c              3      K   | ]5  \  }}j                  |      st        |      rt        |      r||f 7 y w)N)matchr%   r   ).0r)   r   regr$   type_patterns      r   	<genexpr>zfilter_ns.<locals>.<genexpr>U   s@      Mhc3		#0;C0J07\0J S	 Ms   >!>)replacerecompileIdictitems)r(   name_patternr4   ignore_caser$   patternr3   s     ` ` @r   	filter_nsr?   K   sv     ""3t,44S=Gjjbdd+jj%  M"((* M M Mr   c           
      ^   |j                  d      }t        |      dk(  rt        | |d   |||      S t        | |d   d||      }i }|j                         D ]R  \  }}	t	        t        |	      |dj                  |dd       ||      }
|
j                         D ]  \  }}|||d|<    T |S )zbReturn dictionary of all objects in a namespace dictionary that match
    type_pattern and filter.r.      r   )r<   r4   r=   r$   r   N)r=   r$   )splitlenr?   r;   list_namespacer*   join)	namespacer4   filterr=   r$   pattern_listfilteredresultsr   r   r(   
inner_name	inner_objs                r   rD   rD   Y   s     c"L
<A	Q%1$/(D D Y\!_).(3hH !) 	?ID#| #ab)9 :,7(LB *, ?%
I5>j12?		? r   )F)r,   r   TT)FF)__doc__r7   r	   IPython.utils.dir2r   r   r   r   r   r%   r*   r?   rD    r   r   <module>rP      sS    
  #<D: & 78 l G" EIMr   