
    Fwg,                        d Z ddlZddlZdZg dZg dZh dZdeded	dfd
Zd,dede	d	efdZ
ded	efdZded	efdZded	efdZded	efdZd-deded	efdZded	efdZded	efdZded	efdZded	efdZded	efdZded	efdZ edd        edd        ed d!        ed"d#        ed$d%        ed&d'        ed(d)        ed*d+       y).z
    inflection
    ~~~~~~~~~~~~

    A port of Ruby on Rails' inflector to Python.

    :copyright: (c) 2012-2020 by Janne Vanhala

    :license: MIT, see LICENSE for more details.
    Nz0.5.1))z(?i)(quiz)$z\1zes)z(?i)^(oxen)$\1)z
(?i)^(ox)$z\1en)(?i)(m|l)ice$\1ice)z(?i)(m|l)ouse$r   )z(?i)(passer)s?by$z\1sby)z(?i)(matr|vert|ind)(?:ix|ex)$z\1ices)z(?i)(x|ch|ss|sh)$\1es)z(?i)([^aeiouy]|qu)y$z\1ies)z(?i)(hive)$z\1s)z(?i)([lr])f$\1ves)z(?i)([^f])fe$r   )z(?i)sis$ses)(?i)([ti])a$\1a)z(?i)([ti])um$r
   )z(?i)(buffal|potat|tomat)o$z\1oes)z
(?i)(bu)s$z\1ses)z(?i)(alias|status)$r   )z(?i)(octop|vir)i$\1i)z(?i)(octop|vir)us$r   )z(?i)^(ax|test)is$r   )(?i)s$s)$r   )!)z(?i)(database)s$r   )z(?i)(quiz)zes$r   )z(?i)(matr)ices$z\1ix)z(?i)(vert|ind)ices$z\1ex)z(?i)(passer)sby$z\1by)z(?i)^(ox)enr   )z(?i)(alias|status)(es)?$r   )z(?i)(octop|vir)(us|i)$z\1us)z(?i)^(a)x[ie]s$z\1xis)z(?i)(cris|test)(is|es)$z\1is)z(?i)(shoe)s$r   )z
(?i)(o)es$r   )z(?i)(bus)(es)?$r   )r   z\1ouse)z(?i)(x|ch|ss|sh)es$r   )z(?i)(m)ovies$z\1ovie)z(?i)(s)eries$z\1eries)z(?i)([^aeiouy]|qu)ies$z\1y)z(?i)([lr])ves$z\1f)z(?i)(tive)s$r   )z(?i)(hive)s$r   )z(?i)([^f])ves$z\1fe)z(?i)(t)he(sis|ses)$z\1hesis)z(?i)(s)ynop(sis|ses)$z	\1ynopsis)z(?i)(p)rogno(sis|ses)$z
\1rognosis)z(?i)(p)arenthe(sis|ses)$z\1arenthesis)z(?i)(d)iagno(sis|ses)$z
\1iagnosis)z(?i)(b)a(sis|ses)$z\1asis)z(?i)(a)naly(sis|ses)$z	\1nalysis)r	   z\1um)z(?i)(n)ews$z\1ews)z	(?i)(ss)$r   )r    >	   fishricejeansmoneysheepseriesspecies	equipmentinformationsingularpluralreturnc                    dt         dt         fd}| d   j                         |d   j                         k(  rt        j                  ddj	                  | d   | dd       d|dd z   f       t        j                  ddj	                  |d   |dd       d|dd z   f       t
        j                  ddj	                  |d   |dd       d| dd z   f       yt        j                  dd	j	                  | d   j                          || dd             |d   j                         |dd z   f       t        j                  dd	j	                  | d   j                          || dd             |d   j                         |dd z   f       t        j                  dd	j	                  |d   j                          ||dd             |d   j                         |dd z   f       t        j                  dd	j	                  |d   j                          ||dd             |d   j                         |dd z   f       t
        j                  dd	j	                  |d   j                          ||dd             | d   j                         | dd z   f       t
        j                  dd	j	                  |d   j                          ||dd             | d   j                         | dd z   f       y)
z
    A convenience function to add appropriate rules to plurals and singular
    for irregular words.

    :param singular: irregular word in singular form
    :param plural: irregular word in plural form
    stringr   c                 2    dj                  d | D              S )Nr   c              3   N   K   | ]  }d |z   |j                         z   dz     yw)[]N)upper).0chars     J/var/www/horilla/myenv/lib/python3.12/site-packages/inflection/__init__.py	<genexpr>z6_irregular.<locals>.caseinsensitive.<locals>.<genexpr>d   s$     J4sTzDJJL036Js   #%)join)r   s    r%   caseinsensitivez#_irregular.<locals>.caseinsensitivec   s    wwJ6JJJ    r   z(?i)({}){}$   Nr   z{}{}$)strr"   PLURALSinsertformat	SINGULARSlower)r   r   r(   s      r%   
_irregularr1   [   s   K K K {fQioo//q!!(1+x|<F12J
 	 	q!!&)VABZ8F12J
 	 	!!&)VABZ8HQRL 
 	
 	qOOHQK--/+HQRL9;1IOOqr
*
 	
 	qOOHQK--/+HQRL9;1IOOqr
*
 	
 	qOOF1IOO-vabz/JK1IOOqr
*
 	 	qOOF1IOO-vabz/JK1IOOqr
*
 	 	OOF1IOO-vabz/JKQK(12,.
 	 	OOF1IOO-vabz/JKQK(12,.
 	r)   r   uppercase_first_letterc                 z    |rt        j                  dd |       S | d   j                         t        |       dd z   S )aC  
    Convert strings to CamelCase.

    Examples::

        >>> camelize("device_type")
        'DeviceType'
        >>> camelize("device_type", False)
        'deviceType'

    :func:`camelize` can be thought of as a inverse of :func:`underscore`,
    although there are some cases where that does not hold::

        >>> camelize(underscore("IOError"))
        'IoError'

    :param uppercase_first_letter: if set to `True` :func:`camelize` converts
        strings to UpperCamelCase. If set to `False` :func:`camelize` produces
        lowerCamelCase. Defaults to `True`.
    z
(?:^|_)(.)c                 @    | j                  d      j                         S Nr*   groupr"   ms    r%   <lambda>zcamelize.<locals>.<lambda>       qwwqz/?/?/A r)   r   r*   N)resubr0   camelize)r   r2   s     r%   r>   r>      s=    * vvm%A6JJay 8F#3AB#777r)   wordc                 &    | j                  dd      S )z{Replace underscores with dashes in the string.

    Example::

        >>> dasherize("puni_puni")
        'puni-puni'

    _-)replacer?   s    r%   	dasherizerE      s     <<S!!r)   c                     t        j                  dd|       } | j                  dd      } t        j                  dd |       } t        j                  dd |       } | S )	a<  
    Capitalize the first word and turn underscores into spaces and strip a
    trailing ``"_id"``, if any. Like :func:`titleize`, this is meant for
    creating pretty output.

    Examples::

        >>> humanize("employee_salary")
        'Employee salary'
        >>> humanize("author_id")
        'Author'

    z_id$r   rA    z(?i)([a-z\d]*)c                 @    | j                  d      j                         S r5   )r7   r0   r8   s    r%   r:   zhumanize.<locals>.<lambda>   r;   r)   z^\wc                 @    | j                  d      j                         S )Nr   r6   r8   s    r%   r:   zhumanize.<locals>.<lambda>   s    AGGAJ$4$4$6 r)   )r<   r=   rC   rD   s    r%   humanizerJ      sR     66'2t$D<<S!D66#%A4HD66&6=DKr)   numberc                 l    t        t        |             } | dz  dv ryddddj                  | dz  d      S )	a  
    Return the suffix that should be added to a number to denote the position
    in an ordered sequence such as 1st, 2nd, 3rd, 4th.

    Examples::

        >>> ordinal(1)
        'st'
        >>> ordinal(2)
        'nd'
        >>> ordinal(1002)
        'nd'
        >>> ordinal(1003)
        'rd'
        >>> ordinal(-11)
        'th'
        >>> ordinal(-1021)
        'st'

    d   )         thstndrd)r*         
   )absintgetrK   s    r%   ordinalr\      sH    * VF||# 
 #frk4
 		!r)   c                 8    dj                  | t        |             S )a  
    Turn a number into an ordinal string used to denote the position in an
    ordered sequence such as 1st, 2nd, 3rd, 4th.

    Examples::

        >>> ordinalize(1)
        '1st'
        >>> ordinalize(2)
        '2nd'
        >>> ordinalize(1002)
        '1002nd'
        >>> ordinalize(1003)
        '1003rd'
        >>> ordinalize(-11)
        '-11th'
        >>> ordinalize(-1021)
        '-1021st'

    z{}{})r.   r\   r[   s    r%   
ordinalizer^      s    * ==11r)   	separatorc                    t        |       } t        j                  d||       } |rVt        j                  |      }t        j                  d|z  ||       } t        j                  dj	                  |      d|       } | j                         S )z
    Replace special characters in a string so that it may be used as part of a
    'pretty' URL.

    Example::

        >>> parameterize(u"Donald E. Knuth")
        'donald-e-knuth'

    z(?i)[^a-z0-9\-_]+z%s{2,}z(?i)^{sep}|{sep}$)sepr   )transliterater<   r=   escaper.   r0   )r   r_   re_seps      r%   parameterizere     sv     6"FVV()V<F9%	F*Iv>,333?VL<<>r)   c                     | r| j                         t        v r| S t        D ]4  \  }}t        j                  ||       st        j
                  |||       c S  | S )a	  
    Return the plural form of a word.

    Examples::

        >>> pluralize("posts")
        'posts'
        >>> pluralize("octopus")
        'octopi'
        >>> pluralize("sheep")
        'sheep'
        >>> pluralize("CamelOctopus")
        'CamelOctopi'

    )r0   UNCOUNTABLESr,   r<   searchr=   )r?   rulereplacements      r%   	pluralizerk     sU      4::<</!( 	7D+yyt$vvdK66	7 r)   c                     t         D ]  }t        j                  d|z  |       s| c S  t        D ]4  \  }}t        j                  ||       st        j                  |||       c S  | S )ac  
    Return the singular form of a word, the reverse of :func:`pluralize`.

    Examples::

        >>> singularize("posts")
        'post'
        >>> singularize("octopi")
        'octopus'
        >>> singularize("sheep")
        'sheep'
        >>> singularize("word")
        'word'
        >>> singularize("CamelOctopi")
        'CamelOctopus'

    z(?i)\b(%s)\Z)rg   r<   rh   r/   r=   )r?   
inflectionri   rj   s       r%   singularizern   5  si    $ # 
99_z148K ' 3k99T4 66$T223 Kr)   c                 *    t        t        |             S )as  
    Create the name of a table like Rails does for models to table names. This
    method uses the :func:`pluralize` method on the last word in the string.

    Examples::

        >>> tableize('RawScaledScorer')
        'raw_scaled_scorers'
        >>> tableize('egg_and_ham')
        'egg_and_hams'
        >>> tableize('fancyCategory')
        'fancy_categories'
    )rk   
underscorerD   s    r%   tableizerq   Q  s     Z%&&r)   c           	      r    t        j                  dd t        t        |             j	                               S )a  
    Capitalize all the words and replace some characters in the string to
    create a nicer looking title. :func:`titleize` is meant for creating pretty
    output.

    Examples::

      >>> titleize("man from the boondocks")
      'Man From The Boondocks'
      >>> titleize("x-men: the last stand")
      'X Men: The Last Stand'
      >>> titleize("TheManWithoutAPast")
      'The Man Without A Past'
      >>> titleize("raiders_of_the_lost_ark")
      'Raiders Of The Lost Ark'

    z\b('?\w)c                 @    | j                  d      j                         S r5   )r7   
capitalize)matchs    r%   r:   ztitleize.<locals>.<lambda>v  s    ekk!n//1 r)   )r<   r=   rJ   rp   titlerD   s    r%   titleizerw   b  s1    $ 661D!"((* r)   c                 p    t        j                  d|       }|j                  dd      j                  d      S )u5  
    Replace non-ASCII characters with an ASCII approximation. If no
    approximation exists, the non-ASCII character is ignored. The string must
    be ``unicode``.

    Examples::

        >>> transliterate('älämölö')
        'alamolo'
        >>> transliterate('Ærøskøbing')
        'rskbing'

    NFKDasciiignore)unicodedata	normalizeencodedecode)r   
normalizeds     r%   rb   rb   {  s4     &&vv6JWh/66w??r)   c                     t        j                  dd|       } t        j                  dd|       } | j                  dd      } | j                         S )aq  
    Make an underscored, lowercase form from the expression in the string.

    Example::

        >>> underscore("DeviceType")
        'device_type'

    As a rule of thumb you can think of :func:`underscore` as the inverse of
    :func:`camelize`, though there are cases where that does not hold::

        >>> camelize(underscore("IOError"))
        'IoError'

    z([A-Z]+)([A-Z][a-z])z\1_\2z([a-z\d])([A-Z])rB   rA   )r<   r=   rC   r0   rD   s    r%   rp   rp     sF      66)8T:D66%x6D<<S!D::<r)   personpeoplemanmenhumanhumanschildchildrensexsexesmovemovescowkinezombiezombies)T)rB   )__doc__r<   r|   __version__r,   r/   rg   r+   r1   boolr>   rE   rJ   rY   r\   r^   re   rk   rn   rq   rw   rb   rp    r)   r%   <module>r      s  	 
 4"	H	2 2c 2d 2j8S 8$ 8# 86	"C 	"C 	"3 3 *!C !C !@2s 2s 20  s 0C C 2c c 8'3 '3 '"3 3 2@# @# @$S S , 8X  
5%  
7H  
7J  
5'  
67  
5&  
8Y r)   