
    i|                        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Z	 d	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 	 	 dd	Zdd
Z	 	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 ddZ	 d	 	 	 	 	 	 	 ddZy)zText Utilities.    )annotationsN)SequenceMatcher)IterableIterator)version_info_tc                8    dj                  fd| D              S )z2Escape string for use within a regular expression. c              3  b   K   | ]&  }|j                         s|v r|n|d k(  rdnd|z    ( yw) z\000\N)isalnum).0cwhites     p/var/www/html/hwPaymentPortal-be-dev/hw-payment-portal-api/venv/lib/python3.12/site-packages/kombu/utils/text.py	<genexpr>zescape_regex.<locals>.<genexpr>   s9       YY[AJVWPQRs   ,/)join)pr   s    `r   escape_regexr      s#     77       c              #  h   K   |D ])  }t        d| |      j                         }||k\  s$||f + yw)zVFuzzy match: iteratively.

    Yields
    ------
        Tuple: of ratio and key.
    N)r   ratio)needlehaystack	min_ratiokeyr   s        r   fmatch_iterr      s@       fc288:I*s   &2	2c                ^    	 t        t        | ||      d      d   d   S # t        $ r Y yw xY w)z'Fuzzy match - Find best match (scalar).T)reverser      N)sortedr   
IndexError)r   r   r   s      r   fmatch_bestr#   (   sK    )4
 	

  	  s     	,,c                   d}|dz  }|dz  }|dz  }|dz  }t        j                  ||       }|st        d|        t        |j	                  d            }|j	                  d      rt        |j	                  d            nd}|j	                  d	      rt        |j	                  d	            nd}|j	                  d
      r|j	                  d
      nd}|j	                  d      r|j	                  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)versionpatternr*   majorminormicroreleaselevelserials           r   version_string_as_tupler6   7   s    ( GGG33G~G HHWg&E3G9=>> AE#(;;q>CAqE#(;;q>CAqE%*[[^5;;q>L${{1~U[[^2F5%fEEr   c                V    t        t        |       t        |      t        |      ||      S )N)r   r,   )r1   r2   r3   r4   r5   s        r   r.   r.   a   s#     #e*c%j#e*lFSSr   c                    t        |       D ]  \  }}|j                         r n t        | xs d      ||fS t        | d |       | |d  |fS )Nr   )	enumerateisdigitr,   )r3   r4   r5   indexchars        r   _splitmicror=   k   s]     !' 5t||~5 5:Af44uVe}uUV}f44r   )r	   )g333333?)r   strr   Iterable[str]r   floatreturnzIterator[tuple[float, str]])r   r>   r   r?   r   r@   rA   z
str | None)r/   r>   rA   r   )r   r   r   r	   r	   )r1   	str | intr2   rB   r3   rB   r4   r>   r5   r>   rA   r   )r	   r	   )r3   r>   r4   r>   r5   r>   rA   ztuple[int, str, str])__doc__
__future__r   r)   difflibr   typingr   r   kombur   r   r   r#   r6   r.   r=    r   r   <module>rI      s    
 # 	 # %   >A(5:   >A(5:'FV TTT T 	T
 T T 7955!50355r   