
    ̆hK                        % S r SSKJr  SSKJr  SSKJrJrJrJ	r	  1 SkSS11 Sk/r
SS	 jrSS
 jrSS jrSS jr\" 5       rS\S'   g)z
babel.messages.checkers
~~~~~~~~~~~~~~~~~~~~~~~

Various routines that help with validation of translations.

:since: version 0.9

:copyright: (c) 2013-2025 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                :   UR                   (       d+  [        UR                  [        5      (       d  [	        S5      egU c  gUR                  n[        U[
        [        45      (       d  U4n[        U5      U R                  :w  a  [	        SU R                  -  5      eg)z0Verify the number of plurals in the translation.z/Found plural forms for non-pluralizable messageNz*Wrong number of plural forms (expected %d))	pluralizable
isinstancestringstrr   listtuplelennum_plurals)catalogmessagemsgstrss      O/opt/services/DDDS/venv/lib/python3.13/site-packages/babel/messages/checkers.pyr   r      s    '..#.." $- . . 
nnGge}--*
7|w***K&22 3 4 	4 +    c                   SUR                   ;  a  gUR                  n[        U[        [        45      (       d  U4nUR
                  n[        U[        [        45      (       d  U4n[        X#5       H  u  pEU(       d  M  [        XE5        M     g)z9Verify the format string placeholders in the translation.zpython-formatN)flagsidr   r   r   r   zip_validate_format)r   r   msgidsr   msgidmsgstrs         r   python_formatr(   .   sq    gmm+ZZFftUm,,nnGge}--*V-6U+ .r   c           
     V   SS jnSS jnSS jn[        X U45      u  pVU(       d  g[        XEU45      u  pxU(       a  U(       d  U(       d  [        S5      eXx:w  a  [        S5      eU(       ai  [        U5      [        U5      :w  a  [        S5      e[        [	        XV5      5       H-  u  n	u  u  pu  pU" X5      (       a  M  [        SU	S	-   X4-  5      e   g[        U5      nU HC  u  pX;  a  [        S
U< 35      eU" XU   5      (       a  M+  [        SU< SU< SX   < S35      e   g)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                    / n[         R                  " U 5       H=  nUR                  5       u  p4nUS:X  a  Uc  M!  UR                  U[	        U5      45        M?     U$ )N%)r   finditergroupsappendr   )r   resultmatchnameformattypechars         r   _parse _validate_format.<locals>._parse[   sV    (*"++F3E%*\\^"D(34<MM4X/0	 4
 r   c                F    X:X  a  g[          H  nX;   d  M
  X;   d  M    g   g)NTF)_string_format_compatibilities)absets      r   _compatible%_validate_format.<locals>._compatibled   s%    61CxAH 2 r   c                j    S nU  H!  u  p#Uc  US L nM  US L U:w  d  M  [        S5      e   [        U5      $ )Nz5format string mixes positional and named placeholders)r   bool)results
positionalr1   _chars       r   _check_positional+_validate_format.<locals>._check_positionall   sP    
"KD!!T\
DLZ/* ,D E E # Jr   Nzplaceholders are incompatiblez)the format strings are of different kindsz-positional format placeholders are unbalancedzDincompatible format for placeholder %d: %r and %r are not compatible   zunknown named placeholder z$incompatible format for placeholder z: z and z are not compatible)r   r   returnlist[tuple[str, str]])r8   r   r9   r   rE   r>   )r?   rF   rE   r>   )mapr   r   	enumerater#   dict)r2   alternativer4   r;   rB   r8   r9   a_positionalb_positionalidx_firstsecondtype_mapr1   r3   s                   r   r$   r$   >   sJ   :	  v,-DA "%%6A!?LL>??		%JKK q6SV" $0 1 1.7A	.B*C**1kqu--& (J(+a'?(@ A A /C 7ND#&)CD8'LMM D>::&:4("l%'99LN 	  r   1list[Callable[[Catalog | None, Message], object]]c                     SSK Jn   / nUR                  S U " S5       5       5        [        U5      S:X  a  [        [
        /$ U$ )Nr   )find_entrypointsc              3  4   #    U  H  u  pU" 5       v   M     g 7f)N ).0r1   loads      r   	<genexpr>!_find_checkers.<locals>.<genexpr>   s     R/Q|DFF/Qs   zbabel.checkers)babel.messages._compatrT   extendr   r   r(   )rT   checkerss     r   _find_checkersr^      sA    7BDHOOR/?@P/QRR
8} ]++Or   r]   N)r   zCatalog | Noner   r   rE   None)r2   r   rJ   r   rE   r_   )rE   rR   )__doc__
__future__r   collections.abcr   babel.messages.catalogr   r   r   r   r7   r   r(   r$   r^   r]   __annotations__rV   r   r   <module>re      sV   
 # $ T T #J" 4(, \~ ?M>N
; Nr   