
    ]j                     N    d dl mZ d dlmZmZmZmZmZmZ ddZ	 G d de      Z
y)    )	BaseModel)DictOptionalListTupleAnyCallableNc                     | j                         }|r||v r|j                  |      S |j                  | j                               }|S ) )lowerget)namedefault_mapping
re_mappinglc_name
class_names        O/root/env/lib/python3.12/site-packages/label_studio_sdk/label_interface/base.pyget_tag_classr      sB    jjlGg+~~g&&$((6
    c                       e Zd ZU dZi Zee   ed<   dZee	   ed<   dde	de
de
fd	Z	 	 	 	 dd
e	dee	   dee   dee	   dee   defdZy)LabelStudioTagz
    Base class for a LabelStudio Tag

    Attributes:
    -----------
    attr: Optional[Dict]
        A dictionary of attributes for the tag
    tag: Optional[str]
        The tag name
    attr tagN	attr_namedefaultreturnc                     | j                   s|S | j                   j                  |      }|)| j                   j                  |j                               }|#t        |t              r|j                         dk(  r|S |S )zGet a raw attribute value by name, with case-insensitive fallback.

        Returns ``default`` when the attribute is missing or blank.
        r   )r   r   r   
isinstancestrstrip)selfr   r   values       r   get_attrzLabelStudioTag.get_attr   se    
 yyN		i(=IIMM)//"34E=Zs38KNr   tag_typer   name_filter_fnto_nameto_name_filter_fnc                    t        |t              r|j                         }n"t        |t              rt        d |D              }|r|j                         }|r|j                         }t        |t              r| j                  j                         |k7  s,t        |t              r| j                  j                         |vry|r| j
                  j                         |k7  ry|r! || j
                  j                               sy|r| j                  j                         |k7  ry|r! || j
                  j                               syy)a  
        This method checks if the current instance of LabelStudioTag matches the provided parameters.

        Parameters:
        -----------
        tag_type : str
            The type of the tag to match. It can be a string or a tuple of strings.
        name : Optional[str]
            The name of the tag to match. If provided, it should match the name of the current instance.
        name_filter_fn : Optional[Callable]
            A function to filter the name of the tag. If provided, the function should return True for a match.
        to_name : Optional[str]
            The 'to_name' attribute of the tag to match. If provided, it should match the 'to_name' of the current instance.
        to_name_filter_fn : Optional[Callable]
            A function to filter the 'to_name' of the tag. If provided, the function should return True for a match.

        Returns:
        --------
        bool
            True if the current instance matches the provided parameters, False otherwise.
        c              3   <   K   | ]  }|j                           y wN)r   ).0ts     r   	<genexpr>z'LabelStudioTag.match.<locals>.<genexpr>L   s     91QWWY9s   FT)r   r    r   tupler   r   r'   )r"   r%   r   r&   r'   r(   s         r   matchzLabelStudioTag.match,   s    : h$~~'H%(999H::<DmmoGx%$((..*:h*Fx'DHHNN,<H,LDIIOO%-.1B"Ct||))+w6%6tyy7H%Ir   r+   )NNNN)__name__
__module____qualname____doc__r   r   r   __annotations__r   r    r   r$   r	   boolr0    r   r   r   r      s    	 D(4.C##  s " #-1!%0499 sm9 !*	9
 #9 $H-9 
9r   r   r+   )pydanticr   typingr   r   r   r   r   r	   r   r   r7   r   r   <module>r:      s!     = =VY Vr   