
    Mhce                       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 dDdZdDdZdEdZ G d de          Z G d d          Z G d d          Z	 	 	 	 	 dFdGd%Z ej        d&          ZdDd'Z dHdId-Z!dJd/Z"	 	 	 	 	 	 	 	 dKdLd:Z#dd0ddddd)d;dMd?Z$dNdCZ%dS )Oz
    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)SupportsWritestringstrreturnc                h    d }t          j        d                              || 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                `    |                      d          }|dk    rdS |dk    rdS |dk    rdS |S )N   n
t	r)group)matchms     U/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/babel/messages/pofile.pyreplace_escapesz!unescape.<locals>.replace_escapes&   s@    KKNN884#XX4#XX4    z\\([\\trn"])r   )recompilesub)r   r   s     r   unescaper%      s;    	 	 	 :o&&**?F1R4LIIIr    c                    d| v r]|                                  }|                     d          r
|dd         }t          t          |          }d                    |          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   so    * v~~))++T"" 	.)!""-MHm,,wwu~~r    line	list[str]c                   d| vr*d| vr&|                                                                  S g }d}d}| D ]c}|dk    r|rt          d          d}|dk    r|st          d          d}6|dk    r"|r||z  }D|r|                    |           d}^||z  }d|r&|rt          d          |                    |           |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)r0   	locationslocationin_filenamecs        r   _extract_locationsr>   R   sJ    t 4 4{{}}""$$$IHK ' '== X  "W X X XK(]] U  "T U U UK#XX A   ***MHH 	' X  "W X 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.messager   catalogr   r0   linenointr   Nonec                ~    t                                          | d|            || _        || _        || _        d S )Nz on )super__init__rB   r0   rC   )selfrA   rB   r0   rC   	__class__s        r   rH   zPoFileError.__init__   sB    G1111222	r    )
rA   r   rB   r   r0   r   rC   rD   r   rE   )__name__
__module____qualname____doc__rH   __classcell__)rJ   s   @r   r@   r@   ~   sC        NN         r    r@   c                  n    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dS )_NormalizedStringargsr   r   rE   c                H    g | _         |D ]}|                     |           d S N)_strsr9   )rI   rR   args      r   rH   z_NormalizedString.__init__   s7     "
 	 	CKK	 	r    sc                ^    | j                             |                                           d S rT   )rU   r9   strip)rI   rW   s     r   r9   z_NormalizedString.append   s&    
!''))$$$$$r    c                \    d                     t          t          | j                            S )Nr(   )r,   r+   r%   rU   rI   s    r   r/   z_NormalizedString.denormalize   s     wws8TZ00111r    boolc                *    t          | j                  S rT   )r\   rU   r[   s    r   __bool__z_NormalizedString.__bool__   s    DJr    c                J    t           j                            | j                  S rT   )oslinesepr,   rU   r[   s    r   __repr__z_NormalizedString.__repr__   s    ztz***r    otherobjectrD   c                ^    |sdS t          t          |           t          |                    S )Nr   )r   r   rI   rc   s     r   __cmp__z_NormalizedString.__cmp__   s+     	1CIIs5zz***r    c                4    |                      |          dk    S Nr   rg   rf   s     r   __gt__z_NormalizedString.__gt__       ||E""Q&&r    c                4    |                      |          dk     S ri   rj   rf   s     r   __lt__z_NormalizedString.__lt__   rl   r    c                4    |                      |          dk    S ri   rj   rf   s     r   __ge__z_NormalizedString.__ge__       ||E""a''r    c                4    |                      |          dk    S ri   rj   rf   s     r   __le__z_NormalizedString.__le__   rq   r    c                4    |                      |          dk    S ri   rj   rf   s     r   __eq__z_NormalizedString.__eq__   rq   r    c                4    |                      |          dk    S ri   rj   rf   s     r   __ne__z_NormalizedString.__ne__   rq   r    N)rR   r   r   rE   )rW   r   r   rE   )r   r   )r   r\   )rc   rd   r   rD   )rc   rd   r   r\   )rK   rL   rM   rH   r9   r/   r^   rb   rg   rk   rn   rp   rs   ru   rw    r    r   rQ   rQ      s          
% % % %2 2 2 2       + + + ++ + + +' ' ' '' ' ' '( ( ( (( ( ( (( ( ( (( ( ( ( ( (r    rQ   c                  p    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dS )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_pluralFrB   r   ignore_obsoleter\   abort_invalidr   rE   c                t    || _         || _        d| _        d| _        || _        |                                  d S ri   )rB   r   counteroffsetr   _reset_message_state)rI   rB   r   r   s       r   rH   zPoFileParser.__init__   s?    .*!!#####r    c                    g | _         g | _        g | _        g | _        g | _        g | _        d | _        d| _        d| _        d| _	        d| _
        d S )NF)messagestranslationsr:   flagsuser_commentsauto_commentscontextobsoletein_msgid	in_msgstr
in_msgctxtr[   s    r   r   z!PoFileParser._reset_message_state   sV    
r    c           
        | j                                          t          | j                  dk    rt	          d | j        D                       }n| j        d                                         }t          |t          t          f          rd t          | j	        j
                  D             }| j         D ]I\  }}|| j	        j
        k    r|                     d| j        d           2|                                ||<   Jt	          |          }n%| j         d         d                                         }| j        r| j                                        nd}t          ||t          | j                  t!          | j                  | j        | j        | j        dz   |          }| j        r0| j        s(|| j	        j        | j	                            ||          <   n
|| j	        |<   | xj        dz  c_        |                                  dS )	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   | ]}|                                 V  d S rT   )r/   ).0r   s     r   	<genexpr>z,PoFileParser._add_message.<locals>.<genexpr>   s*      AAa!--//AAAAAAr    r   c                    g | ]}d S r(   rx   )r   _s     r   
<listcomp>z-PoFileParser._add_message.<locals>.<listcomp>   s    BBBQbBBBr    r(   z5msg has more translations than num_plurals of catalogN)rC   r   )r   sortlenr   tupler/   
isinstancelistrangerB   num_plurals_invalid_pofiler   r   r	   r:   setr   r   r   r   r   _key_forr   r   )rI   r{   r   idxtranslationr}   rA   s          r   _add_messagezPoFileParser._add_message   s   
 	   t}!!AA4=AAAAAEEM!$0022EedE]++ 		;BB%(@"A"ABBBF$($5 8 8 [$,222((T[:qrrr)5577s6]]FF&q)!,88::F04F$,**,,,$%dn)=)=s4:,d.@WX")+ + + = 	*' WOV%dl&;&;E7&K&KL")DL!!#####r    c                   | j         r| j        sf|                     d| j        d| j         d                                          d           | j                            dt          d          g           |                                  d S d S )Nr(   zmissing msgstr for msgid 'r   ')r   r   r   r   r/   r9   rQ   r   r[   s    r   _finish_current_messagez$PoFileParser._finish_current_message   s    = 	 $ E$$R6tSWS`abScSoSoSqSq6t6t6tuuu!((!->r-B-B)CDDD		  	 r    c                    |                     d          r|                     ||           d S |                     |||           d S )N")r*   !_process_string_continuation_line_process_keyword_line)rI   rC   r0   r   s       r   _process_message_linez"PoFileParser._process_message_line   sP    ??3 	?224@@@@@&&vtX>>>>>r    c                   | j         D ]o}	 |                    |          r0|t          |                   dv r|t          |          d          } nAI# t          $ r |                     ||d           Y lw xY w|                     ||d           d S |dv r|                                  || _        |dk    r|| _        |dv r7d| _        d| _	        | j
                            t          |                     d S |d	k    rd| _	        d| _        |                    d
          rY|dd                              dd          \  }}| j                            t!          |          t          |          g           d S | j                            dt          |          g           d S |dk    rd| _        t          |          | _        d S d S )N)r5   [z$Keyword must be followed by a stringz0Start of line didn't match any expected keyword.)r{   r}   r{   )r{   r~   FTr|   r   r   ]r   r}   )	_keywordsr*   r   
IndexErrorr   r   r   r   r   r   r   r9   rQ   r   r7   r   rD   r   )rI   rC   r0   r   keywordrV   r   msgs           r   r   z"PoFileParser._process_keyword_line  s   ~ 		 		G[??7++ S\\0Bj0P0Ps7||}}-CE [ [ [$$T63YZZZZZ[   v/abbbF***((***  g DK///#DO DMM  !23!7!788888  !DM!DN~~c"" Fqrr7==a00S!((#c((4Ec4J4J)KLLLLL!((!->s-C-C)DEEEEE	!!"DO,S11DLLL "!s   AA!A54A5c                    | j         r| j        d         }nC| j        r| j        d         d         }n(| j        r| j        }n|                     ||d           d S |                    |           d S )Nr!   r   z<Got line starting with " but not in msgid, msgstr or msgctxt)r   r   r   r   r   r   r   r9   )rI   r0   rC   rW   s       r   r   z.PoFileParser._process_string_continuation_line-  s|    = 	b!AA^ 	!"%a(AA_ 	AA  v/noooF	r    c                   |                                   |dd                              d          rt          |dd                    D ]}|                    d          }|dk    rQ	 t	          ||dz   d                    }n# t
          $ r Y Ew xY w| j                            |d |         |f           n| j                            |d f           d S |dd                              d          r`|dd                                          	                    d          D ].}| j
                            |                                           /d S |dd                              d          r<|dd                                          }|r| j                            |           d S d S | j                            |dd                                                     d S )Nr   :   r   ,.)r   r*   r>   rfindrD   r8   r:   r9   r6   r7   r   rY   r   r   )rI   r0   r;   posrC   flagcomments          r   _process_commentzPoFileParser._process_comment9  s	   $$&&&8s## 	8.tABBx88 	< 	<nnS))!88!!$XcAghh%7!8!8% ! ! ! !N))8DSD>6*BCCCCN))8T*:;;;;	< 	< !""X  %% 
	8QRR))//44 0 0
!!$**,,////0 0!""X  %% 	8122hnn&&G 3"))'222223 3 %%d122hnn&6&677777s   'B
BBfileobjIO[AnyStr] | Iterable[AnyStr]c           	        t          |          D ]\  }}|                                }t          |t                    s|                    | j        j                  }|sQ|                    d          r|dd                             d          r3|                     ||dd         	                                d           	 | 
                    |           # t          $ r/}|                     ||t          |                     Y d}~d}~ww xY w|                     ||           !|                                  | j        s{| j        s| j        s| j        rh| j                            t)          d                     | j                            d	t)          d          g           |                                  dS dS dS )
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   )	enumeraterY   r   r   decoderB   charsetr*   r   r6   r   r8   r   r   r   r   r   r   r   r9   rQ   r   r   )rI   r   rC   r0   excs        r   parsezPoFileParser.parseT  s    &g.. 	9 	9LFD::<<DdC(( 9{{4<#788 s## 	98&&s++ E..vtABBx7H7HSW.XXXXE--d3333% E E E,,T63s88DDDDDDDDE **648888$$&&& | 	  	 t/A 	 TEW 	 M  !24!8!8999$$a):4)@)@%ABBB	  	  	  	 s   C
D'$DDc                    t          |t                    sJ | j        rt          || j        ||          t          d|           t          d|dz    d|           d S )NzWARNING:zWARNING: Problem on line r   z: )r   r   r   r@   rB   print)rI   r0   rC   r   s       r   r   zPoFileParser._invalid_pofilet  sr    $$$$$$ 	?c4<v>>>j#@&1*@@@@AAAAAr    N)FF)rB   r   r   r\   r   r\   r   rE   )r   rE   )F)r   r   r   rE   )rK   rL   rM   rN   r   rH   r   r   r   r   r   r   r   r   r   rx   r    r   rz   rz      s          I$ $ $ $ $       $ $ $ $@       ? ? ? ? ?'2 '2 '2 '2 '2R
 
 
 
8 8 8 86       @B B B B B Br    rz   Fr   r   localeLocale | str | Nonedomain
str | Noner   r\   r   r   r   c                x    t          |||          }t          |||          }|                    |            |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
    )r   r   r   )r   )r   rz   r   )r   r   r   r   r   r   rB   parsers           r   read_por   |  sD    l VFGDDDG'?-PPPF
LLNr    zL(\s+|[^\s\w]*\w+[a-zA-Z]-(?=\w+[a-zA-Z])|(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))c                    d|                      dd                               dd                               dd                               dd	                               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     s]     FNN400"74//"74//"74//"74//	0 0r    r(   L   prefixwidthrD   c                   |rW|dk    rPt                    }g }|                     d          D ]'}t          t          |                    |z   |k    rt                              |          }|                                 |rg }d}|rt          t          |d                             dz
  |z   }	||	z   |k     r-|                    |                                           ||	z  }n*|s'|                    |                                           n||                    d                    |                     ||                    |           )n|                     d          }t          |          dk    rt          |           S |r|d         s|d= |dxx         dz  cc<   dd                    fd	|D                       z   S )
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""
c                4    g | ]}t          |          z   S rx   )r   )r   r0   r   s     r   r   znormalize.<locals>.<listcomp>  s$    III4 5IIIr    )	r   r)   r   WORD_SEPr7   reverser9   popr,   )
r   r   r   	prefixlenr.   r0   chunksbufsizelengths
    `        r   	normalizer     s   0  (KK	%%d++ 	# 	#D6$<<  9,u44!--    /CD  
"!$VF2J%7%7!8!81!<y!H&=500JJvzz||444 FNDD#& 9 !$

6::<< 8 8 8! ! 
" LL...  /  T"""")	#, !!$''
5zzQf~~  U2Y "Ib			T			DIIIIII5IIIJJJJr    filenamec                    d| vrd| vr| S |                      d          sd| z   } |                     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).
    r5   r   r3   r4   )r*   endswith)r   s    r   _enclose_filename_if_necessaryr     sc     (t833x(( 'h&X&& HOr    TSupportsWrite[bytes]rB   no_locationomit_headersort_outputsort_by_fileinclude_previousinclude_linenorE   c
           
         d}
|rd}
n|rd}
t          |||	||||
|          D ]G}t          |t                    r|                    |j        d          }|                     |           HdS )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
    NrA   r;   r   r   r   r   r   sort_byr   backslashreplace)generate_por   r   encoder   write)r   rB   r   r   r   r   r   r   r   r   r   r0   s               r   write_por     s    p G 	 '%)	 	 	   dC   	D;;w0BCCDd r    r   r   %Literal['message', 'location'] | NoneIterable[str]c             #     K   rdk    rnd}t          |d          t          dd          }	dfd	}
d fd		}t           |
          D ]&}|j        s_|r j        }rLdk    rFg }|                                D ]}||	                    |          z  }d                    |          }| dV  |j        D ]} |
|          E d{V  |j        D ]} |
|d          E d{V  |sg }	 t          |j
        d           }n# t          $ r
 |j
        }Y nw xY w|D ]Y\  }}|                    t          j        d          }t          |          }|r
|r| d|d}||vr|                    |           Z |
d                    |          d          E d{V  |j        r0dd                    dgt          |j                             dV  |j        r||rz |
dt'          |j        d                    d          E d{V  t)          |j                  dk    r2t'          |j        d                   } |
d| d          E d{V   ||          E d{V  dV  (|s]t           j                                        |
          D ]6}|j        D ]} |
|          E d{V   ||d          E d{V  dV  5dS dS )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  v   K                        |           D ]}d| d|                                 dV   d S )Nr   r5   r   )wraprY   )r   r   r0   comment_wrappers      r   _format_commentz$generate_po.<locals>._format_comment  sX      #((11 	0 	0D/f//tzz||///////	0 	0r    c           
   3    K   t          | j        t          t          f          r| j        r| dt          | j        |           dV  | dt          | j        d         |           dV  | dt          | j        d         |           dV  t          j                  D ]A}	 | j        |         }n# t          $ r d}Y nw xY w| d	|d
dt          ||           dV  Bd S | j        r| dt          | j        |           dV  | dt          | j        |           dV  | dt          | j        pd|           dV  d S )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   )rA   r   r   r   rB   r   s       r   _format_messagez$generate_po.<locals>._format_message  s     gj4-00 	d dcc7?6Y^)_)_)_cccccc[[9WZ]6QV#W#W#W[[[[[[bb)GJqM&X]*^*^*^bbbbbbW011 c c $^C0FF!      FFF bbbbb6&X]1^1^1^bbbbbbbc c  dcc7?6Y^)_)_)_ccccccXX9WZe#T#T#TXXXXXXccIgn.B6Y^$_$_$_ccccccccs   ,B::C	C	)r   r   Nr   )r   c                \    | d         t          | d         t                    r| d         pdfS )Nr   r   r!   )r   rD   )xs    r   <lambda>zgenerate_po.<locals>.<lambda>  s/    !A$
1Q48M8M8VRSTURV8\Z\1] r    key/r   r  r5   r   z, r  )r   |r   r  z#~ r   )r
   _sort_messagesr  header_commentr)   r   r,   r   r   sortedr:   	TypeErrorr   r`   sepr   r9   r   previous_idr   r   r   values)rB   r   r   r   r   r   r   r   comment_widthheader_wrapperr   r  rA   comment_headerr.   r0   r   locsr:   r   rC   r;   norm_previous_idr   s   `      `               @r   r   r   l  s     " #8uqyyEEbM!NNNO uW\]]]N0 0 0 0 0 0d d d d d d d& "'7;;; 3 3z 		( $3N 2*5577 7 7D^00666EE!%5!1!1#'''''', 	0 	0G&w//////////, 	< 	<G&ws;;;;;;;;;;; 	CD."7#4']']_ _ _		 . . .#-			. %. * * &#++BFC889(CC 8n 8"*77V777H4''KK)))&sxx~~cBBBBBBBBBB= 	BAdii <fW]&;&; <==AAAAAA 	[#3 	[&I7#6q#9GGGII          7&''!++#,W-@-C5#Q#Q#Q *?+M;K+M+MVYZZZZZZZZZZ"?7+++++++++



 %##%%
 
 
 	 	G #0 4 4*?73333333333&wu==========JJJJ 	 	s   9DD%$D%r   Iterable[Message]list[Message]c                    t          |           } |dk    r|                                  n|dk    r|                     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]
    rA   r;   c                    | j         S rT   )r:   )r   s    r   r  z _sort_messages.<locals>.<lambda>  s    AK r    r	  )r   r   )r   r   s     r   r  r    sQ     H~~H)	J		//000Or    )r   r   r   r   )r0   r   r   r1   )NNFNF)r   r   r   r   r   r   r   r\   r   r   r   r\   r   r   )r(   r   )r   r   r   r   r   rD   r   r   )r   r   r   r   )r   FFFFFFT)r   r   rB   r   r   rD   r   r\   r   r\   r   r\   r   r\   r   r\   r   r\   r   r\   r   rE   )rB   r   r   r\   r   r\   r   r\   r   r\   r   r\   r   r   r   rD   r   r   )r   r  r   r   r   r  )&rN   
__future__r   r`   r"   collections.abcr   typingr   r   
babel.corer   babel.messages.catalogr   r	   
babel.utilr
   r   r   r   	_typeshedr   r%   r/   r>   	Exceptionr@   rQ   rz   r   r#   r   r   r   r   r   r   r  rx   r    r   <module>r%     s  	 	 # " " " " " 				 				 $ $ $ $ $ $ ) ) ) ) ) ) ) )       3 3 3 3 3 3 3 3 ( ( ( ( ( ( ( ( (!!!!!!!!''''''J J J J.       >) ) ) )X    )   )( )( )( )( )( )( )( )(XEB EB EB EB EB EB EB EBT #'!9 9 9 9 9x 2:   0 0 0 0$:K :K :K :K :Kz   ( !"J J J J J` ""59j j j j j jZ     r    