
    Xhce                       d Z ddlmZ ddlZddlZddlmZ ddlmZm	Z	 ddl
mZ ddlmZmZ ddlmZmZ erdd	lmZmZ dd
lmZ d dZd dZd!dZ G d de      Z G d d      Z G d d      Z	 	 	 	 	 d"	 	 	 	 	 	 	 	 	 	 	 	 	 d#dZ ej<                  d      Zd dZ d$d%dZ!d&dZ"	 	 	 	 	 	 	 	 d'	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d(dZ#dddddddd	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 d)dZ$d*dZ%y)+z
    babel.messages.pofile
    ~~~~~~~~~~~~~~~~~~~~~

    Reading and writing of files in the ``gettext`` PO (portable object)
    format.

    :copyright: (c) 2013-2025 by the Babel Team.
    :license: BSD, see LICENSE for more details.
    )annotationsN)Iterable)TYPE_CHECKINGLiteral)Locale)CatalogMessage)TextWrapper_cmp)IOAnyStr)SupportsWritec                X    d }t        j                  d      j                  || dd       S )zReverse `escape` the given string.

    >>> print(unescape('"Say:\\n  \\"hello, world!\\"\\n"'))
    Say:
      "hello, world!"
    <BLANKLINE>

    :param string: the string to unescape
    c                L    | j                  d      }|dk(  ry|dk(  ry|dk(  ry|S )N   n
t	r)group)matchms     I/var/www/html/myenv/lib/python3.12/site-packages/babel/messages/pofile.pyreplace_escapesz!unescape.<locals>.replace_escapes&   s2    KKN8#X#X    z\\([\\trn"])r   )recompilesub)stringr   s     r   unescaper#      s+    	 ::o&**?F1RLIIr   c                    d| v rG| j                         }| j                  d      r|dd }t        t        |      }dj	                  |      S t        |       S )a  Reverse the normalization done by the `normalize` function.

    >>> print(denormalize(r'''""
    ... "Say:\n"
    ... "  \"hello, world!\"\n"'''))
    Say:
      "hello, world!"
    <BLANKLINE>

    >>> print(denormalize(r'''""
    ... "Say:\n"
    ... "  \"Lorem ipsum dolor sit "
    ... "amet, consectetur adipisicing"
    ... " elit, \"\n"'''))
    Say:
      "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "
    <BLANKLINE>

    :param string: the string to denormalize
    r   ""r   N )
splitlines
startswithmapr#   join)r"   escaped_linesliness      r   denormalizer-   3   sX    * v~))+T")!"-MHm,wwu~r   c                R   d| vr"d| vr| j                         j                         S g }d}d}| D ]U  }|dk(  r|rt        d      d}|dk(  r|st        d      d}-|dk(  r|r||z  }:|s=|j                  |       d}Q||z  }W |r|rt        d      |j                  |       |S )	zExtract locations from location comments.

    Locations are extracted while properly handling First Strong
    Isolate (U+2068) and Pop Directional Isolate (U+2069), used by
    gettext to enclose filenames with spaces and tabs in their names.
       ⁨   ⁩r&   Fzglocation comment contains more First Strong Isolate characters, than Pop Directional Isolate charactersTzglocation comment contains more Pop Directional Isolate characters, than First Strong Isolate characters )lstripsplit
ValueErrorappend)line	locationslocationin_filenamecs        r   _extract_locationsr;   R   s     t 4{{}""$$IHK '=  "W X XK(]  "T U UK#XA  *MH)',   "W X XX&r   c                  $     e Zd ZdZd fdZ xZS )PoFileErrorzDException thrown by PoParser when an invalid po file is encountered.c                X    t         |   | d|        || _        || _        || _        y )Nz on )super__init__catalogr6   lineno)selfmessagerA   r6   rB   	__class__s        r   r@   zPoFileError.__init__   s0    G9D12	r   )
rD   strrA   r   r6   rF   rB   intreturnNone)__name__
__module____qualname____doc__r@   __classcell__)rE   s   @r   r=   r=   ~   s    N r   r=   c                  l    e Zd ZddZddZddZddZddZddZddZ	ddZ
dd	Zdd
ZddZddZy)_NormalizedStringc                B    g | _         |D ]  }| j                  |        y N)_strsr5   )rC   argsargs      r   r@   z_NormalizedString.__init__   s$     "
 	CKK	r   c                V    | j                   j                  |j                                y rR   )rS   r5   strip)rC   ss     r   r5   z_NormalizedString.append   s    

!'')$r   c                T    dj                  t        t        | j                              S )Nr&   )r*   r)   r#   rS   rC   s    r   r-   z_NormalizedString.denormalize   s    wws8TZZ011r   c                ,    t        | j                        S rR   )boolrS   rZ   s    r   __bool__z_NormalizedString.__bool__   s    DJJr   c                T    t         j                  j                  | j                        S rR   )oslinesepr*   rS   rZ   s    r   __repr__z_NormalizedString.__repr__   s    zztzz**r   c                D    |syt        t        |       t        |            S )Nr   )r   rF   rC   others     r   __cmp__z_NormalizedString.__cmp__   s    CIs5z**r   c                *    | j                  |      dkD  S Nr   re   rc   s     r   __gt__z_NormalizedString.__gt__       ||E"Q&&r   c                *    | j                  |      dk  S rg   rh   rc   s     r   __lt__z_NormalizedString.__lt__   rj   r   c                *    | j                  |      dk\  S rg   rh   rc   s     r   __ge__z_NormalizedString.__ge__       ||E"a''r   c                *    | j                  |      dk  S rg   rh   rc   s     r   __le__z_NormalizedString.__le__   ro   r   c                *    | j                  |      dk(  S rg   rh   rc   s     r   __eq__z_NormalizedString.__eq__   ro   r   c                *    | j                  |      dk7  S rg   rh   rc   s     r   __ne__z_NormalizedString.__ne__   ro   r   N)rT   rF   rH   rI   )rX   rF   rH   rI   )rH   rF   )rH   r\   )rd   objectrH   rG   )rd   rv   rH   r\   )rJ   rK   rL   r@   r5   r-   r]   ra   re   ri   rl   rn   rq   rs   ru    r   r   rP   rP      s>    
%2 ++''((((r   rP   c                  n    e Zd ZdZg dZdddZddZddZddZdddZ	dddZ
dd	Zdd
ZddZddZy)PoFileParserzSupport class to  read messages from a ``gettext`` PO (portable object) file
    and add them to a `Catalog`

    See `read_po` for simple cases.
    )msgidmsgstrmsgctxtmsgid_pluralc                j    || _         || _        d| _        d| _        || _        | j                          y rg   )rA   ignore_obsoletecounteroffsetabort_invalid_reset_message_state)rC   rA   r   r   s       r   r@   zPoFileParser.__init__   s3    .*!!#r   c                    g | _         g | _        g | _        g | _        g | _        g | _        d | _        d| _        d| _        d| _	        d| _
        y )NF)messagestranslationsr7   flagsuser_commentsauto_commentscontextobsoletein_msgid	in_msgstr
in_msgctxtrZ   s    r   r   z!PoFileParser._reset_message_state   sR    
r   c           
        | j                   j                          t        | j                        dkD  rt	        d | j                  D              }n| j                  d   j                         }t        |t        t        f      rt        | j                  j                        D cg c]  }d }}| j                   D ]O  \  }}|| j                  j                  k\  r| j                  d| j                  d       =|j                         ||<   Q t	        |      }n | j                   d   d   j                         }| j                  r| j                  j                         nd}t        ||t        | j                        t!        | j"                        | j$                  | j&                  | j                  dz   |      }| j(                  r@| j*                  sC|| j                  j(                  | j                  j-                  ||      <   n|| j                  |<   | xj.                  dz  c_        | j1                          yc c}w )z
        Add a message to the catalog based on the current parser state and
        clear the state ready to process the next message.
        r   c              3  <   K   | ]  }|j                           y wrR   )r-   ).0r   s     r   	<genexpr>z,PoFileParser._add_message.<locals>.<genexpr>   s     Aa!--/As   r   r&   z5msg has more translations than num_plurals of catalogN)rB   r   )r   sortlenr   tupler-   
isinstancelistrangerA   num_plurals_invalid_pofiler   r   r	   r7   setr   r   r   r   r   _key_forr   r   )rC   rz   _r"   idxtranslationr|   rD   s           r   _add_messagezPoFileParser._add_message   s   
 	 t}}!A4==AAEMM!$002EedE]+"'(@(@"ABQbBFB$($5$5 8 [$,,222((T[[:qr)557s	8
 6]F&&q)!,88:F04$,,**,$%dnn)=s4::,,d.@.@WX")+ ==''OV%%dll&;&;E7&KL")DLL!!#' Cs   $	H<c                   | j                   r| j                  sb| j                  d| j                  d| j                   d   j	                          d       | j                  j                  dt        d      g       | j                          y y )Nr&   zmissing msgstr for msgid 'r   ')r   r   r   r   r-   r5   rP   r   rZ   s    r   _finish_current_messagez$PoFileParser._finish_current_message   sz    ==$$$$R8RSWS`S`abScSoSoSqRrrs6tu!!((!->r-B)CD	 r   c                r    |j                  d      r| j                  ||       y | j                  |||       y )N")r(   !_process_string_continuation_line_process_keyword_line)rC   rB   r6   r   s       r   _process_message_linez"PoFileParser._process_message_line   s0    ??3224@&&vtX>r   c                   | j                   D ]4  }	 |j                  |      r |t        |         dv r|t        |      d  } n6 | j	                  ||d       y |dv r| j                          || _        |dk(  r|| _        |dv r3d| _        d| _	        | j                  j                  t        |             y |d	k(  rd| _	        d| _        |j                  d
      rH|dd  j                  dd      \  }}| j                  j                  t!        |      t        |      g       y | j                  j                  dt        |      g       y |dk(  rd| _        t        |      | _        y y # t        $ r | j	                  ||d       Y yw xY w)N)r1   [z$Keyword must be followed by a stringz0Start of line didn't match any expected keyword.)rz   r|   rz   )rz   r}   FTr{   r   r   ]r   r|   )	_keywordsr(   r   
IndexErrorr   r   r   r   r   r   r   r5   rP   r   r3   r   rG   r   )rC   rB   r6   r   keywordrU   r   msgs           r   r   z"PoFileParser._process_keyword_line  s   ~~ 		G[??7+S\0Bj0Ps7|}-C			   v/ab**((*  g DK//#DO DMMM  !23!78 !DM!DN~~c"qr7==a0S!!((#c(4Ec4J)KL!!((!->s-C)DE	!"DO,S1DL "=  [$$T63YZ[s   /E''FFc                    | j                   r| j                  d   }nL| j                  r| j                  d   d   }n-| j                  r| j
                  }n| j                  ||d       y |j                  |       y )Nr   r   z<Got line starting with " but not in msgid, msgstr or msgctxt)r   r   r   r   r   r   r   r5   )rC   r6   rB   rX   s       r   r   z.PoFileParser._process_string_continuation_line-  sd    ==b!A^^!!"%a(A__A  v/no	r   c                   | j                          |dd  j                  d      rzt        |dd        D ]h  }|j                  d      }|dk\  r3	 t	        ||dz   d        }| j                  j                  |d | |f       L| j                  j                  |d f       j y |dd  j                  d      rQ|dd  j                         j                  d      D ]+  }| j                  j                  |j                                - y |dd  j                  d      r2|dd  j                         }|r| j                  j                  |       y y | j                  j                  |dd  j                                y # t
        $ r Y Pw xY w)Nr   :   r   ,.)r   r(   r;   rfindrG   r4   r7   r5   r2   r3   r   rW   r   r   )rC   r6   r8   posrB   flagcomments          r   _process_commentzPoFileParser._process_comment9  so   $$&8s#.tABx8 	<nnS)!8!!$XcAgh%7!8 NN))8DS>6*BCNN))8T*:;	< !"X  %QR)//4 0

!!$**,/0!"X  %12hnn&G""))'2  %%d12hnn&67 & ! !s   E77	FFc           	     8   t        |      D ]  \  }}|j                         }t        |t              s%|j	                  | j
                  j                        }|sN|j                  d      rM|dd j                  d      r&| j                  ||dd j                         d       	 | j                  |       | j                  ||        | j                          | j                  s| j                  s| j                   s| j"                  r[| j$                  j'                  t)        d             | j*                  j'                  d	t)        d      g       | j-                          yyy# t        $ r'}| j                  ||t        |             Y d}~d}~ww xY w)
z
        Reads from the file-like object `fileobj` and adds any po file
        units found in it to the `Catalog` supplied to the constructor.
        #r   N~r   T)r   r%   r   )	enumeraterW   r   rF   decoderA   charsetr(   r   r2   r   r4   r   r   r   r   r   r   r   r5   rP   r   r   )rC   fileobjrB   r6   excs        r   parsezPoFileParser.parseT  s^    &g. 	9LFD::<DdC({{4<<#7#78s#8&&s+..vtABx7HSW.XE--d3 **648	9" 	$$& ||t/A/ATEWEWMM  !24!89$$a):4)@%AB FX| & E,,T63s8DDEs   &E))	F2FFc                    t        |t              sJ | j                  rt        || j                  ||      t        d|       t        d|dz    d|       y )NzWARNING:zWARNING: Problem on line r   z: )r   rF   r   r=   rA   print)rC   r6   rB   r   s       r   r   zPoFileParser._invalid_pofilet  sT    $$$$c4<<v>>j#)&1*Rx@Ar   N)FF)rA   r   r   r\   r   r\   rH   rI   )rH   rI   )F)r   IO[AnyStr] | Iterable[AnyStr]rH   rI   )rJ   rK   rL   rM   r   r@   r   r   r   r   r   r   r   r   r   rw   r   r   ry   ry      sD    I$ $@ ?'2R
86 @Br   ry   Fc                `    t        |||      }t        |||      }|j                  |        |S )a  Read messages from a ``gettext`` PO (portable object) file from the given
    file-like object (or an iterable of lines) and return a `Catalog`.

    >>> from datetime import datetime
    >>> from io import StringIO
    >>> buf = StringIO('''
    ... #: main.py:1
    ... #, fuzzy, python-format
    ... msgid "foo %(name)s"
    ... msgstr "quux %(name)s"
    ...
    ... # A user comment
    ... #. An auto comment
    ... #: main.py:3
    ... msgid "bar"
    ... msgid_plural "baz"
    ... msgstr[0] "bar"
    ... msgstr[1] "baaz"
    ... ''')
    >>> catalog = read_po(buf)
    >>> catalog.revision_date = datetime(2007, 4, 1)

    >>> for message in catalog:
    ...     if message.id:
    ...         print((message.id, message.string))
    ...         print(' ', (message.locations, sorted(list(message.flags))))
    ...         print(' ', (message.user_comments, message.auto_comments))
    (u'foo %(name)s', u'quux %(name)s')
      ([(u'main.py', 1)], [u'fuzzy', u'python-format'])
      ([], [])
    ((u'bar', u'baz'), (u'bar', u'baaz'))
      ([(u'main.py', 3)], [])
      ([u'A user comment'], [u'An auto comment'])

    .. versionadded:: 1.0
       Added support for explicit charset argument.

    :param fileobj: the file-like object (or iterable of lines) to read the PO file from
    :param locale: the locale identifier or `Locale` object, or `None`
                   if the catalog is not bound to a locale (which basically
                   means it's a template)
    :param domain: the message domain
    :param ignore_obsolete: whether to ignore obsolete messages in the input
    :param charset: the character set of the catalog.
    :param abort_invalid: abort read if po file is invalid
    )localedomainr   )r   )r   ry   r   )r   r   r   r   r   r   rA   parsers           r   read_por   |  s2    l VFGDG'?-PF
LLNr   zL(\s+|[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))c                    d| j                  dd      j                  dd      j                  dd      j                  dd	      j                  d
d      z  S )zEscape the given string so that it can be included in double-quoted
    strings in ``PO`` files.

    >>> escape('''Say:
    ...   "hello, world!"
    ... ''')
    '"Say:\\n  \\"hello, world!\\"\\n"'

    :param string: the string to escape
    z"%s"\z\\r   z\tr   z\rr   z\nr   z\")replace)r"   s    r   escaper     sN     FNN40"74/"74/"74/"74/	0 0r   L   c           
        |r|dkD  rt        |      }g }| j                  d      D ]  }t        t        |            |z   |kD  rt        j	                  |      }|j                          |sEg }d}|rot        t        |d               dz
  |z   }	||	z   |k  r%|j                  |j                                ||	z  }n"|s|j                  |j                                n|ro|j                  dj                  |             |r|j                  |        n| j                  d      }t        |      dk  rt        |       S |r|d   s|d= |dxx   dz  cc<   ddj                  |D cg c]  }|t        |      z    c}      z   S c c}w )	a  Convert a string into a format that is appropriate for .po files.

    >>> print(normalize('''Say:
    ...   "hello, world!"
    ... ''', width=None))
    ""
    "Say:\n"
    "  \"hello, world!\"\n"

    >>> print(normalize('''Say:
    ...   "Lorem ipsum dolor sit amet, consectetur adipisicing elit, "
    ... ''', width=32))
    ""
    "Say:\n"
    "  \"Lorem ipsum dolor sit "
    "amet, consectetur adipisicing"
    " elit, \"\n"

    :param string: the string to normalize
    :param prefix: a string that should be prepended to every line
    :param width: the maximum line width; use `None`, 0, or a negative number
                  to completely disable line wrapping
    r   Tr   r   r&   r   r   z""
)	r   r'   r   WORD_SEPr3   reverser5   popr*   )
r"   prefixwidth	prefixlenr,   r6   chunksbufsizelengths
             r   	normalizer     sq   0 K	%%d+ 	#D6$< 9,u4!- CD !$VF2J%7!81!<y!H&=50JJvzz|4 FND#& !$

6::< 8! ! LL.   T")	#, !!$'
5zQf~ U2Y"Ib	T	DII5I4 5IJJJIs   +F	
c                r    d| vrd| vr| S | j                  d      sd| z   } | j                  d      s| dz  } | S )zEnclose filenames which include white spaces or tabs.

    Do the same as gettext and enclose filenames which contain white
    spaces or tabs with First Strong Isolate (U+2068) and Pop
    Directional Isolate (U+2069).
    r1   r   r/   r0   )r(   endswith)filenames    r   _enclose_filename_if_necessaryr     sM     (t83x(h&X&HOr   Tc
           
         d}
|rd}
n|rd}
t        |||	||||
|      D ]?  }t        |t              r|j                  |j                  d      }| j                  |       A y)a  Write a ``gettext`` PO (portable object) template file for a given
    message catalog to the provided file-like object.

    >>> catalog = Catalog()
    >>> catalog.add(u'foo %(name)s', locations=[('main.py', 1)],
    ...             flags=('fuzzy',))
    <Message...>
    >>> catalog.add((u'bar', u'baz'), locations=[('main.py', 3)])
    <Message...>
    >>> from io import BytesIO
    >>> buf = BytesIO()
    >>> write_po(buf, catalog, omit_header=True)
    >>> print(buf.getvalue().decode("utf8"))
    #: main.py:1
    #, fuzzy, python-format
    msgid "foo %(name)s"
    msgstr ""
    <BLANKLINE>
    #: main.py:3
    msgid "bar"
    msgid_plural "baz"
    msgstr[0] ""
    msgstr[1] ""
    <BLANKLINE>
    <BLANKLINE>

    :param fileobj: the file-like object to write to
    :param catalog: the `Catalog` instance
    :param width: the maximum line width for the generated output; use `None`,
                  0, or a negative number to completely disable line wrapping
    :param no_location: do not emit a location comment for every message
    :param omit_header: do not include the ``msgid ""`` entry at the top of the
                        output
    :param sort_output: whether to sort the messages in the output by msgid
    :param sort_by_file: whether to sort the messages in the output by their
                         locations
    :param ignore_obsolete: whether to ignore obsolete messages and not include
                            them in the output; by default they are included as
                            comments
    :param include_previous: include the old msgid as a comment when
                             updating the catalog
    :param include_lineno: include line number in the location comment
    NrD   r8   r   include_linenoinclude_previousno_locationomit_headersort_byr   backslashreplace)generate_por   rF   encoder   write)r   rA   r   r   r   sort_outputsort_by_filer   r   r   r   r6   s               r   write_por     ss    p G	'%)	  dC ;;w0BCDdr   r   c             #     K   rdkD  rnd}t        |d      t        dd      }	dfd	}
d fd		}t         |
      D ]  }|j                  sY|r j                  }rAdkD  r<g }|j	                         D ]  }||	j                  |      z  } dj                  |      }| d |j                  D ]  } |
|      E d{     |j                  D ]  } |
|d      E d{     |sg }	 t        |j                  d       }|D ]R  \  }}|j                  t        j                  d      }t        |      }|r
|r| d|d}||vsB|j!                  |       T  |
dj                  |      d      E d{    |j"                  r-ddj                  dgt        |j"                               d |j$                  rv|rt |
dt'        |j$                  d          d      E d{    t)        |j$                        dkD  r/t'        |j$                  d         } |
d| d      E d{     ||      E d{    d  |sbt         j*                  j-                         |
      D ]9  }|j                  D ]  } |
|      E d{      ||d      E d{    d ; yy7 7 # t        $ r |j                  }Y w xY w7 ^7 7 7 7 K7 9w)zYield text strings representing a ``gettext`` PO (portable object) file.

    See `write_po()` for a more detailed description.
    r   r   F)r   break_long_wordsz# )r   subsequent_indentr   r&   c              3  l   K   j                  |       D ]  }d| d|j                          d  y w)Nr   r1   r   )wraprW   )r   r   r6   comment_wrappers      r   _format_commentz$generate_po.<locals>._format_comment  s<     #((1 	0DfXQtzz|nB//	0s   14c           
   3    K   t        | j                  t        t        f      r| j                  r | dt        | j                  |       d | dt        | j                  d   |       d | dt        | j                  d   |       d t        j                        D ],  }	 | j                  |   }| d	|d
dt        ||       d . y | j                  r | dt        | j                  |       d | dt        | j                  |       d | dt        | j                  xs d|       d y # t        $ r d}Y w xY ww)Nzmsgctxt )r   r   r   msgid r   msgid_plural r   r&   zmsgstr[dz] zmsgstr )
r   idr   r   r   r   r   r   r"   r   )rD   r   r   r"   rA   r   s       r   _format_messagez$generate_po.<locals>._format_message  st    gjj4-07??6Y^)_(``bccHF9WZZ]6QV#W"XXZ[[HM)GJJqM&X]*^)__abbW001 c $^^C0F  Awb6&X]1^0__abbc 7??6Y^)_(``bccHF9WZZe#T"UUWXXHGIgnn.B6Y^$_#``bcc "  F s+   B+E/E>BEEEEE)r   r   Nr   )r   c                H    | d   t        | d   t              xr | d   xs dfS )Nr   r   r   )r   rG   )xs    r   <lambda>zgenerate_po.<locals>.<lambda>  s,    !A$
1Q48M8VRSTURV8\Z\1] r   key/r   r   r1   r   z, r   )r   |r   r   z#~ )r&   )r
   _sort_messagesr   header_commentr'   r   r*   r   r   sortedr7   	TypeErrorr   r_   sepr   r5   r   previous_idr   r   r   values)rA   r   r   r   r   r   r   r   comment_widthheader_wrapperr   r   rD   comment_headerr,   r6   r   locsr7   r   rB   r8   norm_previous_idr   s   `      `               @r   r   r   l  s,    " #uqyEbM!NO uW\]N0d& "'7; 3zz$33N*557 7D^0066E7!%5!1#$B'',, 	0G&w///	0,, 	<G&ws;;;	< D."7#4#4']_	
 %. * &#++BFFC89(Cn"*1VAJ7H4'KK)* 'sxx~cBBB==dii <fW]]&; <=>bAA#3&7#6#6q#9GHI   7&&'!+#,W-@-@-C5#Q *];K:L+MVYZZZ"7+++
g3j %##%
 	G #00 4*73334&wu===J	 Q 0;  .#--	. C
 [+ 4=s   CK.	J?
"K.,K-
K.8KAK./K.K!A3K.7K$8AK.>K&?K.K(AK.K*K.2K,3K.K.KK.KK.$K.&K.(K.*K.,K.c                z    t        |       } |dk(  r| j                          | S |dk(  r| j                  d        | S )z
    Sort the given message iterable by the given criteria.

    Always returns a list.

    :param messages: An iterable of Messages.
    :param sort_by: Sort by which criteria? Options are `message` and `location`.
    :return: list[Message]
    rD   r8   c                    | j                   S rR   )r7   )r   s    r   r   z _sort_messages.<locals>.<lambda>  s
    AKK r   r   )r   r   )r   r   s     r   r  r    sC     H~H) O 
J	/0Or   )r"   rF   rH   rF   )r6   rF   rH   z	list[str])NNFNF)r   r   r   zLocale | str | Noner   
str | Noner   r\   r   r  r   r\   rH   r   )r&   r   )r"   rF   r   rF   r   rG   rH   rF   )r   rF   rH   rF   )r   FFFFFFT)r   zSupportsWrite[bytes]rA   r   r   rG   r   r\   r   r\   r   r\   r   r\   r   r\   r   r\   r   r\   rH   rI   )rA   r   r   r\   r   r\   r   r\   r   r\   r   r\   r   %Literal['message', 'location'] | Noner   rG   rH   zIterable[str])r   zIterable[Message]r   r  rH   zlist[Message])&rM   
__future__r   r_   r   collections.abcr   typingr   r   
babel.corer   babel.messages.catalogr   r	   
babel.utilr
   r   r   r   	_typeshedr   r#   r-   r;   	Exceptionr=   rP   ry   r   r    r   r   r   r   r   r   r  rw   r   r   <module>r     s  	 # 	 	 $ )  3 (!'J. >)X) )( )(XEB EBT #'!9*99 9 	9
 9 9 9x 2::  0$:Kz( !"J!JJ J 	J
 J J J J J J 
J` ""59jj j 	j
 j j j 3j j jZr   