
    g3fi                     `    d Z ddlmZ dedefdZdedefdZdee   defd	Zdd
ededefdZ	y)zString utilities.    )Anyvalreturnc                     t        | t              r| S t        | t              rdt        |       z   S t        | t              rdj                  d | D              S t        |       S )ztStringify a value.

    Args:
        val: The value to stringify.

    Returns:
        The stringified value.
    
c              3   2   K   | ]  }t        |        y wNstringify_value).0vs     Z/var/www/auto_recruiter/arenv/lib/python3.12/site-packages/langchain_core/utils/strings.py	<genexpr>z"stringify_value.<locals>.<genexpr>   s     9+9   )
isinstancestrdictstringify_dictlistjoin)r   s    r   r   r      sU     #s
#tnS)))#tyy9S999s8O    datac                 N    dj                  d | j                         D              S )zStringify a dictionary.

    Args:
        data: The dictionary to stringify.

    Returns:
        The stringified dictionary.
     c              3   D   K   | ]  \  }}| d t        |       d  yw)z: r   Nr
   )r   keyvalues      r   r   z!stringify_dict.<locals>.<genexpr>!   s'     WJCcU"_U34B7Ws    )r   items)r   s    r   r   r      s     77W$**,WWWr   r   c                 2    dj                  d | D              S )zConvert a list to a comma-separated string.

    Args:
        items: The list to convert.

    Returns:
        The comma-separated string.
    z, c              3   2   K   | ]  }t        |        y wr	   )r   )r   items     r   r   zcomma_list.<locals>.<genexpr>-   s     14SY1r   )r   )r   s    r   
comma_listr"   $   s     9915111r   textreplacementc                 &    | j                  d|      S )av  Sanitize text by removing NUL bytes that are incompatible with PostgreSQL.

    PostgreSQL text fields cannot contain NUL (0x00) bytes, which can cause
    psycopg.DataError when inserting documents. This function removes or replaces
    such characters to ensure compatibility.

    Args:
        text: The text to sanitize.
        replacement: String to replace NUL bytes with.

    Returns:
        The sanitized text with NUL bytes removed or replaced.

    Example:
        >>> sanitize_for_postgres("Hello\\x00world")
        'Helloworld'
        >>> sanitize_for_postgres("Hello\\x00world", " ")
        'Hello world'
     )replace)r#   r$   s     r   sanitize_for_postgresr(   0   s    ( <<,,r   N)r   )
__doc__typingr   r   r   r   r   r   r"   r(    r   r   <module>r,      se       $	X 	X# 	X	2d3i 	2C 	2- -# -s -r   