kf$UdZddlmZddlmZddlmZmZmZm Z hdddhhdgZ ddZ ddZ ddZ ddZeZded<dS)z babel.messages.checkers ~~~~~~~~~~~~~~~~~~~~~~~ Various routines that help with validation of translations. :since: version 0.9 :copyright: (c) 2013-2023 by the Babel Team. :license: BSD, see LICENSE for more details. ) annotations)Callable) PYTHON_FORMATCatalogMessageTranslationError>diuxX>FGfgcatalogCatalog | NonemessagerreturnNonec|js+t|jtst ddS|dS|j}t|t t fs|f}t||jkrt d|jzdS)z0Verify the number of plurals in the translation.z/Found plural forms for non-pluralizable messageNz*Wrong number of plural forms (expected %d)) pluralizable isinstancestringstrrlisttuplelen num_plurals)rrmsgstrss w/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/babel/messages/checkers.pyrrs  '.#.. ."$-.. . nG ge} - -* 7||w***K&2 344 4+*cd|jvrdS|j}t|ttfs|f}|j}t|ttfs|f}t ||D]\}}|rt||dS)z9Verify the format string placeholders in the translation.z python-formatN)flagsidrrrrzip_validate_format)rrmsgidsr msgidmsgstrs r! python_formatr+.sgm++ ZF ftUm , ,nG ge} - -*VW--,, v  , UF + + +,,r"formatr alternativec dd}dd }dd }t|||f\}}t|||f\}}|r|s|std ||krtd |rt|t|krtdtt ||D]2\} \\} } \} } || | std| dz| | fz3dSt |} |D]L\}}|| vrtd|||| |std|d|d| |dMdS)aTest 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. The behavior of this function is undefined if the string does not use string formatting. 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 rrrlist[tuple[str, str]]cg}tj|D]G}|\}}}|dkr|#||t |fH|S)N%)rfinditergroupsappendr)rresultmatchnamer,typechars r!_parsez _validate_format.._parse^sj(*"+F33 1 1E%*\\^^ "D&(34< MM4X/ 0 0 0 0 r"abboolc@||krdStD] }||vr||vrdSdS)NTF)_string_format_compatibilities)r:r;sets r! _compatiblez%_validate_format.._compatiblegs= 6641  CCxxAHHttur"resultscpd}|D]#\}}||du} |du|krtd$t|S)Nz5format string mixes positional and named placeholders)rr<)rA positionalr7_chars r!_check_positionalz+_validate_format.._check_positionalosl " E EKD%!!T\ DLZ//*,DEEE0Jr"zplaceholders are incompatiblez)the format strings are of different kindsz-positional format placeholders are unbalancedzDincompatible format for placeholder %d: %r and %r are not compatiblezunknown named placeholder z$incompatible format for placeholder z: z and z are not compatibleN)rrrr/)r:rr;rrr<)rAr/rr<)maprr enumerater&dict)r,r-r9r@rEr:r; a_positional b_positionalidx_firstsecondtype_mapr7r8s r!r'r'>s@      v , - -DAq"%%6A!?!?L,LLLL>???  % %JKKKI q66SVV  "$011 1.7Aq .B.B A A *C**1ekq&;uf-- A&(J(+a'?(@AAA A A A77 I IND(8##&'LD'L'LMMM [8D>:: I&&)-hhh(HIII I I Ir"1list[Callable[[Catalog | None, Message], object]]cg} ddlm}|dD])}||*n#t $rYnwxYwt |dkrttgS|S)Nr) working_setzbabel.checkers) pkg_resourcesrSiter_entry_pointsr4load ImportErrorrrr+)checkersrS entry_points r!_find_checkersrZsBDH0------'889IJJ 0 0K OOK,,.. / / / / 0       8}}]++ OsA AArXN)rrrrrr)r,rr-rrr)rrQ)__doc__ __future__rcollections.abcrbabel.messages.catalogrrrrr>rr+r'rZrX__annotations__r"r!ras   #"""""$$$$$$TTTTTTTTTTTTOO#J"4444( , , , , \I\I\I\I~     ?Mn>N>NNNNNNNr"