o
     ¢i¸  ã                   @   s0   d dl mZ G dd„ deƒZG dd„ deƒZdS )é   )ÚErrorsc                       sL   e Zd ZdZejdœdeddf‡ fdd„Zdd	„ Zdd
d„Z	dd„ Z
‡  ZS )ÚSimpleFrozenDictzãSimplified implementation of a frozen dict, mainly used as default
    function or method argument (for arguments that should default to empty
    dictionary). Will raise an error if user or Weasel attempts to add to dict.
    ©Úerrorr   ÚreturnNc                   s   t ƒ j|i |¤Ž || _dS )z£Initialize the frozen dict. Can be initialized with pre-defined
        values.

        error (str): The error message when user tries to assign to dict.
        N)ÚsuperÚ__init__r   )Úselfr   ÚargsÚkwargs©Ú	__class__© úF/home/ubuntu/.local/lib/python3.10/site-packages/weasel/util/frozen.pyr   
   s   
zSimpleFrozenDict.__init__c                 C   ó
   t | jƒ‚©N©ÚNotImplementedErrorr   )r	   ÚkeyÚvaluer   r   r   Ú__setitem__   ó   
zSimpleFrozenDict.__setitem__c                 C   r   r   r   )r	   r   Údefaultr   r   r   Úpop   r   zSimpleFrozenDict.popc                 C   r   r   r   )r	   Úotherr   r   r   Úupdate   r   zSimpleFrozenDict.updater   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   ÚE001Ústrr   r   r   r   Ú__classcell__r   r   r   r   r      s    	
r   c                       sr   e Zd ZdZejdœdeddf‡ f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‡  ZS )ÚSimpleFrozenLista‚  Wrapper class around a list that lets us raise custom errors if certain
    attributes/methods are accessed. Mostly used for properties like
    Language.pipeline that return an immutable list (and that we don't want to
    convert to a tuple to not break too much backwards compatibility). If a user
    accidentally calls nlp.pipeline.append(), we can raise a more helpful error.
    r   r   r   Nc                   s   || _ tƒ j|Ž  dS )zpInitialize the frozen list.

        error (str): The error message when user tries to mutate the list.
        N)r   r   r   )r	   r   r
   r   r   r   r   %   s   zSimpleFrozenList.__init__c                 O   r   r   r   ©r	   r
   r   r   r   r   Úappend-   r   zSimpleFrozenList.appendc                 O   r   r   r   r$   r   r   r   Úclear0   r   zSimpleFrozenList.clearc                 O   r   r   r   r$   r   r   r   Úextend3   r   zSimpleFrozenList.extendc                 O   r   r   r   r$   r   r   r   Úinsert6   r   zSimpleFrozenList.insertc                 O   r   r   r   r$   r   r   r   r   9   r   zSimpleFrozenList.popc                 O   r   r   r   r$   r   r   r   Úremove<   r   zSimpleFrozenList.removec                 O   r   r   r   r$   r   r   r   Úreverse?   r   zSimpleFrozenList.reversec                 O   r   r   r   r$   r   r   r   ÚsortB   r   zSimpleFrozenList.sort)r   r   r   r   r   ÚE002r!   r   r%   r&   r'   r(   r   r)   r*   r+   r"   r   r   r   r   r#      s    r#   N)Úerrorsr   Údictr   Úlistr#   r   r   r   r   Ú<module>   s    