Format: application/x-python-code
⬇ Download File (3.3 KB)
   1  o
   2  
   3  ��h�@sndZddlZddlZddlmZdgfdd�Ze�\ZZdd�Zdd
   4  d�Z	dd
   5  �Z
   6  		ddd�Zddd�ZdS)u�Support for wildcard pattern matching in object inspection.
   7  
   8  Authors
   9  -------
  10  - Jörgen Stenarson <jorgen.stenarson@bostream.nu>
  11  - Thomas Kluyver
  12  �N)�dir2�lambdacCs`dd�tt�D�}ii}}|D]}|dd���}tt|�}|||<||vr+|||<q||fS)zzReturn dictionaries mapping lower case typename (e.g. 'tuple') to type
  13      objects from the types package, and vice versa.cSsg|]	}|�d�r|�qS)�Type)�endswith)�.0�tname�r�Lc:\Users\shubh\Videos\agent\nova\Lib\site-packages\IPython/utils/wildcard.py�
  14  <listcomp>sz-create_typestr2type_dicts.<locals>.<listcomp>N�����)�dir�types�lower�getattr)Zdont_include_in_type2typestrZtypenamelist�typestr2type�type2typestrr�name�objrrr	�create_typestr2type_dictss
  15  
  16  �rcCs<|dkrdSt|�tkr|}nt�|d�}|rt||�SdS)ais_type(obj, typestr_or_type) verifies if obj is of a certain type. It
  17      can take strings or actual python types for the second argument, i.e.
  18      'tuple'<->TupleType. 'all' matches all types.
  19  
  20      TODO: Should be extended for choosing more than one type.�allTF)�typer�get�
  21  isinstance)rZtypestr_or_typeZ	test_typerrr	�is_type&s
  22  rFcCs|p|�d�p|�d�S)zCReturn true for strings starting with single _ if show_all is true.�__�_)�
  23  startswith)�str�show_allrrr	�show_hidden6src	Cs:i}t|�D]}z	t||�||<WqtyYqw|S)zwProduce a dictionary of an object's attributes. Builds on dir2 by
  24      checking that a getattr() call actually succeeds.)rr�AttributeError)r�ns�keyrrr	�dict_dir:s�r#�*rTcsX|�dd��dd�}|rt�|dtj��nt�|d��t���fdd�|��D��S)z<Filter a namespace dictionary by name pattern and item type.r$z.*�?�.�$c3s:�|]\}}��|�rt|��rt|��r||fVqdS)N)�matchrr)rr"r��regr�type_patternrr	�	<genexpr>Us���zfilter_ns.<locals>.<genexpr>)�replace�re�compile�I�dict�items)r!�name_patternr+�ignore_caser�patternrr)r	�	filter_nsKs
  25  r6c
  26  	Cs�|�d�}t|�dkrt||d|||d�St||dd||d�}i}|��D]'\}}	tt|	�|d�|dd��||d�}
  27  |
  28  ��D]\}}||d||f<qAq'|S)	zbReturn dictionary of all objects in a namespace dictionary that match
  29      type_pattern and filter.r&�r)r3r+r4rrN)r4rz%s.%s)�split�lenr6r2�list_namespacer#�join)
  30  �	namespacer+�filterr4rZpattern_list�filtered�resultsrrr!Z
  31  inner_nameZ	inner_objrrr	r:Ys(
  32  
  33  �
  34  �
  35  ��r:)F)r$rTT)FF)
  36  �__doc__r.r
  37  ZIPython.utils.dir2rrrrrrr#r6r:rrrr	�<module>s
  38  
  39  
  40  �