
    4j                        S r SSKrSSKJr  \R                  " S5      r\R                  " S5      r\R                  " S5      r\R                  " S5      rS r	S	 r
S
 rS rS rS rS rS rS rS rS rS rS rSS jrg)z4
This module contains all the core logic for humps.
    N)Mappingz([A-Z\d]+)(?=[A-Z\d]|$)z	([^\-_]+)z([\-_]*[A-Z][^A-Z]*[\-_]*)z(?<=[^\-_])[\-_]+[^\-_]c                 \   [        U [        [        45      (       a  [        U [        5      $ [        U 5      nUR                  5       (       d  UR                  5       (       a  U $ S n[        [        R                  X!5      5      n[        U5      S:w  a  US   R                  5       USS -   $ U$ )z
Convert a string, dict, or list of dicts to pascal case.

:param str_or_iter:
    A string or iterable.
:type str_or_iter: Union[list, dict, str]
:rtype: Union[list, dict, str]
:returns:
    pascalized string, dictionary, or list of dictionaries.
c                 p    U R                  S5      S   R                  5       U R                  S5      SS -   $ )z
:rtype: str
   r   Ngroupupper)matchs    I/root/lseg-credit/backend/venv/lib/python3.13/site-packages/humps/main.py_replace_fnpascalize.<locals>._replace_fn    s4     {{1~a &&(5;;q>!"+===    r   r   N)
isinstancelistr   _process_keys	pascalize_is_noneisupper	isnumericcamelize	PASCAL_REsublenr	   )str_or_itersr   s      r   r   r      s     +g//[)44Ayy{{akkmm> 	{./A#&q6Q;1Q4::<!AB%5A5r   c                 t   [        U [        [        45      (       a  [        U [        5      $ [        U 5      nUR                  5       (       d  UR                  5       (       a  U $ [        U5      S:w  a1  USS R                  5       (       d  US   R                  5       USS -   n[        R                  S U5      $ )z
Convert a string, dict, or list of dicts to camel case.

:param str_or_iter:
    A string or iterable.
:type str_or_iter: Union[list, dict, str]
:rtype: Union[list, dict, str]
:returns:
    camelized string, dictionary, or list of dictionaries.
r   N   r   c                 F    U R                  S5      S   R                  5       $ )Nr   r   ms    r   <lambda>camelize.<locals>.<lambda>A   s    qwwqz"~';';'=r   )r   r   r   r   r   r   r   r   r   lowerUNDERSCORE_REr   r   r   s     r   r   r   *   s     +g//[(33Ayy{{akkmm
1v{1Ra5==??aDJJL1QR5  =qAAr   c                 v   [        U [        [        45      (       a  [        U [        5      $ [        U 5      nUR                  5       (       a  U $ UR                  5       (       dA  [        U5      (       d  [        U5      (       a!  [        [        U5      SS9R                  5       $ [        R                  S U5      $ )z
Convert a string, dict, or list of dicts to kebab case.
:param str_or_iter:
    A string or iterable.
:type str_or_iter: Union[list, dict, str]
:rtype: Union[list, dict, str]
:returns:
    kebabized string, dictionary, or list of dictionaries.
-string	separatorc                 0    SU R                  S5      S   -   $ )Nr(   r   r   )r   r    s    r   r"   kebabize.<locals>.<lambda>]   s    sQWWQZ^';r   )r   r   r   r   kebabizer   r   r   is_camelcaseis_pascalcase_separate_words_fix_abbreviationsr$   r%   r   r&   s     r   r.   r.   D   s     +g//[(33A{{}}IIKKl1ooq1A1A)!, eg		
 ;Q??r   c                 
   [        U [        [        45      (       a  [        U [        5      $ [        U 5      nUR                  5       (       d  UR                  5       (       a  U $ [        [        U5      5      R                  5       $ )z
Convert a string, dict, or list of dicts to snake case.

:param str_or_iter:
    A string or iterable.
:type str_or_iter: Union[list, dict, str]
:rtype: Union[list, dict, str]
:returns:
    snake cased string, dictionary, or list of dictionaries.
)r   r   r   r   
decamelizer   r   r   r1   r2   r$   r&   s     r   r4   r4   `   sa     +g//[*55Ayy{{akkmm-a017799r   c                     [        U 5      $ )z
Convert a string, dict, or list of dicts to snake case.

:param str_or_iter: A string or iterable.
:type str_or_iter: Union[list, dict, str]
:rtype: Union[list, dict, str]
:returns:
    snake cased string, dictionary, or list of dictionaries.
)r4   r   s    r   depascalizer7   u   s     k""r   c                     [        U [        [        45      (       a  [        U [        5      $ [        U 5      nUR                  5       (       a  U $ UR                  SS5      $ )z
Convert a string, dict, or list of dicts to snake case.
:param str_or_iter:
    A string or iterable.
:type str_or_iter: Union[list, dict, str]
:rtype: Union[list, dict, str]
:returns:
    snake cased string, dictionary, or list of dictionaries.
r(   _)r   r   r   r   
dekebabizer   r   replacer&   s     r   r:   r:      sN     +g//[*55A{{}}99S#r   c                     U [        U 5      :H  $ )z
Determine if a string, dict, or list of dicts is camel case.

:param str_or_iter:
    A string or iterable.
:type str_or_iter: Union[list, dict, str]
:rtype: bool
:returns:
    True/False whether string or iterable is camel case
)r   r6   s    r   r/   r/      s     (;///r   c                     U [        U 5      :H  $ )z
Determine if a string, dict, or list of dicts is pascal case.

:param str_or_iter: A string or iterable.
:type str_or_iter: Union[list, dict, str]
:rtype: bool
:returns:
    True/False whether string or iterable is pascal case
)r   r6   s    r   r0   r0      s     )K000r   c                     U [        U 5      :H  $ )z
Determine if a string, dict, or list of dicts is camel case.
:param str_or_iter:
    A string or iterable.
:type str_or_iter: Union[list, dict, str]
:rtype: bool
:returns:
    True/False whether string or iterable is camel case
)r.   r6   s    r   is_kebabcaser?      s     (;///r   c                 `    [        U 5      (       a  [        U 5      (       d  gU [        U 5      :H  $ )z
Determine if a string, dict, or list of dicts is snake case.

:param str_or_iter:
    A string or iterable.
:type str_or_iter: Union[list, dict, str]
:rtype: bool
:returns:
    True/False whether string or iterable is snake case
F)r?   r/   r4   r6   s    r   is_snakecaserA      s,     K  k)B)B*[111r   c                 N    U c  S$ [         R                  " SS[        U 5      5      $ )z
Determine if the input is None
and returns a string with white-space removed
:param _in: input
:return:
    an empty sting if _in is None,
    else the input is returned with white-space removed
 z\s+)rer   str)_ins    r   r   r      s$     2>"&&SX">>r   c           	         [        U [        5      (       a  U  Vs/ s H  n[        X!5      PM     sn$ [        U [        5      (       a5  U R	                  5        VVs0 s H  u  p#U" U5      [        X15      _M     snn$ U $ s  snf s  snnf N)r   r   r   r   items)r   fnkvs       r   r   r      st    +t$$.9:ka$k::+w''8C8I8I8KL8K1}Q++8KLL ;Ls   A>Bc                 0    [         R                  S U 5      $ )a  
Rewrite incorrectly cased acronyms, initialisms, and abbreviations,
allowing them to be decamelized correctly. For example, given the string
"APIResponse", this function is responsible for ensuring the output is
"api_response" instead of "a_p_i_response".

:param string: A string that may contain an incorrectly cased abbreviation.
:type string: str
:rtype: str
:returns:
    A rewritten string that is safe for decamelization.
c                 @    U R                  S5      R                  5       $ )Nr   )r   titler    s    r   r"   $_fix_abbreviations.<locals>.<lambda>   s    AGGAJ$4$4$6r   )
ACRONYM_REr   )r*   s    r   r2   r2      s     >>6??r   c                 X    UR                  S [        R                  U 5       5       5      $ )z
Split words that are separated by case differentiation.
:param string: Original string.
:param separator: String by which the individual
    words will be put back together.
:returns:
    New string.
c              3   6   #    U  H  o(       d  M  Uv   M     g 7frH    ).0r   s     r   	<genexpr>"_separate_words.<locals>.<genexpr>   s     A%;q!!%;s   
	)joinSPLIT_REsplitr)   s     r   r1   r1      s"     >>AX^^F%;AAAr   )r9   )__doc__rD   collections.abcr   compilerQ   r   rY   r%   r   r   r.   r4   r7   r:   r/   r0   r?   rA   r   r   r2   r1   rT   r   r   <module>r^      s    
 #ZZ23
JJ|$	::34

5668B4@8:*
#(0
1
02"	?@ 	Br   