o
    f#
                     @   s   d dl mZ d dlZd dlZd dlmZ ejd  dkZdd Zdd Z	d	d
 Z
dd Zeddd eddD ZerGedd eD ZeZdd Zdd Zdd ZdddZdd ZdS )     )unicode_literalsN)StringProcessor   c                 C   s$   zt | dkW S  ty   Y dS w )zn
    Check input has length and that length > 0

    :param s:
    :return: True if len(s) > 0 else False
    r   F)len	TypeErrors r	   I/home/ubuntu/webapp/venv/lib/python3.10/site-packages/fuzzywuzzy/utils.pyvalidate_string   s
   r   c                       t   fdd}|S )Nc                     s"   | d | d kr
dS  | i |S )Nr      d   r	   argskwargsfuncr	   r
   	decorator   s   z(check_for_equivalence.<locals>.decorator	functoolswrapsr   r   r	   r   r
   check_for_equivalence      r   c                    r   )Nc                     s*   | d d u s| d d u rdS  | i |S Nr   r   r	   r   r   r	   r
   r   "   s   z!check_for_none.<locals>.decoratorr   r   r	   r   r
   check_for_none!   r   r   c                    r   )Nc                     s2   t | d dkst | d dkrdS  | i |S r   )r   r   r   r	   r
   r   +   s    z%check_empty_string.<locals>.decoratorr   r   r	   r   r
   check_empty_string*   r   r    c                 C   s   g | ]}t |qS r	   )chr).0ir	   r	   r
   
<listcomp>3   s    r"         c                 c   s    | ]	}t |d fV  qd S N)ord)r    cr	   r	   r
   	<genexpr>5   s    r(   c                 C   s   t r| tS | d tS r%   )PY3	translatetranslation_table	bad_charsr   r	   r	   r
   	asciionly9   s   
r-   c                 C   s<   t | tu r
t| S t | tu rt| ddS tt| S )Nasciiignore)typestrr-   unicodeencodeasciidammitr   r	   r	   r
   r4   @   s
   r4   c                 C   sH   t | trt |tr| |fS t | trt |tr| |fS t| t|fS )zTIf both objects aren't either both string or unicode instances force them to unicode)
isinstancer1   r2   )s1s2r	   r	   r
   make_type_consistentI   s
   r8   Fc                 C   s.   |rt | } t| }t|}t|}|S )zProcess string by
        -- removing all but letters and numbers
        -- trim whitespace
        -- force to lower case
        if force_ascii == True, force convert to ascii)r4   r   /replace_non_letters_non_numbers_with_whitespaceto_lower_casestrip)r   force_ascii
string_outr	   r	   r
   full_processU   s   


r>   c                 C   s   t t| S )z#Returns a correctly rounded integer)intround)nr	   r	   r
   intrg   s   rB   )F)
__future__r   sysr   fuzzywuzzy.string_processingr   version_infor)   r   r   r   r   r1   joinranger,   dictr+   r2   r-   r4   r8   r>   rB   r	   r	   r	   r
   <module>   s$    				
