
    ̆h                       % S r SSKJr  SSKrSSKrSSKJrJr  SSKJr  SSK	J
r
  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJrJr  SSKJr  SSKJr  SSKJrJrJ r J!r!  \(       a  SSK"J#r#  \$\%\$S4   -  \&\$   -  r'S\(S'   / SQr)S"S jr*\RV                  " S\RX                  5      r-S#S jr.S$S jr/ " S S5      r0 " S S\15      r2Sr3S%S jr4S&S'S jjr5 " S  S!5      r6g)(z
babel.messages.catalog
~~~~~~~~~~~~~~~~~~~~~~

Data structures for message catalogs.

:copyright: (c) 2013-2025 by the Babel Team.
:license: BSD, see LICENSE for more details.
    )annotationsN)IterableIterator)copy)SequenceMatcher)message_from_string)nlargest)	Formatter)TYPE_CHECKING)__version__)LocaleUnknownLocaleError)format_datetime)
get_plural)LOCALTZFixedOffsetTimezone_cmpdistinct)	TypeAlias.r   
_MessageID)DEFAULT_HEADERPYTHON_FORMATCatalogMessageTranslationErrorc                   US:  d  [        SU< 35      eSUs=::  a  S::  d  O  [        SU< 35      e/ n[        SS9nUR                  U 5        U Hw  nUR                  U5        UR	                  5       U:  d  M*  UR                  5       U:  d  M@  UR                  5       U:  d  MV  UR                  UR                  5       U45        My     [        X$5      nU VVs/ s H  u  pvUPM	     snn$ s  snnf )zA modified version of ``difflib.get_close_matches``.

It just passes ``autojunk=False`` to the ``SequenceMatcher``, to work
around https://github.com/python/cpython/issues/90825.
r   zn must be > 0: g        g      ?zcutoff must be in [0.0, 1.0]: F)autojunk)	
ValueErrorr   set_seq2set_seq1real_quick_ratioquick_ratioratioappendr	   )wordpossibilitiesncutoffresultsxscores           N/opt/services/DDDS/venv/lib/python3.13/site-packages/babel/messages/catalog.pyget_close_matchesr.   *   s     q5?1%011&C9&DEEF'AJJt	

16)==?f$779MM1779a.)  a F$%f(%Af%%%s   C/z
    \%
        (?:\(([\w]*)\))?
        (
            [-#0\ +]?(?:\*|[\d]+)?
            (?:\.(?:\*|[\d]+))?
            [hlL]?
        )
        ([diouxXeEfFgGcrs%])
c                    SU ;  a  g[        5       n SnUR                  U 5       H  nUS   c  M  SnM     U$ ! [         a     gf = f)N{F   T)r
   parser   )stringfmtfield_name_seents       r-   _has_python_brace_formatr7   P   s^    
&
+C  6"At"& #   s   9 9 
AAc                t   [         R                  " SU 5      n[        R                  R                  UR	                  S5      S5      nUR	                  S5      nUb]  US   USS  pTUS S USS  pv[        U S35      n[        U5      n	[        U5      n
U	S	-  nX-  nX-  n[        U5      nUR                  US
9nU$ )Nz+^(?P<datetime>.*?)(?P<tzoffset>[+-]\d{4})?$datetimez%Y-%m-%d %H:%Mtzoffsetr   r1      1<   tzinfo)rematchr9   strptimegroupintr   replace)valuerA   dtr:   plus_minus_sresthours_offset_smins_offset_s
plus_minushours_offsetmins_offsetnet_mins_offsets               r-   _parse_datetime_headerrP   c   s    HHCUKE				#	#EKK
$;=M	NB {{:&H%a[(12,d(,Ra$qr( L>+,
>*-( '+&% '7 ZZxZ(I    c                     \ rS rSrSr        S                   SS jjrSS jrSS jrSS jrSS jr	SS	 jr
SS
 jrSS jrSS jrSS jrSS jrSSS jjr\SS j5       r\SS j5       r\SS j5       r\SS j5       rSrg)r      z0Representation of a single message in a catalog.Nc
                   Xl         U(       d  U R                  (       a  SnX l        [        [	        U5      5      U l        [        U5      U l        U(       a-  U R                  (       a  U R                  R                  S5        OU R                  R                  S5        U(       a-  U R                  (       a  U R                  R                  S5        OU R                  R                  S5        [        [	        U5      5      U l        [        [	        U5      5      U l        [        U[        5      (       a	  U/U l        O[        U5      U l        Xl        Xl        g)a  Create the message object.

:param id: the message ID, or a ``(singular, plural)`` tuple for
           pluralizable messages
:param string: the translated message string, or a
               ``(singular, plural)`` tuple for pluralizable messages
:param locations: a sequence of ``(filename, lineno)`` tuples
:param flags: a set or sequence of flags
:param auto_comments: a sequence of automatic comments for the message
:param user_comments: a sequence of user comments for the message
:param previous_id: the previous message ID, or a ``(singular, plural)``
                    tuple for pluralizable messages
:param lineno: the line number on which the msgid line was found in the
               PO file, if any
:param context: the message context
) rU   zpython-formatzpython-brace-formatN)idpluralizabler3   listr   	locationssetflagspython_formatadddiscardpython_brace_formatauto_commentsuser_comments
isinstancestrprevious_idlinenocontext)
selfrV   r3   rY   r[   r`   ra   rd   re   rf   s
             r-   __init__Message.__init__   s    8 $++Fhy12Z
$$$JJNN?+JJ/$**JJNN01JJ45!(="9:!(="9:k3'' +}D#K0DrQ   c                ~    S[        U 5      R                   SU R                  < S[        U R                  5      < S3$ )N< z	 (flags: z)>)type__name__rV   rX   r[   rg   s    r-   __repr__Message.__repr__   s7    4:&&'q9T$**=M<PPRSSrQ   c                8    S n[        U" U 5      U" U5      5      $ )z0Compare Messages, taking into account plural idsc                    [        U [        5      (       a5  U R                  (       a$  U R                  S   U R                  =(       d    S4$ U R                  U R                  =(       d    S4$ )Nr   rU   )rb   r   rW   rV   rf   )objs    r-   values_to_compare*Message.__cmp__.<locals>.values_to_compare   sK    #w''C,<,<vvay#++"333663;;,",,rQ   )r   )rg   otherru   s      r-   __cmp__Message.__cmp__   s"    	- %d+->u-EFFrQ   c                *    U R                  U5      S:  $ Nr   rx   rg   rw   s     r-   __gt__Message.__gt__       ||E"Q&&rQ   c                *    U R                  U5      S:  $ r{   r|   r}   s     r-   __lt__Message.__lt__   r   rQ   c                *    U R                  U5      S:  $ r{   r|   r}   s     r-   __ge__Message.__ge__       ||E"a''rQ   c                *    U R                  U5      S:*  $ r{   r|   r}   s     r-   __le__Message.__le__   r   rQ   c                *    U R                  U5      S:H  $ r{   r|   r}   s     r-   __eq__Message.__eq__   r   rQ   c                *    U R                  U5      S:g  $ r{   r|   r}   s     r-   __ne__Message.__ne__   r   rQ   c                b    [        U[        5      (       d   eU R                  UR                  :H  $ )zKChecks whether messages are identical, taking into account all
properties.
)rb   r   __dict__r}   s     r-   is_identicalMessage.is_identical   s*     %))))}}..rQ   c                    [        [        [        U R                  U R                  U R
                  U R                  U R                  U R                  U R                  U R                  U R                  4	5      6 $ N)r   mapr   rV   r3   rY   r[   r`   ra   rd   re   rf   ro   s    r-   cloneMessage.clone   s^    D477DKK#'::t/A/A#'#5#5t7G7G#';;#> ? @ 	@rQ   c                    SSK Jn  / nU H  n U" X5        M     U$ ! [         a  nUR                  U5         SnAM3  SnAff = f)a]  Run various validation checks on the message.  Some validations
are only performed if the catalog is provided.  This method returns
a sequence of `TranslationError` objects.

:rtype: ``iterator``
:param catalog: A catalog instance that is passed to the checkers
:see: `Catalog.check` for a way to perform checks for all messages
      in a catalog.
r   )checkersN)babel.messages.checkersr   r   r$   )rg   catalogr   errorscheckeres         r-   checkMessage.check   sK     	5)+G!&  
  $ !a  !s   
A>Ac                     SU R                   ;   $ )zWhether the translation is fuzzy.

>>> Message('foo').fuzzy
False
>>> msg = Message('foo', 'foo', flags=['fuzzy'])
>>> msg.fuzzy
True
>>> msg
<Message 'foo' (flags: ['fuzzy'])>

:type:  `bool`fuzzyr[   ro   s    r-   r   Message.fuzzy   s     $**$$rQ   c                B    [        U R                  [        [        45      $ )zWhether the message is plurizable.

>>> Message('foo').pluralizable
False
>>> Message(('foo', 'bar')).pluralizable
True

:type:  `bool`)rb   rV   rX   tuplero   s    r-   rW   Message.pluralizable  s     $''D%=11rQ   c                z    U R                   n[        U[        [        45      (       d  U/n[	        S U 5       5      $ )zWhether the message contains Python-style parameters.

>>> Message('foo %(name)s bar').python_format
True
>>> Message(('foo %(name)s', 'foo %(name)s')).python_format
True

:type:  `bool`c              3  L   #    U  H  n[         R                  U5      v   M     g 7fr   )r   search.0rV   s     r-   	<genexpr>(Message.python_format.<locals>.<genexpr>  s     :c=''++cs   "$rV   rb   rX   r   anyrg   idss     r-   r\   Message.python_format  s6     gg#e}--%C:c:::rQ   c                z    U R                   n[        U[        [        45      (       d  U/n[	        S U 5       5      $ )zWhether the message contains Python f-string parameters.

>>> Message('Hello, {name}!').python_brace_format
True
>>> Message(('One apple', '{count} apples')).python_brace_format
True

:type:  `bool`c              3  8   #    U  H  n[        U5      v   M     g 7fr   )r7   r   s     r-   r   .Message.python_brace_format.<locals>.<genexpr>+  s     >#B+B//#s   r   r   s     r-   r_   Message.python_brace_format  s6     gg#e}--%C>#>>>rQ   )	r`   rf   r[   rV   re   rY   rd   r3   ra   )rU    r   r   r   r   NN)rV   r   r3   _MessageID | NonerY   Iterable[tuple[str, int]]r[   Iterable[str]r`   r   ra   r   rd   r   re   
int | Nonerf   
str | NonereturnNoner   rc   )rw   objectr   rD   )rw   r   r   bool)rw   r   r   r   )r   r   r   )r   zCatalog | Noner   zlist[TranslationError])r   r   )rn   
__module____qualname____firstlineno____doc__rh   rp   rx   r~   r   r   r   r   r   r   r   r   propertyr   rW   r\   r_   __static_attributes__r   rQ   r-   r   r      s   :
 %'/1!')')"$!"11 "1 -	1
 1 %1 %1  1 1 1 
1fTG''((((/@& % % 	2 	2 ; ; ? ?rQ   r   c                      \ rS rSrSrSrg)r   i.  z[Exception thrown by translation checkers when invalid message
translations are encountered.r   N)rn   r   r   r   r   r   r   rQ   r-   r   r   .  s    %rQ   r   z# Translations template for PROJECT.
# Copyright (C) YEAR ORGANIZATION
# This file is distributed under the same license as the PROJECT project.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#c                V    SSK Jn  U" 5       nXS'   [        UR                  5       5      $ )Nr   )r   content-type)email.messager   dict
get_params)rF   r   ms      r-   parse_separated_headerr   ;  s%    %	AnrQ   c                    [        U [        5      (       a  U $ [        U [        5      (       a  U R                  X5      $ [        U 5      $ r   )rb   rc   bytesdecode)r*   encodingr   s      r-   _force_textr   C  s9    !S!Uxx))q6MrQ   c                  8   \ rS rSrSrSS\SSSSSSSSSS4                           S#S jjrS$S jrS%S jrS&S jr	\
" \\5      r\
" \	5      rS'S	 jrS(S
 jr\
" \\SS9rS)S jrS*S jr\
" \\SS9r\
S+S j5       r\
S'S j5       r\
S'S j5       rS,S jrS+S jrS-S jrS'S jrS.S jrS/S jrS0S jr        S1                   S2S jjrS3S jrS4S5S jjrS4S6S jjr     S7           S8S jjr!S9S jr"S4S:S  jjr#S;S! jr$S"r%g)<r   iK  z$Representation of a message catalog.NTc                   X l         Xl        X0l        0 U l        U=(       d    SU l        U=(       d    SU l        U=(       d    SU l        U=(       d    SU l        U
=(       d    SU l         U=(       d    SU l	         U=(       d    SU l
        Uc$  [        R                  R                  [        5      nOC[        U[        R                  5      (       a$  UR                  (       d  UR!                  [        S	9nXl        U	c  S
n	OC[        U	[        R                  5      (       a$  U	R                  (       d  U	R!                  [        S	9n	Xl        Xl        0 U l        SU l        SU l        g)a  Initialize the catalog object.

: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 header_comment: the header comment as string, or `None` for the
                       default header
:param project: the project's name
:param version: the project's version
:param copyright_holder: the copyright holder of the catalog
:param msgid_bugs_address: the email address or URL to submit bug
                           reports to
:param creation_date: the date the catalog was created
:param revision_date: the date the catalog was revised
:param last_translator: the name and email of the last translator
:param language_team: the name and email of the language team
:param charset: the encoding to use in the output (defaults to utf-8)
:param fuzzy: the fuzzy bit on the catalog header
PROJECTVERSIONORGANIZATIONzEMAIL@ADDRESSzFULL NAME <EMAIL@ADDRESS>zLANGUAGE <LL@li.org>utf-8Nr>   zYEAR-MO-DA HO:MI+ZONE)domainlocale_header_comment	_messagesprojectversioncopyright_holdermsgid_bugs_addresslast_translatorlanguage_teamcharsetr9   nowr   rb   r?   rE   creation_daterevision_dater   obsolete_num_plurals_plural_expr)rg   r   r   header_commentr   r   r   r   r   r   r   r   r   r   s                 r-   rh   Catalog.__init__N  s*   H -?A+)+) 0 BN"4"G.M2M<*D.D:)' $--11':Mx'8'899-BVBV)111AM* 3Mx'8'899-BVBV)111AM*
 ?A  rQ   c                N   Uc  S U l         S U l        g [        U[        5      (       a  [	        U5      U l         Xl        g [        U[        5      (       a-  [	        U5      U l          [        R
                  " U5      U l        g [        SU< 35      e! [         a
    S U l         g f = f)NzD`locale` must be a Locale, a locale identifier string, or None; got )_locale_identifier_localerb   r   rc   r2   r   	TypeErrorrg   r   s     r-   _set_localeCatalog._set_locale  s    >&*D#DLff%%&)&kD#!Lfc""&)&kD#$%||F3 ^_e^hijj	 & $#$s   %B B$#B$c                    U R                   $ r   )r   ro   s    r-   _get_localeCatalog._get_locale  s    ||rQ   c                    U R                   $ r   )r   ro   s    r-   _get_locale_identifierCatalog._get_locale_identifier  s    &&&rQ   c                L   U R                   n[        R                  R                  [        5      R	                  S5      n[        U R                  S5      (       a  U R                  R	                  S5      nUR                  SU R                  5      R                  SU R                  5      R                  SU5      R                  SU R                  5      nU R                  (       a  U R                  R                  OU R                  nU(       a  UR                  SU S35      nU$ )	Nz%Ystrftimer   r   YEARr   zTranslations templatez translations)r   r9   r   r   r   hasattrr   rE   r   r   r   r   english_namelocale_identifier)rg   commentyearlocale_names       r-   _get_header_commentCatalog._get_header_comment  s    &&  $$W-66t<4%%z22%%..t4D//)T\\:!')T\\:!'&$/!'.$2G2GH 	 48;;t{{//DDZDZoo&=+m?\]GrQ   c                    Xl         g r   )r   )rg   r3   s     r-   _set_header_commentCatalog._set_header_comment  s    %rQ   a      The header comment for the catalog.

    >>> catalog = Catalog(project='Foobar', version='1.0',
    ...                   copyright_holder='Foo Company')
    >>> print(catalog.header_comment) #doctest: +ELLIPSIS
    # Translations template for Foobar.
    # Copyright (C) ... Foo Company
    # This file is distributed under the same license as the Foobar project.
    # FIRST AUTHOR <EMAIL@ADDRESS>, ....
    #

    The header can also be set from a string. Any known upper-case variables
    will be replaced when the header is retrieved again:

    >>> catalog = Catalog(project='Foobar', version='1.0',
    ...                   copyright_holder='Foo Company')
    >>> catalog.header_comment = '''\
    ... # The POT for my really cool PROJECT project.
    ... # Copyright (C) 1990-2003 ORGANIZATION
    ... # This file is distributed under the same license as the PROJECT
    ... # project.
    ... #'''
    >>> print(catalog.header_comment)
    # The POT for my really cool Foobar project.
    # Copyright (C) 1990-2003 Foo Company
    # This file is distributed under the same license as the Foobar
    # project.
    #

    :type: `unicode`
    )docc           	     .   [        U R                  [        R                  [        R                  [        [
        45      (       a  [        U R                  SSS9nOU R                  nU R                  nU R                  (       a+  SU;   a%  UR                  S[        U R                  5      5      nSU R                   SU R                   34SU R                  4S[        U R                  SSS94S	U4S
U R                  4/nU R                  (       a&  UR!                  S[        U R                  5      45        UR!                  SU45        U R"                  b  UR!                  SU R$                  45        USSSU R&                   34SSS[(         S34/-  nU$ )Nzyyyy-MM-dd HH:mmZen)r   LANGUAGEzProject-Id-Versionrl   zReport-Msgid-Bugs-TozPOT-Creation-DatezPO-Revision-DatezLast-TranslatorLanguagezLanguage-TeamzPlural-Forms)zMIME-Versionz1.0zContent-Typeztext/plain; charset=)zContent-Transfer-Encoding8bitzGenerated-ByzBabel 
)rb   r   r9   timerD   floatr   r   r  rE   rc   r   r   r   r   r   r$   r   plural_formsr   r   )rg   r   r   headerss       r-   _get_mime_headersCatalog._get_mime_headers  s}   d((8+<+<hmmSRW*XYY+D,>,>@S\`aM ..M**!!jM&A)11*c$BXBX>YZM "dll^1T\\N#CD#T%<%<= /$2D2DFYbf"gh/ 4 45*
 !!NNJD,B,B(CDE78;;"NNND,=,=>?#3DLL>BC1vgYb12	
 	
 rQ   c                8   U GH  u  p#[        UR                  5       U R                  S9n[        X0R                  S9nUS:X  a6  UR                  S5      nSR	                  US S 5      U l        US   U l        Mw  US:X  a  X0l        M  US:X  a  X0l        M  US:X  a.  UR                  SS	5      nU R                  U=(       d    S 5        M  US
:X  a  X0l        M  US:X  a/  [        U5      nSU;   a  US   R                  5       U l        GM  GM
  US:X  aH  [        SU 35      n[        UR                  SS5      5      U l        UR                  SS5      U l        GMX  US:X  a  [#        U5      U l        GMq  US:X  d  GMz  SU;  d  GM  [#        U5      U l        GM     g )N)r   zproject-id-versionrl   zreport-msgid-bugs-tozlast-translatorlanguage-_zlanguage-teamr   r   zplural-formsz ;npluralsr;   plural(n != 1)zpot-creation-datezpo-revision-dater   )r   lowerr   splitjoinr   r   r   r   rE   r   r   r   rD   getr   r   rP   r   r   )rg   r  namerF   partsparamss         r-   _set_mime_headersCatalog._set_mime_headers  sn   "KDtzz|dllCD=E++C("xxcr
3$Ry//*/'**',$#c3/
   $/(%*"'/6&#))#4#:#:#<DL ''/"UG=$'

:q(A$B!$*JJx$D!,,%;E%B"++&)?)FD&C #rQ   a      The MIME headers of the catalog, used for the special ``msgid ""`` entry.

    The behavior of this property changes slightly depending on whether a locale
    is set or not, the latter indicating that the catalog is actually a template
    for actual translations.

    Here's an example of the output for such a catalog template:

    >>> from babel.dates import UTC
    >>> from datetime import datetime
    >>> created = datetime(1990, 4, 1, 15, 30, tzinfo=UTC)
    >>> catalog = Catalog(project='Foobar', version='1.0',
    ...                   creation_date=created)
    >>> for name, value in catalog.mime_headers:
    ...     print('%s: %s' % (name, value))
    Project-Id-Version: Foobar 1.0
    Report-Msgid-Bugs-To: EMAIL@ADDRESS
    POT-Creation-Date: 1990-04-01 15:30+0000
    PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
    Last-Translator: FULL NAME <EMAIL@ADDRESS>
    Language-Team: LANGUAGE <LL@li.org>
    MIME-Version: 1.0
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: 8bit
    Generated-By: Babel ...

    And here's an example of the output when the locale is set:

    >>> revised = datetime(1990, 8, 3, 12, 0, tzinfo=UTC)
    >>> catalog = Catalog(locale='de_DE', project='Foobar', version='1.0',
    ...                   creation_date=created, revision_date=revised,
    ...                   last_translator='John Doe <jd@example.com>',
    ...                   language_team='de_DE <de@example.com>')
    >>> for name, value in catalog.mime_headers:
    ...     print('%s: %s' % (name, value))
    Project-Id-Version: Foobar 1.0
    Report-Msgid-Bugs-To: EMAIL@ADDRESS
    POT-Creation-Date: 1990-04-01 15:30+0000
    PO-Revision-Date: 1990-08-03 12:00+0000
    Last-Translator: John Doe <jd@example.com>
    Language: de_DE
    Language-Team: de_DE <de@example.com>
    Plural-Forms: nplurals=2; plural=(n != 1);
    MIME-Version: 1.0
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: 8bit
    Generated-By: Babel ...

    :type: `list`
    c                    U R                   c1  SnU R                  (       a  [        U R                  5      S   nXl         U R                   $ )zThe number of plurals used by the catalog or locale.

>>> Catalog(locale='en').num_plurals
2
>>> Catalog(locale='ga').num_plurals
5

:type: `int`r;   r   )r   r   r   )rg   nums     r-   num_pluralsCatalog.num_pluralsZ  sA     $C{{ -a0 #   rQ   c                    U R                   c1  SnU R                  (       a  [        U R                  5      S   nXl         U R                   $ )a  The plural expression used by the catalog or locale.

>>> Catalog(locale='en').plural_expr
'(n != 1)'
>>> Catalog(locale='ga').plural_expr
'(n==1 ? 0 : n==2 ? 1 : n>=3 && n<=6 ? 2 : n>=7 && n<=10 ? 3 : 4)'
>>> Catalog(locale='ding').plural_expr  # unknown locale
'(n != 1)'

:type: `str`r   r1   )r   r   r   )rg   exprs     r-   plural_exprCatalog.plural_exprk  sA     $D{{!$++.q1 $   rQ   c                <    SU R                    SU R                   S3$ )zReturn the plural forms declaration for the locale.

>>> Catalog(locale='en').plural_forms
'nplurals=2; plural=(n != 1);'
>>> Catalog(locale='pt_BR').plural_forms
'nplurals=2; plural=(n > 1);'

:type: `str`z	nplurals=z	; plural=;)r,  r0  ro   s    r-   r  Catalog.plural_forms~  s'     4++,Id6F6F5GqIIrQ   c                >    U R                  U5      U R                  ;   $ )z?Return whether the catalog has a message with the specified ID._key_forr   rg   rV   s     r-   __contains__Catalog.__contains__  s    }}R DNN22rQ   c                ,    [        U R                  5      $ )z]The number of messages in the catalog.

This does not include the special ``msgid ""`` entry.)lenr   ro   s    r-   __len__Catalog.__len__  s     4>>""rQ   c              #  (  #    / nU R                    H  u  p#UR                  U SU 35        M     [        5       nU R                  (       a  US1-  n[	        SSR                  U5      US9v   U R                   H  nU R                  U   v   M     g7f)zIterates through all the entries in the catalog, in the order they
were added, yielding a `Message` object for every entry.

:rtype: ``iterator``z: r   rU   r  r   N)mime_headersr$   rZ   r   r   r#  r   )rg   bufr%  rF   r[   keys         r-   __iter__Catalog.__iter__  s     
 ,,KDJJ$r%)* -::gYEb$))C.66>>C..%% "s   BBc                    SnU R                   (       a  SU R                    3nS[        U 5      R                   SU R                  < U S3$ )NrU   rl   rk   >)r   rm   rn   r   r   s     r-   rp   Catalog.__repr__  sF    ;;&F4:&&'qxqAArQ   c                &    U R                  U5        g)z)Delete the message with the specified ID.N)deleter8  s     r-   __delitem__Catalog.__delitem__  s    BrQ   c                $    U R                  U5      $ )zEReturn the message with the specified ID.

:param id: the message ID
)r$  r8  s     r-   __getitem__Catalog.__getitem__  s    
 xx|rQ   c                   [        U[        5      (       d   S5       eU R                  XR                  5      nU R                  R                  U5      nU(       a  UR                  (       a3  UR                  (       d"  UR                  Ul        UR                  Ul        [        [        UR                  UR                  -   5      5      Ul        [        [        UR                  UR                  -   5      5      Ul        [        [        UR                  UR                  -   5      5      Ul        U=R                  UR                  -  sl        gUS:X  a|  [        UR                  5      R!                  5       U l        SR%                  UR                   Vs/ s H  nSU 3R'                  5       PM     sn5      U l        UR*                  U l        g[        U[        [,        45      (       aB  [        UR                  [        [,        45      (       d   S[/        UR                  5       35       eX R                  U'   gs  snf )ai  Add or update the message with the specified ID.

>>> catalog = Catalog()
>>> catalog[u'foo'] = Message(u'foo')
>>> catalog[u'foo']
<Message u'foo' (flags: [])>

If a message with that ID is already in the catalog, it is updated
to include the locations and flags of the new message.

>>> catalog = Catalog()
>>> catalog[u'foo'] = Message(u'foo', locations=[('main.py', 1)])
>>> catalog[u'foo'].locations
[('main.py', 1)]
>>> catalog[u'foo'] = Message(u'foo', locations=[('utils.py', 5)])
>>> catalog[u'foo'].locations
[('main.py', 1), ('utils.py', 5)]

:param id: the message ID
:param message: the `Message` object
zexpected a Message objectrU   r  z# zExpected sequence but got N)rb   r   r7  rf   r   r$  rW   rV   r3   rX   r   rY   r`   ra   r[   r   itemsr@  r#  rstripr   r   r   rm   )rg   rV   messagerB  currentcs         r-   __setitem__Catalog.__setitem__  s   , '7++H-HH+mmB0..$$S)##G,@,@$ZZ
!( $Xg.?.?.5.?.?/@ &A !BG$('2G2G292G2G3H *I %JG!$('2G2G292G2G3H *I %JG!MMW]]*M2X 3GNN C I I KD"&))H]H],^H]1r!X__->H],^"_D DJ"tUm,,!'..4-@@ H0gnn1E0FGH@")NN3 -_s   H<c
                <    [        X[        U5      XEXgUU	S9	n
XU'   U
$ )a  Add or update the message with the specified ID.

>>> catalog = Catalog()
>>> catalog.add(u'foo')
<Message ...>
>>> catalog[u'foo']
<Message u'foo' (flags: [])>

This method simply constructs a `Message` object with the given
arguments and invokes `__setitem__` with that object.

:param id: the message ID, or a ``(singular, plural)`` tuple for
           pluralizable messages
:param string: the translated message string, or a
               ``(singular, plural)`` tuple for pluralizable messages
:param locations: a sequence of ``(filename, lineno)`` tuples
:param flags: a set or sequence of flags
:param auto_comments: a sequence of automatic comments
:param user_comments: a sequence of user comments
:param previous_id: the previous message ID, or a ``(singular, plural)``
                    tuple for pluralizable messages
:param lineno: the line number on which the msgid line was found in the
               PO file, if any
:param context: the message context
)re   rf   )r   rX   )rg   rV   r3   rY   r[   r`   ra   rd   re   rf   rR  s              r-   r]   Catalog.add  s/    J "d9ou'V")+ RrQ   c              #     #    U R                   R                  5        H   nUR                  U S9nU(       d  M  X4v   M"     g7f)a4  Run various validation checks on the translations in the catalog.

For every message which fails validation, this method yield a
``(message, errors)`` tuple, where ``message`` is the `Message` object
and ``errors`` is a sequence of `TranslationError` objects.

:rtype: ``generator`` of ``(message, errors)``
)r   N)r   valuesr   )rg   rR  r   s      r-   r   Catalog.check  s;      ~~,,.G]]4]0Fvo% /s
   2A
Ac                V    U R                   R                  U R                  X5      5      $ )zReturn the message with the specified ID and context.

:param id: the message ID
:param context: the message context, or ``None`` for no context
)r   r$  r7  )rg   rV   rf   s      r-   r$  Catalog.get  s"     ~~!!$--"<==rQ   c                `    U R                  X5      nX0R                  ;   a  U R                  U	 gg)zDelete the message with the specified ID and context.

:param id: the message ID
:param context: the message context, or ``None`` for no context
Nr6  rg   rV   rf   rB  s       r-   rI  Catalog.delete%  s-     mmB(.. s# !rQ   c                n  ^ ^^^^ T R                   mTR                  5       m0 T l         0 nU(       d]  T HW  nU(       d  M  TU   R                  (       d  M"  T R                  U5      nTU   R                  n	X4UT R                  U5      '   MY     [        5       mSUUUUU 4S jjn
U H  nUR                  (       d  M  T R                  UR                  UR                  5      nUT;   a  U
" XU5        MM  U(       dM  [        T R                  U5      UR                  5       S5      nU(       a  US   nXm   u  pUb  X4nU
" XU5        M  UT UR                  '   M     T H$  nU(       d  UT;  d  M  TU   T R                  U'   M&     U(       a  UR                  T l        U(       a  UR                  T l        gg)aB  Update the catalog based on the given template catalog.

>>> from babel.messages import Catalog
>>> template = Catalog()
>>> template.add('green', locations=[('main.py', 99)])
<Message ...>
>>> template.add('blue', locations=[('main.py', 100)])
<Message ...>
>>> template.add(('salad', 'salads'), locations=[('util.py', 42)])
<Message ...>
>>> catalog = Catalog(locale='de_DE')
>>> catalog.add('blue', u'blau', locations=[('main.py', 98)])
<Message ...>
>>> catalog.add('head', u'Kopf', locations=[('util.py', 33)])
<Message ...>
>>> catalog.add(('salad', 'salads'), (u'Salat', u'Salate'),
...             locations=[('util.py', 38)])
<Message ...>

>>> catalog.update(template)
>>> len(catalog)
3

>>> msg1 = catalog['green']
>>> msg1.string
>>> msg1.locations
[('main.py', 99)]

>>> msg2 = catalog['blue']
>>> msg2.string
u'blau'
>>> msg2.locations
[('main.py', 100)]

>>> msg3 = catalog['salad']
>>> msg3.string
(u'Salat', u'Salate')
>>> msg3.locations
[('util.py', 42)]

Messages that are in the catalog but not in the template are removed
from the main collection, but can still be accessed via the `obsolete`
member:

>>> 'head' in catalog
False
>>> list(catalog.obsolete.values())
[<Message 'head' (flags: [])>]

:param template: the reference catalog, usually read from a POT file
:param no_fuzzy_matching: whether to use fuzzy matching of message IDs
:param update_header_comment: whether to copy the header comment from the template
:param keep_user_comments: whether to keep user comments from the old catalog
:param update_creation_date: whether to copy the creation date from the template
c                  > U R                  5       n SnX:w  av  SnTR                  U5        TR                  U5      nUc   e[        UR                  [
        5      (       a  UR                  /U l        O2[        UR                  5      U l        OTR                  US 5      nUc   eUR                  U l	        T(       a#  [        [        UR                  5      5      U l        [        U R                  [        [        45      (       a  [        U R                  [        [        45      (       d;  Sn[        U R                  /S/[        U R                  5      S-
  -  -   5      U l	        O[        U R                  5      T	R                  :w  a2  Sn[        U R                  S [        UR                  5       5      U l	        O;[        U R                  [        [        45      (       a  SnU R                  S   U l	        U =R                  UR                  -  sl        U(       a  U =R                  S1-  sl        U T	U R                  '   g )NFTrU   r1   r   r   )r   r]   r$  rb   rV   rc   rd   rX   popr3   r   ra   r   r<  r,  r[   )
rR  oldkeynewkeyr   oldmsgfuzzy_matcheskeep_user_commentsmessages	remainingrg   s
        r-   _mergeCatalog.update.<locals>._merge|  s   mmoGE!!&)!f-)))fii--+199+G'*.vyy/G'"vt4)))#]]GN!(,Xf6J6J-K(L%'**tUm44!'..4-@@ E%* (RDC

Oa4G,HI&GN (D,<,<< E%*7>>:M3v}};M+N%OGNGNNT5M::!(!2MMV\\)M'*&DrQ   r1   r   N)rR  r   rd  tuple[str, str] | strre  rm  r   r   )r   r   r3   r7  rf   _to_fuzzy_match_keyrZ   rV   r.   keysr   r   r   )rg   templateno_fuzzy_matchingupdate_header_commentrh  update_creation_datefuzzy_candidatesmsgidrB  ctxtrk  rR  matchesmodified_keyre  newctxtrg  ri  rj  s   `   `           @@@r-   updateCatalog.update/  s   ~ >>MMO	  !5Xe_333--.C#E?22DGJk$T%=%=c%BC	 "
 #	' #	'J  GzzzmmGJJ@(?7-,"3 44S9,113#
 #+21:L.>.LOF&2)/"7C8$'.D$+  . E E$>'0'7e$  ! #+"9"9D  !)!7!7D  rQ   c                x    [        U[        5      (       a  US   nOUnUR                  5       R                  5       $ )z?Converts a message key to a string suitable for fuzzy matching.r   )rb   r   r!  strip)rg   rB  matchkeys      r-   rn  Catalog._to_fuzzy_match_key  s3    c5!!1vHH~~%%''rQ   c                V    Un[        U[        [        45      (       a  US   nUb  X24nU$ )zThe key for a message is just the singular ID even for pluralizable
messages, but is a ``(msgid, msgctxt)`` tuple for context-specific
messages.
r   )rb   rX   r   r_  s       r-   r7  Catalog._key_for  s5    
 cD%=))Q%C.C
rQ   c                ~   [        U[        5      (       d   eU R                  R                  5       UR                  R                  5       -   HC  nU R	                  U5      nUR	                  U5      nUb  Ub  UR                  U5      (       a  MC    g   [        U R                  5      [        UR                  5      :H  $ )zLChecks if catalogs are identical, taking into account messages and
headers.
F)rb   r   r   ro  r$  r   r   r@  )rg   rw   rB  	message_1	message_2s        r-   r   Catalog.is_identical  s     %))))>>&&(5??+?+?+AACI		#I!$ --i88 B D%%&$u/A/A*BBBrQ   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r@  r   r   r   r   r   )r   Locale | str | Noner   r   r   r   r   r   r   r   r   r   r   r   r   zdatetime.datetime | str | Noner   z6datetime.datetime | datetime.time | float | str | Noner   r   r   r   r   r   r   r   r   r   )r   r  r   r   )r   zLocale | None)r   r   r   )r3   r   r   r   )r   zlist[tuple[str, str]])r  zIterable[tuple[str, str]]r   r   )r   rD   )rV   r   r   r   )r   zIterator[Message])rV   r   r   r   )rV   r   r   r   )rV   r   rR  r   r   r   )Nr   r   r   r   r   NN)rV   r   r3   r   rY   r   r[   r   r`   r   ra   r   rd   r   re   r   rf   r   r   r   )r   z0Iterable[tuple[Message, list[TranslationError]]]r   )rV   r   rf   r   r   zMessage | None)rV   r   rf   r   r   r   )FFTT)rp  r   rq  r   rr  r   rh  r   rs  r   r   r   )rB  rm  r   rc   )rV   r   rf   r   r   rm  )rw   r   r   r   )&rn   r   r   r   r   r   rh   r   r   r   r   r   r  r  r
  r   r  r(  r@  r,  r0  r  r9  r=  rC  rp   rJ  rM  rU  r]   r   r$  rI  rz  rn  r7  r   r   r   rQ   r-   r   r   K  s   . '+!%3""'+)-8<PT&*$("D!#D! D! #	D!
 D! D! %D! 'D! 6D! ND! $D! "D! D! D! 
D!Lk*' k;/F !78& 13F M 	NB<"GH -/@ 2G 2	Lh ! !  ! !$ 	J 	J3#&B.*f %)/1!')')"$!")) ") -	)
 ) %) %)  ) ) ) 
)V&>$ #(&+#'%)U8U8  U8  $	U8
 !U8 #U8 
U8n(
CrQ   r   )   g333333?)r3   rc   r   r   )rF   rc   r   zdatetime.datetime)rF   rc   r   zdict[str, str])r   strict)r*   zstr | bytesr   rc   r   rc   r   rc   )7r   
__future__r   r9   r@   collections.abcr   r   r   difflibr   emailr   heapqr	   r3   r
   typingr   babelr   r   
babel.corer   r   babel.datesr   babel.messages.pluralsr   
babel.utilr   r   r   r   typing_extensionsr   rc   r   rX   r   __annotations____all__r.   compileVERBOSEr   r7   rP   r   	Exceptionr   r   r   r   r   r   rQ   r-   <module>r     s    #  	 .  # %     ( 1 ' - C C+%S/1DI=J	=&4 

 	 ZZ	&<j? j?Z%y %
 ]
C ]
CrQ   