o
    $&]i                     @  s   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mZ d dlmZ er:d dlmZ d dlmZ G dd	 d	eed
 ZdS )    )annotationsN)TYPE_CHECKING)ArrowSeriesNamespaceextract_nativelitparse_datetime_format)StringNamespace)ArrowSeries)
Incompletec                   @  s   e Z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d<d%d&Zd<d'd(Zd3d)d*Zd3d+d,Zd3d-d.Zd=d0d1Zd2S )>ArrowSeriesStringNamespacereturnr	   c                 C     |  t| jS N)with_nativepcutf8_lengthnativeself r   X/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/narwhals/_arrow/series_str.py	len_chars      z$ArrowSeriesStringNamespace.len_charsvaluepatternstrliteralboolnintc          
      C  sX   |rt jnt j}t| j|\}}t|tjsd}t||| j	||
 |d}	| |	S )NzBPyArrow backed `.str.replace` only supports str replacement values)replacementmax_replacements)r   replace_substringreplace_substring_regexr   	compliant
isinstancepaStringScalar	TypeErrorr   as_pyr   )
r   r   r   r   r   fn_value_nativemsg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'   s   z&ArrowSeriesStringNamespace.replace_all
characters
str | Nonec                 C  s   |  t| j|p
tjS r   )r   r   	utf8_trimr   string
whitespace)r   r2   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   r8   r   r   r   starts_with1   s   $z&ArrowSeriesStringNamespace.starts_withsuffixc                 C  s&   |  t| t| d jt|S r   r9   )r   r>   r   r   r   	ends_with4   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   contains9   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   rD   rE   rH   r   r   r   r;   =   s   z ArrowSeriesStringNamespace.slicebyc                 C  s   t | j|}| |S r   )r   split_patternr   r   )r   rJ   split_seriesr   r   r   splitC   s   
z ArrowSeriesStringNamespace.splitformatc                 C  s2   |d u r	t | jn|}tj| j|dd}| |S )Nus)rN   unit)r   r   r   strptimer   )r   rN   timestamp_arrayr   r   r   to_datetimeG   s   
z&ArrowSeriesStringNamespace.to_datetimec                 C  s   | j |dj S )N)rN   )rS   dtdate)r   rN   r   r   r   to_dateL   r   z"ArrowSeriesStringNamespace.to_datec                 C  r   r   )r   r   
utf8_upperr   r   r   r   r   to_uppercaseO   r   z'ArrowSeriesStringNamespace.to_uppercasec                 C  r   r   )r   r   
utf8_lowerr   r   r   r   r   to_lowercaseR   r   z'ArrowSeriesStringNamespace.to_lowercasec                 C  r   r   )r   r   
utf8_titler   r   r   r   r   to_titlecaseU   r   z'ArrowSeriesStringNamespace.to_titlecase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 )r]   rb   )r   binary_join_element_wiser   r   r;   lessr   r:   make_structand_	utf8_lpad	case_whenr&   repeatr<   r   )r   r]   binary_joinr   hyphenplus
first_charremaining_charsless_than_widthstarts_with_hyphenstarts_with_plus
conditionspadded_remaining_charsresultr   r   r   zfillX   s6   


z ArrowSeriesStringNamespace.zfillN)r   r	   )
r   r	   r   r   r   r   r   r   r   r	   )r   r	   r   r   r   r   r   r	   )r2   r3   r   r	   )r8   r   r   r	   )r>   r   r   r	   )r   r   r   r   r   r	   )rD   r   rE   rF   r   r	   )rJ   r   r   r	   )rN   r3   r   r	   )r]   r   r   r	   )__name__
__module____qualname__r   r/   r1   r7   r=   r?   rC   r;   rM   rS   rV   rX   rZ   r\   rv   r   r   r   r   r      s     













r   r	   )
__future__r   r5   typingr   pyarrowr&   pyarrow.computecomputer   narwhals._arrow.utilsr   r   r   r   !narwhals._compliant.any_namespacer   narwhals._arrow.seriesr	   narwhals._arrow.typingr
   r   r   r   r   r   <module>   s    