U
    ÝZßf  ã                   @   s`   d dl mZmZmZmZ d dlZe d¡Ze d¡Zdd„ Z	dd„ Z
d	d
„ Zdd„ Zdd„ ZdS )é    )Úabsolute_importÚdivisionÚprint_functionÚunicode_literalsNz9^[a-z0-9]+|[A-Z][a-z0-9]+|[A-Z]+(?=[A-Z][a-z0-9])|[A-Z]+$z[-_/]+c                 C   s>   g }t  t| ¡D ](}t |¡}|r.| |¡ q| |¡ q|S )z¤
    Splits name based on capitalization, dashes, and underscores.
        Example: 'GetFile' -> ['Get', 'File']
        Example: 'get_file' -> ['get', 'file']
    )ÚreÚsplitÚ_split_words_dashes_reÚ_split_words_capitalization_reÚfindallÚextendÚappend)ÚnameZ	all_wordsÚwordÚvals© r   ú:/tmp/pip-unpacked-wheel-vqb3mfeu/stone/backends/helpers.pyÚsplit_words   s    
r   c                 C   s>   t | ƒ}t|ƒdkst‚| d¡ ¡ }|d dd„ |D ƒ¡ S )zq
    Converts name to lower camel case. Words are identified by capitalization,
    dashes, and underscores.
    r   Ú c                 S   s   g | ]}|  ¡ ‘qS r   ©Ú
capitalize©Ú.0r   r   r   r   Ú
<listcomp>#   s     zfmt_camel.<locals>.<listcomp>)r   ÚlenÚAssertionErrorÚpopÚlowerÚjoin)r   ÚwordsÚfirstr   r   r   Ú	fmt_camel   s    r    c                 C   s   d  dd„ t| ƒD ƒ¡S )zz
    Converts name to words separated by dashes. Words are identified by
    capitalization, dashes, and underscores.
    ú-c                 S   s   g | ]}|  ¡ ‘qS r   ©r   r   r   r   r   r   +   s     zfmt_dashes.<locals>.<listcomp>©r   r   ©r   r   r   r   Ú
fmt_dashes&   s    r%   c                 C   s   d  dd„ t| ƒD ƒ¡S )zl
    Converts name to pascal case. Words are identified by capitalization,
    dashes, and underscores.
    r   c                 S   s   g | ]}|  ¡ ‘qS r   r   r   r   r   r   r   3   s     zfmt_pascal.<locals>.<listcomp>r#   r$   r   r   r   Ú
fmt_pascal.   s    r&   c                 C   s   d  dd„ t| ƒD ƒ¡S )z
    Converts name to words separated by underscores. Words are identified by
    capitalization, dashes, and underscores.
    Ú_c                 S   s   g | ]}|  ¡ ‘qS r   r"   r   r   r   r   r   ;   s     z#fmt_underscores.<locals>.<listcomp>r#   r$   r   r   r   Úfmt_underscores6   s    r(   )Ú
__future__r   r   r   r   r   Úcompiler	   r   r   r    r%   r&   r(   r   r   r   r   Ú<module>   s   ÿ
