
    khj                     J    d dl Z  G d d      Z G d de      Z G d d      Zy)    Nc                   :    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
y	)
ComparableMixinz(Implements rich operators for an object.c                     	  || j                         |j                               S # t        t        f$ r	 t        cY S w xY wN)_cmpkeyAttributeError	TypeErrorNotImplemented)selfothermethods      K/opt/mcp/mcp-sentiment/venv/lib/python3.12/site-packages/textblob/mixins.py_comparezComparableMixin._compare   s<    	"$,,.%--/::	* 	" "!	"s   $' ??c                 (    | j                  |d       S )Nc                     | |k  S r    sos     r   <lambda>z(ComparableMixin.__lt__.<locals>.<lambda>   
    Q     r   r   r   s     r   __lt__zComparableMixin.__lt__       }}U$677r   c                 (    | j                  |d       S )Nc                     | |k  S r   r   r   s     r   r   z(ComparableMixin.__le__.<locals>.<lambda>   
    a r   r   r   s     r   __le__zComparableMixin.__le__       }}U$788r   c                 (    | j                  |d       S )Nc                     | |k(  S r   r   r   s     r   r   z(ComparableMixin.__eq__.<locals>.<lambda>   r   r   r   r   s     r   __eq__zComparableMixin.__eq__   r!   r   c                 (    | j                  |d       S )Nc                     | |k\  S r   r   r   s     r   r   z(ComparableMixin.__ge__.<locals>.<lambda>   r   r   r   r   s     r   __ge__zComparableMixin.__ge__   r!   r   c                 (    | j                  |d       S )Nc                     | |kD  S r   r   r   s     r   r   z(ComparableMixin.__gt__.<locals>.<lambda>   r   r   r   r   s     r   __gt__zComparableMixin.__gt__   r   r   c                 (    | j                  |d       S )Nc                     | |k7  S r   r   r   s     r   r   z(ComparableMixin.__ne__.<locals>.<lambda>   r   r   r   r   s     r   __ne__zComparableMixin.__ne__   r!   r   N)__name__
__module____qualname____doc__r   r   r    r$   r'   r*   r-   r   r   r   r   r      s(    2"899989r   r   c                   "     e Zd ZdZ fdZ xZS )BlobComparableMixinz@Allow blob objects to be comparable with both strings and blobs.c                 ~    t        |t        t        f      r || j                         |      S t        |   ||      S r   )
isinstancestrbytesr   superr   )r   r   r   	__class__s      r   r   zBlobComparableMixin._compare%   s6    ec5\*$,,.%00wv..r   )r.   r/   r0   r1   r   __classcell__)r9   s   @r   r3   r3   "   s    J/ /r   r3   c                   `   e Zd ZdZd Zd Zd Zd Zd Zd Z	de
j                  fd	Zde
j                  fd
Zde
j                  fdZde
j                  fdZde
j                  fdZde
j                  fdZeZeZd Zd Zde
j                  fdZddZd Zd Zd Ze
j                  fdZy)StringlikeMixina  Make blob objects behave like Python strings.

    Expects that classes that use this mixin to have a _strkey() method that
    returns the string to apply string methods to. Using _strkey() instead
    of __str__ ensures consistent behavior between Python 2 and 3.
    c                 T    | j                   j                  }t        |       }| d| dS )z.Returns a string representation for debugging.z("z"))r9   r.   r6   )r   
class_nametexts      r   __repr__zStringlikeMixin.__repr__4   s-    ^^,,
4yRvR((r   c                 "    | j                         S )zQReturns a string representation used in print statements
        or str(my_blob)._strkeyr   s    r   __str__zStringlikeMixin.__str__:   s     ||~r   c                 4    t        | j                               S )z#Returns the length of the raw text.)lenrC   rD   s    r   __len__zStringlikeMixin.__len__?   s    4<<>""r   c                 4    t        | j                               S )zqMakes the object iterable as if it were a string,
        iterating through the raw string's characters.
        )iterrC   rD   s    r   __iter__zStringlikeMixin.__iter__C   s     DLLN##r   c                 &    || j                         v S )z1Implements the `in` keyword like a Python string.rB   )r   subs     r   __contains__zStringlikeMixin.__contains__I   s    dlln$$r   c                     t        |t              r| j                         |   S | j                  | j                         |         S )zReturns a  substring. If index is an integer, returns a Python
        string of a single character. If a range is given, e.g. `blob[3:5]`,
        a new instance of the class is returned.
        )r5   intrC   r9   )r   indexs     r   __getitem__zStringlikeMixin.__getitem__M   s;    
 eS!<<>%(( >>$,,."788r   r   c                 D    | j                         j                  |||      S )zBehaves like the built-in str.find() method. Returns an integer,
        the index of the first occurrence of the substring argument sub in the
        sub-string given by [start:end].
        )rC   findr   rM   startends       r   rT   zStringlikeMixin.findX   s    
 ||~""3s33r   c                 D    | j                         j                  |||      S )zBehaves like the built-in str.rfind() method. Returns an integer,
        the index of he last (right-most) occurence of the substring argument
        sub in the sub-sequence given by [start:end].
        )rC   rfindrU   s       r   rY   zStringlikeMixin.rfind_   s    
 ||~##C44r   c                 D    | j                         j                  |||      S )zWLike blob.find() but raise ValueError when the substring
        is not found.
        )rC   rQ   rU   s       r   rQ   zStringlikeMixin.indexf   s     ||~##C44r   c                 D    | j                         j                  |||      S )zTLike blob.rfind() but raise ValueError when substring is not
        found.
        )rC   rindexrU   s       r   r\   zStringlikeMixin.rindexl   s     ||~$$S%55r   c                 D    | j                         j                  |||      S )z6Returns True if the blob starts with the given prefix.)rC   
startswith)r   prefixrV   rW   s       r   r^   zStringlikeMixin.startswithr   s    ||~((<<r   c                 D    | j                         j                  |||      S )z4Returns True if the blob ends with the given suffix.)rC   endswith)r   suffixrV   rW   s       r   ra   zStringlikeMixin.endswithv   s    ||~&&vuc::r   c                 \    | j                  | j                         j                               S )z2Returns a blob object with the text in title-case.)r9   rC   titlerD   s    r   rd   zStringlikeMixin.title~        ~~dlln22455r   c                 `    | j                   | j                         j                  |i |      S )zPerform a string formatting operation, like the built-in
        `str.format(*args, **kwargs)`. Returns a blob object.
        )r9   rC   format)r   argskwargss      r   rg   zStringlikeMixin.format   s,     ~~3dlln33TDVDEEr   Nc                 B    | j                         j                  ||      S )z&Behaves like the built-in str.split().)rC   split)r   sepmaxsplits      r   rk   zStringlikeMixin.split   s    ||~##C22r   c                 ^    | j                  | j                         j                  |            S )zBehaves like the built-in str.strip([chars]) method. Returns
        an object with leading and trailing whitespace removed.
        )r9   rC   strip)r   charss     r   ro   zStringlikeMixin.strip   s$     ~~dlln2259::r   c                 \    | j                  | j                         j                               S )zELike str.upper(), returns new object with all upper-cased characters.)r9   rC   upperrD   s    r   rr   zStringlikeMixin.upper   re   r   c                 \    | j                  | j                         j                               S )zELike str.lower(), returns new object with all lower-cased characters.)r9   rC   lowerrD   s    r   rt   zStringlikeMixin.lower   re   r   c                 ^    | j                  | j                         j                  |            S )zBehaves like the built-in `str.join(iterable)` method, except
        returns a blob object.

        Returns a blob which is the concatenation of the strings or blobs
        in the iterable.
        )r9   rC   join)r   iterables     r   rv   zStringlikeMixin.join   s$     ~~dlln11(;<<r   c                 b    | j                  | j                         j                  |||            S )z\Return a new blob object with all the occurence of `old` replaced
        by `new`.
        )r9   rC   replace)r   oldnewcounts       r   ry   zStringlikeMixin.replace   s(     ~~dlln44S#uEFFr   r   )r.   r/   r0   r1   r@   rE   rH   rK   rN   rR   sysmaxsizerT   rY   rQ   r\   r^   ra   starts_with	ends_withrd   rg   rk   ro   rr   rt   rv   ry   r   r   r   r<   r<   ,   s    )
#$%	9  S[[ 4  !ckk 5  !ckk 5 !"s{{ 6 ()ckk = &'CKK ;
 KI6F s{{ 3;66= '*kk Gr   r<   )r}   r   r3   r<   r   r   r   <module>r      s,    
9 9<// /{G {Gr   