Ë
    5]jA  ã                  óˆ   — U d Z ddlmZ ddlmZ ddlmZmZmZm	Z	 h d£ddhh d£gZ
dd	„Zdd
„Zdd„Zdd„Z e«       Zded<   y)zÞ
babel.messages.checkers
~~~~~~~~~~~~~~~~~~~~~~~

Various routines that help with validation of translations.

:since: version 0.9

:copyright: (c) 2013-2026 by the Babel Team.
:license: BSD, see LICENSE for more details.
é    )Úannotations)ÚCallable)ÚPYTHON_FORMATÚCatalogÚMessageÚTranslationError>   ÚdÚiÚuÚxÚX>   ÚFÚGÚfÚgc                ó  — |j                   s&t        |j                  t        «      st	        d«      ‚y| €y|j                  }t        |t
        t        f«      s|f}t        |«      | j                  k7  rt	        d| j                  › d�«      ‚y)z0Verify the number of plurals in the translation.z/Found plural forms for non-pluralizable messageNz'Wrong number of plural forms (expected ú))	ÚpluralizableÚ
isinstanceÚstringÚstrr   ÚlistÚtupleÚlenÚnum_plurals)ÚcatalogÚmessageÚmsgstrss      úN/var/www/zogu/zoguvenv/lib/python3.12/site-packages/babel/messages/checkers.pyr   r      s‡   € à×ÒÜ˜'Ÿ.™.¬#Ô.Ü"Ð#TÓUÐUØð 
ˆØà�n‰n€GÜ�g¤¤e˜}Ô-Ø�*ˆÜ
ˆ7ƒ|�w×*Ñ*Ò*ÜØ5°g×6IÑ6IÐ5JÈ!ÐLó
ð 	
ð +ó    c                ó6  — d|j                   vry|j                  }t        |t        t        f«      s|f}|j
                  }t        |t        t        f«      s|f}|d   rt        |d   |d   «       |j                  r|dd D ]  }|sŒt        |d   |«       Œ yy)z9Verify the format string placeholders in the translation.zpython-formatNr   é   )ÚflagsÚidr   r   r   r   Ú_validate_formatr   )r   r   Úmsgidsr   Úmsgstrs        r   Úpython_formatr(   /   sš   € à˜gŸm™mÑ+ØØ�Z‰Z€FÜ�fœt¤U˜mÔ,Ø�ˆØ�n‰n€GÜ�g¤¤e˜}Ô-Ø�*ˆàˆq‚zÜ˜ ™ G¨A¡JÔ/Ø×ÒØ˜a˜b�kò 	4ˆFÚÜ  ¨¡¨FÕ3ñ	4ð r    c           
     ó  — dd„}dd„}dd„} || «      } ||«      }|sy ||«      } ||«      }|r|s|st        d«      ‚||k7  rt        d«      ‚|rkt        |«      t        |«      k7  rt        d«      ‚t        t        ||«      «      D ]0  \  }	\  \  }
}\  }
} |||«      rŒt        d|	d	z   d
›d|›d|›d�«      ‚ yt	        |«      }|D ];  \  }}||vrt        d|›�«      ‚ ||||   «      rŒ%t        d|›d|›d||   ›d�«      ‚ y)a(  Test format string `alternative` against `format`.  `format` can be the
    msgid of a message and `alternative` one of the `msgstr`\s.  The two
    arguments are not interchangeable as `alternative` may contain less
    placeholders if `format` uses named placeholders.

    If the string formatting of `alternative` is compatible to `format` the
    function returns `None`, otherwise a `TranslationError` is raised.

    Examples for compatible format strings:

    >>> _validate_format('Hello %s!', 'Hallo %s!')
    >>> _validate_format('Hello %i!', 'Hallo %d!')

    Example for an incompatible format strings:

    >>> _validate_format('Hello %(name)s!', 'Hallo %s!')
    Traceback (most recent call last):
      ...
    TranslationError: the format strings are of different kinds

    This function is used by the `python_format` checker.

    :param format: The original format string
    :param alternative: The alternative format string that should be checked
                        against format
    :raises TranslationError: on formatting errors
    c                ó®   — g }t        j                  | «      D ]:  }|j                  «       \  }}}|dk(  r|€Œ|j                  |t	        |«      f«       Œ< |S )Nú%)r   ÚfinditerÚgroupsÚappendr   )r   ÚresultÚmatchÚnameÚformatÚtypechars         r   Ú_parsez _validate_format.<locals>._parse_   s]   € Ø(*ˆÜ"×+Ñ+¨FÓ3ò 	1ˆEØ%*§\¡\£^Ñ"ˆD�&˜(Ø˜3Š 4 <ØØ�M‰M˜4¤ X£Ð/Õ0ð		1ð
 ˆr    c                ó<   — | |k(  ryt         D ]  }| |v sŒ||v sŒ y y)NTF)Ú_string_format_compatibilities)ÚaÚbÚsets      r   Ú_compatiblez%_validate_format.<locals>._compatibleh   s0   € Ø�Š6ØÜ1ò 	ˆCØ�CŠx˜A šHÙð	ð r    c                ób   — d }| D ]  \  }}|€|d u }Œ|d u |k7  sŒt        d«      ‚ t        |«      S )Nz5format string mixes positional and named placeholders)r   Úbool)ÚresultsÚ
positionalr1   Ú_chars       r   Ú_check_positionalz+_validate_format.<locals>._check_positionalp   sR   € Øˆ
Ø"ò 	‰KˆD�%ØÐ!Ø! T˜\‘
à˜D�L ZÓ/Ü*ØOóð ð	ô �JÓÐr    Nzplaceholders are incompatiblez)the format strings are of different kindsz-positional format placeholders are unbalancedz$incompatible format for placeholder r"   r	   z: z and z are not compatiblezunknown named placeholder )r   r   Úreturnúlist[tuple[str, str]])r7   r   r8   r   rA   r<   )r=   rB   rA   r<   )r   r   Ú	enumerateÚzipÚdict)r2   Úalternativer4   r:   r@   r7   r8   Úa_positionalÚb_positionalÚidxÚ_ÚfirstÚsecondÚtype_mapr1   r3   s                   r   r%   r%   B   sf  € ó:óó
 ñ 	ˆv‹€AÙˆ{Ó€AáØñ % QÓ'€LÙ$ QÓ'€LÙ™L±ÜÐ>Ó?Ð?Ø	˜Ò	%ÜÐJÓKÐKñ Üˆq‹6”S˜“VÒÜ"Ð#RÓSÐSÜ.7¼¸A¸q»	Ó.Bò 	Ñ*ˆCÑ*‘*�1�e™k˜q &Ù˜u fÕ-Ü&Ø:¸3À¹7À1¸+ÀRØ�i˜u V JÐ.AðCóð ñ	ô ˜“7ˆØò 	‰NˆD�(Ø˜8Ñ#Ü&Ð)CÀDÀ8Ð'LÓMÐMÙ  ¨8°D©>Õ:Ü&Ø:¸4¸(À"Ø�l %¨°©Ð'9Ð9LðNóð ñ		r    ú1list[Callable[[Catalog | None, Message], object]]c                 ó†   — ddl m}  g }|j                  d„  | d«      D «       «       t        |«      dk(  rt        t
        gS |S )Nr   )Úfind_entrypointsc              3  ó0   K  — | ]  \  }} |«       –— Œ y ­w)N© )Ú.0r1   Úloads      r   ú	<genexpr>z!_find_checkers.<locals>.<genexpr>¨   s   è ø€ ÒR™|  d‘D—FÑRùs   ‚zbabel.checkers)Úbabel.messages._compatrP   Úextendr   r   r(   )rP   Úcheckerss     r   Ú_find_checkersrY   ¤   sA   € Ý7àBD€HØ‡O�OÑRÑ/?Ð@PÓ/QÔRÔRÜ
ˆ8ƒ}˜Òô œ]Ð+Ð+Ø€Or    rX   N)r   zCatalog | Noner   r   rA   ÚNone)r2   r   rF   r   rA   rZ   )rA   rN   )Ú__doc__Ú
__future__r   Úcollections.abcr   Úbabel.messages.catalogr   r   r   r   r6   r   r(   r%   rY   rX   Ú__annotations__rR   r    r   ú<module>r`      sV   ðò
õ #å $ç TÓ Tò Øˆ#€JÚð"Ð ó
ó(4ó&_óD	ñ ?MÓ>N€Ð
;Ô Nr    