
    yIf8                    h    d dl mZ d dlmZ d dlmZmZmZmZ d dl	m
Z
mZmZmZ  G d d          ZdS )    )annotations)NoReturn)DeletedMessageErrorInvalidMessageErrorMessageBecameExtensionErrorUnknownMessageError)is_deleted_msgidis_deleted_symbolis_moved_msgidis_moved_symbolc                      e Zd ZdZddZddZddZd d
Zd!dZd"dZ	d#dZ
d$dZd#dZed%d            Zed&d            Zd'dZdS )(MessageIdStorezpThe MessageIdStore store MessageId and make sure that there is a 1-1 relation
    between msgid and symbol.
    returnNonec                >    i | _         i | _        i | _        i | _        d S N) _MessageIdStore__msgid_to_symbol _MessageIdStore__symbol_to_msgid_MessageIdStore__old_names_MessageIdStore__active_msgidsselfs    S/var/www/piapp/venv/lib/python3.11/site-packages/pylint/message/message_id_store.py__init__zMessageIdStore.__init__   s(    13131357    intc                *    t          | j                  S r   )lenr   r   s    r   __len__zMessageIdStore.__len__"   s    4)***r   strc                j    d}| j                                         D ]\  }}|d| d| dz  }|dz  }|S )NzMessageIdStore: [
z  - z (z)
])r   items)r   resultmsgidsymbols       r   __repr__zMessageIdStore.__repr__%   sW    &!399;; 	2 	2ME61U11f1111FF#r   r%   c                    	 | j         |                                         S # t          $ r}d| d}t          |          |d }~ww xY wN'z%' is not stored in the message store.)r   upperKeyErrorr   )r   r%   emsgs       r   
get_symbolzMessageIdStore.get_symbol,   s\    	2)%++--88 	2 	2 	2BeBBBC%c**1	2s   ! 
AAAr&   c                n    	 | j         |         S # t          $ r}d| d}t          |          |d }~ww xY wr)   )r   r,   r   )r   r&   r-   r.   s       r   	get_msgidzMessageIdStore.get_msgid3   sT    	2)&11 	2 	2 	2CfCCCC%c**1	2s    
4/4	old_nameslist[tuple[str, str]]c                    |                      ||           |                     ||           |D ]2\  }}|                      ||           |                     |||           3d S r   )check_msgid_and_symboladd_msgid_and_symboladd_legacy_msgid_and_symbol)r   r%   r&   r2   	old_msgid
old_symbols         r   register_message_definitionz*MessageIdStore.register_message_definition:   s     	##E6222!!%000%. 	K 	K!Iz''	:>>>,,Y
EJJJJ	K 	Kr   c                .    || j         |<   || j        |<   dS )zAdd valid message id.

        There is a little duplication with add_legacy_msgid_and_symbol to avoid a function call,
        this is called a lot at initialization.
        N)r   r   )r   r%   r&   s      r   r6   z#MessageIdStore.add_msgid_and_symbolC   s$     )/u%).v&&&r   	new_msgidc                    || j         |<   || j        |<   | j                            |g           }|                    |           || j        |<   dS )zAdd valid legacy message id.

        There is a little duplication with add_msgid_and_symbol to avoid a function call,
        this is called a lot at initialization.
        N)r   r   r   getappend)r   r%   r&   r<   existing_old_namess        r   r7   z*MessageIdStore.add_legacy_msgid_and_symbolL   s^     )/u%).v&!-11%<<!!),,,"4r   c                    | j                             |          }| j                            |          }||d S |||k    r|                     |||           |r||k    r|                     |||           d S d S d S r   )r   r>   r   _raise_duplicate_msgid_raise_duplicate_symbol)r   r%   r&   existing_msgidexisting_symbols        r   r5   z%MessageIdStore.check_msgid_and_symbolZ   s    %)%;%?%?%G%G&*&<&@&@&G&G"~'=F%&&++FE>JJJ 	I&88((HHHHH	I 	I88r   other_symbolr   c                    ||g}|                                  d|  d}|d|d          d|d          dz  }t          |          )z+Raise an error when a symbol is duplicated.zMessage id 'z' cannot have both r*   r   ' and '   z' as symbolic name.sortr   )r%   r&   rF   symbolserror_messages        r   rC   z&MessageIdStore._raise_duplicate_symbolf   s_     <(AuAAAOWQZOO
OOOO!-000r   other_msgidc           	         ||g}|                                  d|  d|d          d|d          d|  d	}t          |          )z*Raise an error when a msgid is duplicated.zMessage symbol 'z' cannot be used for 'r   rH   rI   z?' at the same time. If you're creating an 'old_names' use 'old-z' as the old symbol.rJ   )r&   r%   rN   msgidsrM   s        r   rB   z%MessageIdStore._raise_duplicate_msgido   s     %Xv X Xq	X X"()X X;AX X X 	
 "-000r   msgid_or_symbol	list[str]c                f   	 | j         |         S # t          $ r Y nw xY wd}d}|dd                                         rQ|                                }| j                            |          }|s t          |          }|t          |          }n>|}| j                            |          }|s t          |          }|t          |          }|r|s9|t          ||          |t          ||          d| d}t          |          | j                            ||g          }|| j         |<   |S )zReturn msgids but the input can be a symbol.

        self.__active_msgids is used to implement a primitive cache for this function.
        NrI   zNo such message id or symbol 'z'.)r   r,   isdigitr+   r   r>   r	   r   r   r
   r   r   r   r   r   )r   rQ   deletion_reasonmoved_reasonr%   r&   	error_msgidss           r   get_active_msgidsz MessageIdStore.get_active_msgids{   sv   
	'88 	 	 	D	
 122&&(( 	;#))++E+//66F 9"25"9"9"*#1%#8#8L$F*..??E ;"3F";";"*#26#:#:L 	1F 	1*)/?KKK'1/<PPPLLLLI%i000""55'2203_-
s    
N)r   r   )r   r   )r   r    )r%   r    r   r    )r&   r    r   r    )r%   r    r&   r    r2   r3   r   r   )r%   r    r&   r    r   r   )r%   r    r&   r    r<   r    r   r   )r%   r    r&   r    rF   r    r   r   )r&   r    r%   r    rN   r    r   r   )rQ   r    r   rR   )__name__
__module____qualname____doc__r   r   r'   r/   r1   r:   r6   r7   r5   staticmethodrC   rB   rY    r   r   r   r      s.        8 8 8 8+ + + +   2 2 2 22 2 2 2K K K K/ / / /5 5 5 5
I 
I 
I 
I 1 1 1 \1 	1 	1 	1 \	1' ' ' ' ' 'r   r   N)
__future__r   typingr   pylint.exceptionsr   r   r   r   #pylint.message._deleted_message_idsr	   r
   r   r   r   r_   r   r   <module>rd      s   
 # " " " " "                            K K K K K K K K K Kr   