
    -e2                        d Z ddlmZ ddlZ ej        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Zdddd,dZd-d.dZd/dZed0d#            Zed1d$            Zd2d%Zd3d4d)ZdS )5z9 Functions useful for string manipulations or encoding.

    )annotationsN)AnyIterableoverload
quote_plus)append_docstringformat_docstringindent	nice_joinsnakify    textstrnintchreturnc                v    ||z  d                     f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  "   K   | ]	}|z   V  
d S N ).0linepaddings     2lib/python3.11/site-packages/bokeh/util/strings.py	<genexpr>zindent.<locals>.<genexpr><   s'      AAWt^AAAAAA    )joinsplit)r   r   r   r   s      @r   r   r   -   sA     1fG99AAAA

40@0@AAAAAAr    z, or)sepconjunctionseqIterable[str]r$   r%   c                   d | D             } t          |           dk    s||                    |           S |                    | dd                    d| d| 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                ,    g | ]}t          |          S r   )r   )r   xs     r   
<listcomp>znice_join.<locals>.<listcomp>Q   s    


a3q66


r       Nr   )lenr!   )r&   r$   r%   s      r   r   r   ?   so    $  
3


C
3xx1}}+xx}}((3ss8$$>>{>>SW>>>r    _namec                    t          j        dd| d|           } t          j        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)r0   r$   s     r   r   r   Y   sH    6(---->>D6%}S}}}d;;D::<<r    	docstring
str | Noneextrac                    | dn| |z   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   )r5   r7   s     r   r	   r	   _   s     $44)e*;;r    Noneargsr   kwargsc                    d S r   r   r5   r:   r;   s      r   r
   r
   p   s    JM#r    c                    d S r   r   r=   s      r   r
   r
   r   s    HKr    c                $    | dn | 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)formatr=   s      r   r
   r
   u   s&      $44*:)*:D*KF*K*KKr    url	argumentsdict[str, str] | Nonec                |    |9d |                                 D             }| dd                    |          z   z  } | 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              3  ^   K   | ](\  }}t          |           d t          |           V  )dS )=Nr   )r   keyvalues      r   r   z-format_url_query_arguments.<locals>.<genexpr>   sB      ^^jc5JsOO99j&7&799^^^^^^r    ?&)itemsr!   )rA   rB   rK   s      r   format_url_query_argumentsrL      sE     ^^IOOL]L]^^^sSXXe__$$Jr    )r   r   )r   r   r   r   r   r   r   r   )r&   r'   r$   r   r%   r   r   r   )r/   )r0   r   r$   r   r   r   )r5   r6   r7   r   r   r6   )r5   r9   r:   r   r;   r   r   r9   )r5   r   r:   r   r;   r   r   r   )r5   r6   r:   r   r;   r   r   r6   r   )rA   r   rB   rC   r   r   )__doc__
__future__r   logging	getLogger__name__logr2   typingr   r   r   urllib.parser   __all__r   r   r   r	   r
   rL   r   r    r   <module>rV      sY    # " " " " " g!! 
			 * * * * * * * * * * # # # # # #B B B B B$ 15 ? ? ? ? ? ?4    < < < <" 
 M M M 
 M	 K K K 
 KL L L L&      r    