o
    $&]i)                     @  s   U d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZmZ er<d dlm  mZ d dlmZ d dlmZ d	Zd
ed< G dd de	d ZdS )    )annotations)TYPE_CHECKINGAnyCallable)	Timestamp)SQLExprStringNamespace)_is_naive_formatnot_implementedN)	TypeAlias)IbisExprzstr | ir.StringValuer
   IntoStringValuec                   @  sh   e Zd ZdddZd ddZd ddZd!ddZd"ddZd"ddZd#ddZ	d#ddZ
e Ze ZdS )$IbisExprStringNamespace
characters
str | Nonereturnr   c                 C  s$   |d ur
d}t || jdd S )Nz@Ibis does not support `characters` argument in `str.strip_chars`c                 S  s   |   S N)stripexpr r   U/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/narwhals/_ibis/expr_str.py<lambda>   s    z5IbisExprStringNamespace.strip_chars.<locals>.<lambda>NotImplementedError	compliant_with_callable)selfr   msgr   r   r   strip_chars   s   z#IbisExprStringNamespace.strip_charspatternr   valueCallable[..., ir.StringValue]c                      d fdd}|S )Nr   ir.StringColumnr   ir.StringValuec                      |   S r   )
re_replacer   r   r    r   r   fn      z0IbisExprStringNamespace._replace_all.<locals>.fnr   r#   r   r$   r   r   r   r    r(   r   r'   r   _replace_all      z$IbisExprStringNamespace._replace_allc                   r"   )Nr   r#   r   r$   c                   r%   r   )replacer   r'   r   r   r(   &   r)   z8IbisExprStringNamespace._replace_all_literal.<locals>.fnr*   r   r+   r   r'   r   _replace_all_literal#   r-   z,IbisExprStringNamespace._replace_all_literalstrliteralboolc                  s*   |r| j n| j | jj fdd|dS )Nc                   s    || S r   r   )r   r    r(   r   r   r   r   .   s    z5IbisExprStringNamespace.replace_all.<locals>.<lambda>)r    )r/   r,   r   _with_elementwise)r   r    r   r1   r   r3   r   replace_all+   s   z#IbisExprStringNamespace.replace_allformat Callable[..., ir.TimestampValue]c                      d fdd}|S )Nr   r#   r   ir.TimestampValuec                   
   |   S r   )as_timestampr   r6   r   r   r(   2      
z0IbisExprStringNamespace._to_datetime.<locals>.fnr   r#   r   r9   r   r   r6   r(   r   r<   r   _to_datetime1   s   z$IbisExprStringNamespace._to_datetimec                   r8   )Nr   r#   r   r9   c                   s   t d d}|  |S )N)timezone)r   r;   cast)r   dtyper<   r   r   r(   8   s   
z6IbisExprStringNamespace._to_datetime_naive.<locals>.fnr>   r   r?   r   r<   r   _to_datetime_naive7   s   z*IbisExprStringNamespace._to_datetime_naivec                 C  s8   |d u r
d}t |t|r| jn| j}| j||S )N%Cannot infer format with Ibis backend)r   r   rD   r@   r   r   r   r6   r   r(   r   r   r   to_datetime>   s
   z#IbisExprStringNamespace.to_datetimec                   s.    d u r
d}t |d fdd}| j|S )	NrE   r   r#   r   ir.DateValuec                   r:   r   )as_dater   r<   r   r   r(   J   r=   z+IbisExprStringNamespace.to_date.<locals>.fn)r   r#   r   rH   r   rF   r   r<   r   to_dateE   s
   zIbisExprStringNamespace.to_dateN)r   r   r   r   )r   r   r    r   r   r!   )r    r   r   r0   r1   r2   r   r   )r6   r0   r   r7   )r6   r   r   r   )__name__
__module____qualname__r   r,   r/   r5   r@   rD   rG   rJ   r	   r.   to_titlecaser   r   r   r   r      s    









r   r   )
__future__r   typingr   r   r   ibis.expr.datatypesr   narwhals._sql.expr_strr   narwhals._utilsr   r	   ibis.expr.typesr   typesirtyping_extensionsr
   narwhals._ibis.exprr   r   __annotations__r   r   r   r   r   <module>   s    