a
    ]Df%                     @  s  d Z ddlmZ ddlZeeZddlZddlm	Z	m
Z
mZ ddlmZ dZd(d	d
d	d	dddZddddd	d	d	dddZd)d	d	d	dddZdd	ddddZedddddd d!Zed	ddd	dd"d!Zdddddd#d!Zd*d	d$d	d%d&d'ZdS )+z9 Functions useful for string manipulations or encoding.

    )annotationsN)AnyIterableoverload
quote_plus)append_docstringformat_docstringindent	nice_joinsnakify    strint)textnchreturnc                   s&   ||  d  fdd| dD S )aH   Indent all the lines in a given block of text by a specified amount.

    Args:
        text (str) :
            The text to indent

        n (int, optional) :
            The amount to indent each line by (default: 2)

        ch (char, optional) :
            What character to fill the indentation with (default: " ")

    
c                 3  s   | ]} | V  qd S N ).0linepaddingr   _/nfs/NAS7/SABIOD/METHODE/ermites/ermites_venv/lib/python3.9/site-packages/bokeh/util/strings.py	<genexpr><       zindent.<locals>.<genexpr>)joinsplit)r   r   r   r   r   r   r
   -   s    r
   z, or)sepconjunctionzIterable[str])seqr"   r#   r   c                C  sV   dd | D } t | dks"|du r,|| S || dd  d| d| d  S dS )a   Join together sequences of strings into English-friendly phrases using
    the conjunction ``or`` when appropriate.

    Args:
        seq (seq[str]) : a sequence of strings to nicely join
        sep (str, optional) : a sequence delimiter to use (default: ", ")
        conjunction (str or None, optional) : a conjunction to use for the last
            two items, or None to reproduce basic join behaviour (default: "or")

    Returns:
        a joined string

    Examples:
        >>> nice_join(["a", "b", "c"])
        'a, b or c'

    c                 S  s   g | ]}t |qS r   )r   )r   xr   r   r   
<listcomp>Q   r   znice_join.<locals>.<listcomp>   Nr   )lenr   )r$   r"   r#   r   r   r   r   ?   s    
r   _)namer"   r   c                 C  s4   t dd| d| } t dd| d| } |  S )z" Convert CamelCase to snake_case. z([A-Z]+)([A-Z][a-z])z\1z\2z([a-z\d])([A-Z]))resublower)r+   r"   r   r   r   r   Y   s    r   z
str | None)	docstringextrar   c                 C  s   | du rdS | | S )a   Safely append to docstrings.

    When Python is executed with the ``-OO`` option, doc strings are removed and
    replaced the value ``None``. This function guards against appending the
    extra content in that case.

    Args:
        docstring (str or None) : The docstring to format, or None
        extra (str): the content to append if docstring is not None

    Returns:
        str or None

    Nr   )r/   r0   r   r   r   r   _   s    r   Noner   )r/   argskwargsr   c                 O  s   d S r   r   r/   r2   r3   r   r   r   r	   p   s    r	   c                 O  s   d S r   r   r4   r   r   r   r	   r   s    c                 O  s   | du rdS | j |i |S )a   Safely format docstrings.

    When Python is executed with the ``-OO`` option, doc strings are removed and
    replaced the value ``None``. This function guards against applying the string
    formatting options in that case.

    Args:
        docstring (str or None) : The docstring to format, or ``None``
        args (tuple) : string formatting arguments for the docsring
        kwargs (dict) : string formatting arguments for the docsring

    Returns:
        str or None

    N)formatr4   r   r   r   r	   u   s    zdict[str, str] | None)url	argumentsr   c                 C  s0   |dur,dd |  D }| dd| 7 } | S )a!   Format a base URL with optional query arguments

    Args:
        url (str) :
            An base URL to append query arguments to
        arguments (dict or None, optional) :
            A mapping of key/value URL query arguments, or None (default: None)

    Returns:
        str

    Nc                 s  s(   | ] \}}t | d t | V  qdS )=Nr   )r   keyvaluer   r   r   r      r   z-format_url_query_arguments.<locals>.<genexpr>?&)itemsr   )r6   r7   r=   r   r   r   format_url_query_arguments   s    r>   )r   r   )r*   )N)__doc__
__future__r   logging	getLogger__name__logr,   typingr   r   r   urllib.parser   __all__r
   r   r   r   r	   r>   r   r   r   r   <module>   s"   
