U
    ARd                     @   s,   d dl Z dd Zdd Zdd Zdd	 ZdS )
    Nc                 C   s   d ttj| dS )z_Converts snake_case to UpperCamelCase.

    Example
    -------
        foo_bar -> FooBar

     _)joinmapstrtitlesplit)snake_case_str r
   =/tmp/pip-unpacked-wheel-b9et7o5g/streamlit/case_converters.pyto_upper_camel_case   s    r   c                 C   sB   |  d}t|dkr:dd |D }|d |d< d|S | S dS )zxConverts snake_case to lowerCamelCase.

    Example
    -------
        foo_bar -> fooBar
        fooBar -> foobar

    r      c                 S   s   g | ]}|  qS r
   )r   ).0wr
   r
   r   
<listcomp>(   s     z'to_lower_camel_case.<locals>.<listcomp>r   r   N)r   lenr   )r	   wordsZcapitalizedr
   r
   r   to_lower_camel_case   s    	

r   c                 C   s    t dd| }t dd| S )zConverts UpperCamelCase and lowerCamelCase to snake_case.

    Examples
    --------
        fooBar -> foo_bar
        BazBang -> baz_bang

    z(.)([A-Z][a-z]+)z\1_\2z([a-z0-9])([A-Z]))resublower)Zcamel_case_strs1r
   r
   r   to_snake_case/   s    	r   c                 C   sH   t  }| D ]4\}}| |}t|t kr:t| |||< q|||< q|S )a  Apply a conversion function to all keys in a dict.

    Parameters
    ----------
    func : callable
        The function to apply. Takes a str and returns a str.
    in_dict : dict
        The dictionary to convert. If some value in this dict is itself a dict,
        it also gets recursively converted.

    Returns
    -------
    dict
        A new dict with all the contents of `in_dict`, but with the keys
        converted by `func`.

    )dictitemstypeconvert_dict_keys)funcZin_dictZout_dictkvZconverted_keyr
   r
   r   r   <   s    
r   )r   r   r   r   r   r
   r
   r
   r   <module>   s   