o
    Lh                     @  sx   d dl mZ d dlZd dlmZ d dlZd dlmZ	 d dl
mZmZmZ er2d dlmZ d dlmZ G dd deZdS )	    )annotationsN)TYPE_CHECKING)ArrowSeriesNamespacelitparse_datetime_format)ArrowSeries)
Incompletec                   @  s   e Zd Zd1ddZd2ddZd3ddZd4ddZd5ddZd6ddZd7ddZ	d8dd Z
d9d"d#Zd:d%d&Zd:d'd(Zd1d)d*Zd1d+d,Zd;d.d/Zd0S )<ArrowSeriesStringNamespacereturnr   c                 C     |  t| jS N)with_nativepcutf8_lengthnativeself r   [/var/www/html/Persson_Maskin/env/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   r3   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   r9   r:   r=   r   r   r   r0   -   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)rC   unit)r   r   r   strptimer   )r   rC   timestamp_arrayr   r   r   to_datetime7   s   
z&ArrowSeriesStringNamespace.to_datetimec                 C  s   | j |dj S )N)rC   )rH   dtdate)r   rC   r   r   r   to_date<   r   z"ArrowSeriesStringNamespace.to_datec                 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_lowercaseB   r   z'ArrowSeriesStringNamespace.to_lowercasewidthc              
   C  s   t j}| j}tdtd}}| ddj| dd j}}t t |t|}t ||}	t ||}
t t 	|	|t 	|
||}t j
||d dd}t ||t|t||d|t|t||dt j
||dd|}| |S )	N-+r      0)padding )rP   rU   )r   binary_join_element_wiser   r   r0   lessr   r/   make_structand_	utf8_lpad	case_whenparepeatr1   r   )r   rP   binary_joinr   hyphenplus
first_charremaining_charsless_than_widthstarts_with_hyphenstarts_with_plus
conditionspadded_remaining_charsresultr   r   r   zfillE   s6   


z ArrowSeriesStringNamespace.zfillN)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   r   r
   r   )r   r   r   r   r
   r   )r9   r   r:   r;   r
   r   )r?   r   r
   r   )rC   r(   r
   r   )rP   r   r
   r   )__name__
__module____qualname__r   r$   r&   r,   r2   r4   r8   r0   rB   rH   rK   rM   rO   rj   r   r   r   r   r	      s    












r	   )
__future__r   r*   typingr   pyarrowr]   pyarrow.computecomputer   narwhals._arrow.utilsr   r   r   narwhals._arrow.seriesr   narwhals._arrow.typingr   r	   r   r   r   r   <module>   s    