o
    —¨Êh|  ã                   @  s˜   d Z ddlmZ ddlZddlmZ ddlmZmZ ddl	m
Z
 d'dd	„Z	
d(d)dd„Z	
d(d*dd„Zd+dd„Z					d,d-d"d#„Z	d.d/d%d&„ZdS )0zText Utilities.é    )ÚannotationsN)ÚSequenceMatcher)ÚIterableÚIterator)Úversion_info_tÚ c                   s   d  ‡ fdd„| D ƒ¡S )z2Escape string for use within a regular expression.r   c                 3  s8   � | ]}|  ¡ s|ˆ v r|n	|d krdnd| V  qdS )ú z\000ú\N)Úisalnum)Ú.0Úc©Úwhite© úB/var/www/html/env/lib/python3.10/site-packages/kombu/utils/text.pyÚ	<genexpr>   s
   € &ÿ
ÿzescape_regex.<locals>.<genexpr>)Újoin)Úpr   r   r   r   Úescape_regex   s   þr   ç333333ã?ÚneedleÚstrÚhaystackúIterable[str]Ú	min_ratioÚfloatÚreturnúIterator[tuple[float, str]]c                 c  s2   � |D ]}t d| |ƒ ¡ }||kr||fV  qdS )zVFuzzy match: iteratively.

    Yields
    ------
        Tuple: of ratio and key.
    N)r   Úratio)r   r   r   Úkeyr   r   r   r   Úfmatch_iter   s   €	
€ýr    ú
str | Nonec                 C  s4   zt t| ||ƒdd�d d W S  ty   Y dS w )z'Fuzzy match - Find best match (scalar).T)Úreverser   é   N)Úsortedr    Ú
IndexError)r   r   r   r   r   r   Úfmatch_best(   s   
þüûÿr&   Úversionr   c                 C  sÈ   d}|d7 }|d7 }|d7 }|d7 }t  || ¡}|s!td| › �ƒ‚t| d¡ƒ}| d¡r4t| d¡ƒnd}| d	¡rBt| d	¡ƒnd}| d
¡rN| d
¡nd}| d¡rZ| d¡nd}t|||||ƒS )aa  Parse a version string into its components and return a version_info_t tuple.

    The version string is expected to follow the pattern:
    'major.minor.micro[releaselevel][serial]'. Each component of the version
    is extracted and returned as a tuple in the format (major, minor, micro,
    releaselevel, serial).

    Args
    ----
        version (str): The version string to parse.

    Returns
    -------
        version_info_t: A tuple containing the parsed version components.

    Raises
    ------
        ValueError: If the version string is invalid and does not match the expected pattern.
    z^(\d+)z(?:\.(\d+))?z!(?:\.*([a-zA-Z+-][\da-zA-Z+-]*))?z(?:\.(.*))?zInvalid version string: r#   é   r   é   é   r   é   )ÚreÚmatchÚ
ValueErrorÚintÚgroupÚ_unpack_version)r'   Úpatternr-   ÚmajorÚminorÚmicroÚreleaselevelÚserialr   r   r   Úversion_string_as_tuple7   s   r8   r3   ú	str | intr4   r5   r6   r7   c                 C  s   t t| ƒt|ƒt|ƒ||ƒS )N)r   r/   )r3   r4   r5   r6   r7   r   r   r   r1   a   s   r1   útuple[int, str, str]c                 C  sN   t | ƒD ]
\}}| ¡ s n
qt| pdƒ||fS t| d |… ƒ| |d … |fS )Nr   )Ú	enumerateÚisdigitr/   )r5   r6   r7   ÚindexÚcharr   r   r   Ú_splitmicrok   s   ÿr?   )r   )r   )r   r   r   r   r   r   r   r   )r   r   r   r   r   r   r   r!   )r'   r   r   r   )r   r   r   r   r   )r3   r9   r4   r9   r5   r9   r6   r   r7   r   r   r   )r   r   )r5   r   r6   r   r7   r   r   r:   )Ú__doc__Ú
__future__r   r,   Údifflibr   Útypingr   r   Úkombur   r   r    r&   r8   r1   r?   r   r   r   r   Ú<module>   s(    
ÿÿ
+ûÿ