o
    $&]i*                     @  s   d dl mZ d dl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 er.d dlmZ G dd	 d	ee e
e ee ZdS )
    )annotationsN)TYPE_CHECKINGAnyGeneric)LazyExprNamespace)StringNamespace)SQLExprT)
NativeExprc                   @  s   e Zd Zd6ddZd7d
dZ	d8d9d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dAd-d.Zd<d/d0Zd<d1d2ZdBd4d5ZdS )CSQLExprStringNamespacevaluer   returnr	   c                 C  s   | j |S N)	compliant_lit)selfr    r   T/var/www/html/IGF-ODF-V3/venv/lib/python3.10/site-packages/narwhals/_sql/expr_str.pyr      s   zSQLExprStringNamespace._litnamestrargsc                 G  s   | j j|g|R  S r   )r   	_function)r   r   r   r   r   r   r      s   z SQLExprStringNamespace._functionN	condition	otherwise
Any | Nonec                 C  s   | j |||S r   )r   _when)r   r   r   r   r   r   r   r      s   zSQLExprStringNamespace._whenpatternliteralboolr   c                     d fdd}j |S )Nexprr	   r   c                   s,    r d| S  d| S )Ncontainsregexp_matchesr   r   r   r   r   r   r   r   func   s   z-SQLExprStringNamespace.contains.<locals>.funcr   r	   r   r	   r   _with_elementwise)r   r   r   r%   r   r$   r   r       s   zSQLExprStringNamespace.containssuffixc                   s    j  fddS )Nc                   s     d|  S )N	ends_withr"   r#   r   r)   r   r   <lambda>&       z2SQLExprStringNamespace.ends_with.<locals>.<lambda>r'   r+   r   r+   r   r*   $      z SQLExprStringNamespace.ends_withc                       j  fddS )Nc                        d| S )Nlengthr   r#   r   r   r   r,   +       z2SQLExprStringNamespace.len_chars.<locals>.<lambda>r'   r3   r   r3   r   	len_chars)      
z SQLExprStringNamespace.len_charsc                  sJ   |rdnd g |sj j rdgj j fdd|dS )Nreplaceregexp_replacegc                   s   j  | |gR  S r   r"   )r   r   fnameoptionsr   r   r   r   r,   5   s
    z4SQLExprStringNamespace.replace_all.<locals>.<lambda>)r   )r   _implementation	is_duckdbr   r(   )r   r   r   r   r   r:   r   replace_all.   s   z"SQLExprStringNamespace.replace_alloffsetintr1   
int | Nonec                   r   )Nr   r	   r   c                   s^    d| }dk rt|d nd } d ur% n|} d| ||S )Nr1   r      substr)r   operatoraddr   )r   
col_length_offset_lengthr1   r@   r   r   r   r%   <   s   z*SQLExprStringNamespace.slice.<locals>.funcr&   r'   )r   r@   r1   r%   r   rJ   r   slice;   s   zSQLExprStringNamespace.slicebyc                      j  fddS )Nc                       d|  S )N	str_splitr"   r#   rL   r   r   r   r,   K   r-   z.SQLExprStringNamespace.split.<locals>.<lambda>r'   )r   rL   r   rP   r   splitI   r.   zSQLExprStringNamespace.splitprefixc                   rM   )Nc                   rN   )Nstarts_withr"   r#   rR   r   r   r   r,   P   r-   z4SQLExprStringNamespace.starts_with.<locals>.<lambda>r'   )r   rR   r   rT   r   rS   N   r.   z"SQLExprStringNamespace.starts_with
characters
str | Nonec                   s    dd l j fddS )Nr   c                   s&    d|  d u rjS  S )Ntrim)r   r   
whitespacer#   rU   r   stringr   r   r,   W   s    z4SQLExprStringNamespace.strip_chars.<locals>.<lambda>)rZ   r   r(   )r   rU   r   rY   r   strip_charsS   s   z"SQLExprStringNamespace.strip_charsc                   r/   )Nc                   r0   )Nlowerr2   r#   r3   r   r   r,   `   r4   z5SQLExprStringNamespace.to_lowercase.<locals>.<lambda>r'   r3   r   r3   r   to_lowercase^   r6   z#SQLExprStringNamespace.to_lowercasec                   r/   )Nc                   r0   )Nupperr2   r#   r3   r   r   r,   e   r4   z5SQLExprStringNamespace.to_uppercase.<locals>.<lambda>r'   r3   r   r3   r   to_uppercasec   r6   z#SQLExprStringNamespace.to_uppercasewidthc                   s   d fdd} j |S )Nr   r	   r   c           	        s     d|  k } d d d}}}  d| |}  d| |}  d|  d}  d| d	 |} t||  d
|| t||  d
|| |  d|  || S )Nr1   0-+rS   rD      lpadrC   concat)r   r   r   rE   and_)	r   less_than_widthzerohyphenplusstarts_with_minusstarts_with_plus	substringpadded_substringr   r`   r   r   r%   l   s*   "

z*SQLExprStringNamespace.zfill.<locals>.funcr&   )r   _with_callable)r   r`   r%   r   rp   r   zfillh   s   zSQLExprStringNamespace.zfill)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   r   )r   r   )r   r   r   r   r   r   r   r   )r@   rA   r1   rB   r   r   )rL   r   r   r   )rR   r   r   r   )rU   rV   r   r   )r`   rA   r   r   )__name__
__module____qualname__r   r   r   r    r*   r5   r?   rK   rQ   rS   r[   r]   r_   rr   r   r   r   r   r
      s     











r
   )
__future__r   rE   typingr   r   r   narwhals._compliantr   !narwhals._compliant.any_namespacer   narwhals._sql.typingr   narwhals._compliant.exprr	   r
   r   r   r   r   <module>   s    
