
    Mh                     t    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dS )u   Support for wildcard pattern matching in object inspection.

Authors
-------
- Jörgen Stenarson <jorgen.stenarson@bostream.nu>
- Thomas Kluyver
    N)dir2lambdac                     d t          t                    D             }i i }}|D ]A}|dd                                         }t          t          |          }|||<   || vr|||<   B||fS )zzReturn dictionaries mapping lower case typename (e.g. 'tuple') to type
    objects from the types package, and vice versa.c                 <    g | ]}|                     d           |S )Type)endswith).0tnames     V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/IPython/utils/wildcard.py
<listcomp>z-create_typestr2type_dicts.<locals>.<listcomp>   s)    LLLeU^^F5K5KLELLL    N)dirtypeslowergetattr)dont_include_in_type2typestrtypenamelisttypestr2typetype2typestrr
   nameobjs          r   create_typestr2type_dictsr      s     MLs5zzLLLL!#R,L % %SbSz!!eU## T333 $L%%r   c                     |dk    rdS t          |          t           k    r|}nt                              |d          }|rt          | |          S dS )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!   &   s`     %tO$$#		 $$_e<<	 *#y)))5r   Fc                 \    |p*|                      d          p|                      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>>#3F3F/FFr   c                 v    i }t          |           D ]&}	 t          | |          ||<   # t          $ r Y #w xY w|S )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-   :   s]     
BCyy 
 
S#&&2c77   4Is   )
66*r   Tc                 2   |                     dd                               dd          }|r#t          j        |dz   t          j                  nt          j        |dz             t	          fd|                                 D                       S )z<Filter a namespace dictionary by name pattern and item type.r.   z.*?.$c              3      K   | ]@\  }}                     |          t          |          *t          |          :||fV  Ad S )N)matchr(   r!   )r	   r,   r   regr'   type_patterns      r   	<genexpr>zfilter_ns.<locals>.<genexpr>U   s{       M Mhc3		# M0;C0J0JM07\0J0JMS	 M M M M M Mr   )replacerecompileIdictitems)r+   name_patternr6   ignore_caser'   patternr5   s     ` ` @r   	filter_nsrA   K   s     ""3t,,44S==G &jbd++j%%  M M M M M M"((** M M M M M Mr   c           
         |                     d          }t          |          dk    rt          | |d         |||          S t          | |d         d||          }i }|                                D ]e\  }}	t	          t          |	          |d                    |dd                   ||          }
|
                                D ]\  }}|||d|<   f|S )zbReturn dictionary of all objects in a namespace dictionary that match
    type_pattern and filter.r1      r   )r>   r6   r?   r'   r   N)r?   r'   )splitlenrA   r=   list_namespacer-   join)	namespacer6   filterr?   r'   pattern_listfilteredresultsr   r   r+   
inner_name	inner_objs                r   rF   rF   Y   s    c""L
<A	Q%1$/(D D D D Y\!_).(3hH H H !)) 	? 	?ID#| #abb)9 : :,7(L L LB *, ? ?%
I5>jj122?r   )F)r.   r   TT)FF)__doc__r9   r   IPython.utils.dir2r   r   r   r   r!   r(   r-   rA   rF    r   r   <module>rR      s     
			  # # # # # #<D: & & & & 7688 l   G G G G  " EIM M M M     r   