o
    iE	                     @   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   Z/var/www/html/karishye-ai-python/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    