o
    h	                     @  st   d dl mZ d dlZd dlmZ d dlmZ d dlm	Z	 d dlm
Z
 d dlmZ er0d dlmZ G dd	 d	e	ZdS )
    )annotationsN)TYPE_CHECKING)ArrowSeriesNamespace)lit)parse_datetime_format)ArrowSeriesc                   @  s   e Zd Zd,ddZd-ddZd.ddZd/ddZd0ddZd1ddZd2ddZ	d3dd Z
d4d"d#Zd5d%d&Zd,d'd(Zd,d)d*Zd+S )6ArrowSeriesStringNamespacereturnr   c                 C     |  t| jS N)with_nativepcutf8_lengthnativeself r   N/var/www/vscode/kcb/lib/python3.10/site-packages/narwhals/_arrow/series_str.py	len_chars      z$ArrowSeriesStringNamespace.len_charspatternstrvalueliteralboolnintc                C  s,   |rt jnt j}|| j|||d}| |S )N)replacementmax_replacements)r   replace_substringreplace_substring_regexr   r   )r   r   r   r   r   fnarrr   r   r   replace   s   
z"ArrowSeriesStringNamespace.replacec                C  s   | j |||ddS )N)r   r   )r#   )r   r   r   r   r   r   r   replace_all   r   z&ArrowSeriesStringNamespace.replace_all
characters
str | Nonec                 C  s   |  t| j|p
tjS r   )r   r   	utf8_trimr   string
whitespace)r   r&   r   r   r   strip_chars   s   z&ArrowSeriesStringNamespace.strip_charsprefixc              	   C  s$   |  t| dt|jt|S )Nr   r   r   equalslicelenr   r   )r   r,   r   r   r   starts_with!   s   $z&ArrowSeriesStringNamespace.starts_withsuffixc                 C  s&   |  t| t| d jt|S r   r-   )r   r2   r   r   r   	ends_with$   s   z$ArrowSeriesStringNamespace.ends_withc                C  s"   |rt jnt j}| || j|S r   )r   match_substringmatch_substring_regexr   r   )r   r   r   
check_funcr   r   r   contains)   s   z#ArrowSeriesStringNamespace.containsoffsetlength
int | Nonec                 C  s,   |d ur|| nd }|  tj| j||dS )N)startstop)r   r   utf8_slice_codeunitsr   )r   r8   r9   r<   r   r   r   r/   -   s   z ArrowSeriesStringNamespace.slicebyc                 C  s   t | j|}| |S r   )r   split_patternr   r   )r   r>   split_seriesr   r   r   split3   s   
z ArrowSeriesStringNamespace.splitformatc                 C  s2   |d u r	t | jn|}tj| j|dd}| |S )Nus)rB   unit)r   r   r   strptimer   )r   rB   timestamp_arrayr   r   r   to_datetime7   s   
z&ArrowSeriesStringNamespace.to_datetimec                 C  r
   r   )r   r   
utf8_upperr   r   r   r   r   to_uppercase<   r   z'ArrowSeriesStringNamespace.to_uppercasec                 C  r
   r   )r   r   
utf8_lowerr   r   r   r   r   to_lowercase?   r   z'ArrowSeriesStringNamespace.to_lowercaseN)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   )r2   r   r	   r   )r   r   r   r   r	   r   )r8   r   r9   r:   r	   r   )r>   r   r	   r   )rB   r'   r	   r   )__name__
__module____qualname__r   r#   r%   r+   r1   r3   r7   r/   rA   rG   rI   rK   r   r   r   r   r      s    










r   )
__future__r   r)   typingr   pyarrow.computecomputer   narwhals._arrow.utilsr   r   r   narwhals._arrow.seriesr   r   r   r   r   r   <module>   s    