o
    ­ƒðjE	  ã                   @   s¸   U d Z ddlZddlmZ ddlmZ ddlmZmZm	Z	 ddl
mZ e d e d	 ee	 ¡¡¡ej¡Zeed
< deddfdd„Zd	g ddfdededee dededefdd„ZdS )zA
.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>
é    N)ÚSequence)ÚFinalé   )Úascii_symbolsÚto_strÚunprintable_ascii_chars)ÚInvalidCharErrorú[{}]Ú Ú__RE_SYMBOLÚtextÚreturnc                 C   s$   t  t| ƒ¡}|rtd|› �ƒ‚dS )zü
    Verifying whether symbol(s) included in the ``text`` or not.

    Args:
        text:
            Input text to validate.

    Raises:
        ValidationError (ErrorReason.INVALID_CHARACTER):
            If symbol(s) included in the ``text``.
    zinvalid symbols found: N)r   Úfindallr   r   )r   Ú
match_list© r   ú–/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/pathvalidate/_symbol.pyÚvalidate_symbol   s   ÿr   FÚreplacement_textÚexclude_symbolsÚis_replace_consecutive_charsÚis_stripc                 C   sž   |rt  d t  d ttt ƒt|ƒ ¡¡¡t j¡}nt	}z
| 
|t| ƒ¡}W n ty2   tdƒ‚w |s7|S |rFt  
t  |¡› d�||¡}|rM| |¡}|S )ag  
    Replace all of the symbols in the ``text``.

    Args:
        text:
            Input text.
        replacement_text:
            Replacement text.
        exclude_symbols:
            Symbols that were excluded from the replacement.
        is_replace_consecutive_chars:
            If |True|, replace consecutive multiple ``replacement_text`` characters
            to a single character.
        is_strip:
            If |True|, strip ``replacement_text`` from the beginning/end of the replacement text.

    Returns:
        A replacement string.

    Example:

        :ref:`example-sanitize-symbol`
    r	   r
   ztext must be a stringú+)ÚreÚcompileÚformatÚescapeÚjoinÚsetr   r   ÚUNICODEr   Úsubr   Ú	TypeErrorÚstrip)r   r   r   r   r   ÚregexpÚnew_textr   r   r   Úreplace_symbol$   s,   ÿÿú	ÿ
r$   )Ú__doc__r   Úcollections.abcr   Útypingr   Ú_commonr   r   r   Úerrorr   r   r   r   r   r   r   Ú__annotations__Ústrr   Úboolr$   r   r   r   r   Ú<module>   s6    ÿûÿþýüûú