
    M1                        S r SSKrSSKrSr/ SQr/ SQr1 SkrS rS$S jrS	 r	S
 r
S rS rS%S jrS rS rS rS rS rS r\" SS5        \" SS5        \" SS5        \" SS5        \" SS5        \" SS5        \" S S!5        \" S"S#5        g)&zImported inflection library.

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informationc           	      *   S nU S   R                  5       US   R                  5       :X  a  [        R                  SSU S   < SU SS < S3SUSS -   45        [        R                  SSUS   < SUSS < S3SUSS -   45        [        R                  SSUS   < SUSS < S3SU SS -   45        g[        R                  SU S   R                  5       < U" U SS 5      < S3US   R                  5       USS -   45        [        R                  SU S   R	                  5       < U" U SS 5      < S3US   R	                  5       USS -   45        [        R                  SUS   R                  5       < U" USS 5      < S3US   R                  5       USS -   45        [        R                  SUS   R	                  5       < U" USS 5      < S3US   R	                  5       USS -   45        [        R                  SUS   R                  5       < U" USS 5      < S3U S   R                  5       U SS -   45        [        R                  SUS   R	                  5       < U" USS 5      < S3U S   R	                  5       U SS -   45        g)	a7  Adds appropriate rules for irregular words.

A convenience function to add appropriate rules to plurals and singular
for irregular words.

Args:
  singular: (str) An irregular word in singular form
  plural: (str) An irregular word in plural form

Returns:
  A string of a corrected rule for an irregular word.
c                 2    SR                  S U  5       5      $ )Nr   c              3   T   #    U  H  nS U-   UR                  5       -   S-   v   M      g7f)[]N)upper).0chars     0platform/bq/third_party/inflection/inflection.py	<genexpr>6_irregular.<locals>.caseinsensitive.<locals>.<genexpr>l   s$     Fvt3:

,s2vs   &()joinstrings    r!   caseinsensitive#_irregular.<locals>.caseinsensitivek   s    77FvFFF    r   z(?i)()   Nr   r   )r   PLURALSinsert	SINGULARSlower)singularpluralr'   s      r!   
_irregularr2   ^   s   G a[F1IOO--NN1"1+x|4qr

  NN1 )VABZ0qr

  Q )VABZ0
 
 NN1QK%%'!")FGq	F12J&
  NN1QK%%'!")FGq	F12J&
  NN11IOO%vabz'BCq	F12J&
  NN11IOO%vabz'BCq	F12J&
  Q1IOO%vabz'BChqrl*
  Q1IOO%vabz'BChqrl*
 r)   c                     U(       a  [         R                  " SS U 5      $ U S   R                  5       [        U 5      SS -   $ )a  Convert strings to CamelCase.

Examples::

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

:func:`camelize` can be though 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`.
Args:
  string: (str) A word to camelize.
  uppercase_first_letter: (bool) Indicator to capitalize the first letter.

Returns:
  A string that has been been converted to camelcase.
z
(?:^|_)(.)c                 @    U R                  S5      R                  5       $ Nr+   groupr   ms    r!   <lambda>camelize.<locals>.<lambda>   s    1771:+;+;+=r)   r   r+   N)resubr/   camelize)r&   uppercase_first_letters     r!   r>   r>      s=    4 66-!=vFF!9??x/333r)   c                 &    U R                  SS5      $ )zReplace underscores with dashes in the string.

Example::

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

Args:
  word: (str) A word that contains underscores.

Returns:
  A string with underscores replaced with dashes.
_-)replacewords    r!   	dasherizerF      s     
c3	r)   c                     [         R                  " SSU 5      n U R                  SS5      n [         R                  " SS U 5      n [         R                  " SS U 5      n U $ )	a  Changes text into conversational english.

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"

Args:
  word: (str) A word to convert to conversational English.

Returns:
  A string that has been converted to conversational english.
z_id$r   rA    z(?i)([a-z\d]*)c                 @    U R                  S5      R                  5       $ r5   )r7   r/   r8   s    r!   r:   humanize.<locals>.<lambda>   s    QWWQZ-=-=-?r)   z^\wc                 @    U R                  S5      R                  5       $ )Nr   r6   r8   s    r!   r:   rJ      s    !''!*"2"2"4r)   )r<   r=   rC   rD   s    r!   humanizerL      sR    ( 
T	"$	c3	$	!#?	F$	4d	;$	+r)   c                 p    [        [        U 5      5      n U S-  S;   a  gSSSS.R                  U S-  S5      $ )	a  Finds a suffix based on ordinal sequence.

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"

Args:
  number: (int) A number to denote position in an ordered sequence.

Returns:
  A string of a numbers corresponding ordinal notation.
d   )         thstndrd)r+         
   )absintgetnumbers    r!   ordinalr^      sH    6 s6{&c\\!  
c&2+t	r)   c                 $    U < [        U 5      < 3$ )a  Adds the ordinal notation to the end of a number.

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"

Args:
  number: (int) A number to add ordinal notation.

Returns:
  A string of a number with its ordinal notation.
)r^   r\   s    r!   
ordinalizer`     s    6 76?	++r)   c                    [        U 5      n [        R                  " SX5      n U(       aM  [        R                  " U5      n[        R                  " SU-  X5      n [        R                  " SSU0-  SU 5      n U R	                  5       $ )a  Substitutes special characters with provided separator.

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"

Args:
  string: (str) A string to substitute into a url.
  separator: (str) A delimiter to separate each word by.

Returns:
  A string with speical characters swapped with the provided separator.
z(?i)[^a-z0-9\-_]+z%s{2,}z(?i)^%(sep)s|%(sep)s$sepr   )transliterater<   r=   escaper/   )r&   	separatorre_seps      r!   parameterizerg   &  sm    $  &66&	:&YYy!FVVI&	:FVV,v>FKF	r)   c                     U (       a  U R                  5       [        ;   a  U $ [         H9  u  p[        R                  " X5      (       d  M"  [        R
                  " XU 5      s  $    U $ )a9  Return the plural form of a word.

Examples::

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

Args:
  word: (str) A word to make plural.

Returns:
  A string of a word in its plural form.
)r/   UNCOUNTABLESr,   r<   searchr=   )rE   rulereplacements      r!   	pluralizerm   E  sM    ( 
-K$	4		vvd.. % Kr)   c                     [          H&  n[        R                  " SU-  U 5      (       d  M$  U s  $    [         H9  u  p#[        R                  " X 5      (       d  M"  [        R                  " X#U 5      s  $    U $ )a  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"

Args:
  word: (str) A word to make singular.

Returns:
  A string of a word in its singular form.
z(?i)\b(%s)\Z)ri   r<   rj   r.   r=   )rE   
inflectionrk   rl   s       r!   singularizerp   b  s_    , !j	yy:-t44k ! %d	yyVVDt,, % 
+r)   c                 *    [        [        U 5      5      $ )a  Splits a word up by underscores and makes lowercase (tableized).

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"

Args:
  word: (str) A word to put into table format.

Returns:
  A String of a word in table format.
)rm   
underscorerD   s    r!   tableizers     s    * 
:d#	$$r)   c           	      X    [         R                  " SS [        [        U 5      5      5      $ )a8  Capitalizes each word in a sentence.

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"

Args:
  string: (str) A title to captialize.

Returns:
  A string with Captials on each word.
z\b('?[a-z])c                 @    U R                  S5      R                  5       $ r5   )r7   
capitalize)matchs    r!   r:   titleize.<locals>.<lambda>  s    EKKN--/r)   )r<   r=   rL   rr   r%   s    r!   titleizery     s(    0 
/z&!"
 r)   c                 r    [         R                  " SU 5      nUR                  SS5      R                  S5      $ )u  Turn a string into ASCII notation.

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(u"älämölö")
    u"alamolo"
    >>> transliterate(u"Ærøskøbing")
    u"rskbing"

Args:
  string: (str) A string to convert to ASCII

Returns:
  A string in ASCII format.
NFKDasciiignore)unicodedata	normalizeencodedecode)r&   
normalizeds     r!   rc   rc     s4    ( $$VV4*			7H	-	4	4W	==r)   c                     [         R                  " SSU 5      n [         R                  " SSU 5      n U R                  SS5      n U R                  5       $ )a  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"

Args:
  word: (str) A word to make underscored.

Returns:
  A string with underscores.
z([A-Z]+)([A-Z][a-z])z\1_\2z([a-z\d])([A-Z])rB   rA   )r<   r=   rC   r/   rD   s    r!   rr   rr     sF    ( 
'4	8$	#Xt	4$	c3	$	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.   ri   r2   r>   rF   rL   r^   r`   rg   rm   rp   rs   ry   rc   rr    r)   r!   <module>r      s   
 
 4"	H
5p4@ "6#L,<>:@%0>>04 8X  
5%  
7H  
7J  
5'  
67  
5&  
8Y r)   