o bcj@sdZddlZddlZddlZgdZejejddZe dej ej BZ ddZ d d Zd Zd d eedDZddddZdGddZddZddZddZGdddZGdddeZdHd!d"ZiZd#gZdddd efd$d%Zdedfd&d'Ziaiad(adId)d*Z dId+d,Z!dId-d.Z"d/d0Z#d1d2Z$d3d4Z%d5d6Z&d7d8Z'd9d:Z(d;d<Z)d=d>Z*d?d@Z+dAdBZ,dCdDZ-dEdFZ.eZ/dS)JaInternationalization and localization support. This module provides internationalization (I18N) and localization (L10N) support for your Python programs by providing an interface to the GNU gettext message catalog library. I18N refers to the operation by which a program is made aware of multiple languages. L10N refers to the adaptation of your program, once internationalized, to the local language and cultural habits. N)NullTranslationsGNUTranslationsCatalogfind translationinstall textdomainbindtextdomainbind_textdomain_codesetdgettext dngettextgettextlgettext ldgettext ldngettext lngettextngettextpgettext dpgettext npgettext dnpgettextZsharelocalea (?P[ \t]+) | # spaces and horizontal tabs (?P[0-9]+\b) | # decimal integer (?Pn\b) | # only n is allowed (?P[()]) | (?P[-*/%+?:]|[>, # <=, >=, ==, !=, &&, ||, # ? : # unary and bitwise ops # not allowed (?P\w+|.) # invalid token ccsRtt|D]}|j}|dkrq||}|dkr td||VqdVdS)NZ WHITESPACESZINVALIDz invalid token in plural form: %s)refinditer_token_pattern lastgroupgroup ValueError)pluralmokindvaluer#h/home/lily/lilypond-2.24.1/release/binaries/dependencies/install/Python-3.10.8/lib/python3.10/gettext.py _tokenizeVs   r%cCs|rtd|StdS)Nz#unexpected token in plural form: %szunexpected end of plural form)r)r"r#r#r$_erroras r&))||)&&)z==z!=)<>z<=z>=)+-)*/%cCs i|] \}}|D]}||qqSr#r#).0iopsopr#r#r$ os r4orandz//)r'r(r.c Csd}t|}|dkr|d7}t|}|dks |dkr/t|\}}d||f}|dkr.tdn%|dkr:d ||f}nzt|d }Wn tyMt|dwd ||f}t|}d }|tvrt|}||krgn(|d vrs|d vrsd|}t||}t||d\} }d||| f}|}|tvs^||krdkrnnd|}|dkr|dkrt|d\} }|dkrt|t|\} }d| || f}|dkrd|}||fS)Nr!znot (z%s(%s))z%unbalanced parenthesis in plural formnz%s%s z%s%dd)z(%s)r5z%s %s %sr@?r:z%s if %s else %s)next_parserintr& _binary_ops _c2py_opsget) tokensZpriorityresultnexttoksubr"jr1r3rightZif_trueZif_falser#r#r$rDrsX        rDcCsTzt|}Wntytd|jjfdwddl}|d|jjftd|S)Nz'Plural value must be an integer, got %srr@)round TypeError __class____name__warningswarnDeprecationWarning)r<r1rSr#r#r$_as_ints   rVcCst|dkr tdz>tt|\}}|rt|d}|D]}|dkr0|d7}|dkr/tdq|dkr8|d8}qd ti}td |||d WStyStdw) zGets a C expression as used in PO files for plural forms and returns a Python function that implements an equivalent expression. iz"plural form expression is too longrr:r5z%plural form expression is too complexr;rVzif True: def func(n): if not isinstance(n, int): n = _as_int(n) return int(%s) func)lenrrDr%r&rVexecRecursionError)rrJrKZdepthcnsr#r#r$c2pys4   r^cCs8ddl}||}d}d}d}d}|d}|dkr+||d}|d|}||O}nd}|d}|dkrG||d}|d|}||O}nd}|d}|dkrc||d} |d|}||O}nd} |} g} t|dD]&} | |@s| } | |@r| | 7} | |@r| |7} | |@r| |7} | | qo| | S) Nrr5r@@r._)r normalizerrangeappendreverse)ZlocrZCOMPONENT_CODESETZCOMPONENT_TERRITORYZCOMPONENT_MODIFIERmaskposZmodifiercodesetZ territoryZlanguageZretr1valr#r#r$ _expand_langsH               rkc@seZdZdddZddZddZdd Zd d Zd d ZddZ ddZ ddZ ddZ ddZ ddZddZdddZdS)rNcCs2i|_d|_d|_d|_|dur||dSdSN)_info_charset_output_charset _fallbackrDselffpr#r#r$__init__szNullTranslations.__init__cCsdSrlr#rqr#r#r$rDszNullTranslations._parsecCs |jr |j|dS||_dSrl)rp add_fallback)rrfallbackr#r#r$ru s zNullTranslations.add_fallbackcCs|jr |j|S|Srl)rpr )rrmessager#r#r$r s zNullTranslations.gettextcCsddl}|dtdddl}|jr3||ddt|j|WdS1s.wY|jr<| |jS| | S)Nr/lgettext() is deprecated, use gettext() insteadr_ignore.*\blgettext\b.*) rSrTrUrrpcatch_warningsfilterwarningsrroencodegetpreferredencoding)rrrwrSrr#r#r$rs    zNullTranslations.lgettextcCs&|jr |j|||S|dkr|S|SNr5)rpr)rrmsgid1msgid2r<r#r#r$r#s zNullTranslations.ngettextcCsddl}|dtdddl}|jr5||ddt|j|||WdS1s0wY|dkr<|}n|}|jrG| |jS| | S)Nr1lngettext() is deprecated, use ngettext() insteadr_ry.*\blngettext\b.*r5) rSrTrUrrpr{r|rror}r~rrrrr<rSrtmsgr#r#r$r+s$   zNullTranslations.lngettextcCs|jr |j||S|Srl)rpr)rrcontextrwr#r#r$r=szNullTranslations.pgettextcCs(|jr |j||||S|dkr|S|Sr)rpr)rrrrrr<r#r#r$rBs zNullTranslations.npgettextcC|jSrl)rmrrr#r#r$infoJzNullTranslations.infocCrrl)rnrr#r#r$charsetMrzNullTranslations.charsetcCsddl}|dtd|jS)Nrzoutput_charset() is deprecatedr_rSrTrUro)rrrSr#r#r$output_charsetPs zNullTranslations.output_charsetcCs ddl}|dtd||_dS)Nrz"set_output_charset() is deprecatedr_r)rrrrSr#r#r$set_output_charsetVs  z#NullTranslations.set_output_charsetcCsNddl}|j|jd<|dur#hd}|t|@D] }t|||j|<qdSdS)Nrrb>r rrrrr)builtinsr __dict__setgetattr)rrnamesrZallowednamer#r#r$r\s zNullTranslations.installrl)rR __module__ __qualname__rtrDrur rrrrrrrrrrr#r#r#r$rs rc@s\eZdZdZdZdZdZddZddZd d Z d d Z d dZ ddZ ddZ ddZdS)rl*l$<z%s%s)rr5cCs|d?|d@fS)z/Returns a tuple of major version, minor versionir#)rrversionr#r#r$ _get_versionsrszGNUTranslations._get_versionsc"Csddlm}t|dd}i|_}dd|_|}t|}|d|dd d}||jkr>|d |d d \}} } } d } n||jkrS|d |d d \}} } } d} nt dd|| |\} }| |j vrot ddt | |t d| D]}|| || | d\}}||}|| || | d\}}||}||kr||kr|||}|||}nt dd||dkr,d}|dD]l}|}|sq|dr|drqd}}d|vr|dd\}}|}|}||j|<|}n|r|j|d|7<|dkr|dd|_q|dkr+|d}|ddd}t||_q|jp1d}d|vr\|d\}} |d}t ||}t|D]\}}!t |!||||f<qLn t |||t ||<| d7} | d7} qtdS)z8Override this method to support alternative .mo formats.r)unpackrrcSs t|dkSr)rE)r<r#r#r$s z(GNUTranslations._parse..z4Iz>IIzBad magic numberzBad version number zFile is corrupt z #-#-#-#-#rBr5 z content-typezcharset=z plural-forms;zplural=ascii)structrr_catalogrreadrYLE_MAGICBE_MAGICOSErrorrVERSIONSstrrdsplitdecodestrip startswithendswithlowerrmrnr^ enumerate)"rrrsrfilenameZcatalogZbufZbuflenmagicrZmsgcountZ masteridxZtransidxZiiZ major_versionZ minor_versionr1ZmlenZmoffZmendZtlenZtoffZtendmsgrZlastkZb_itemitemkvrrrrxr#r#r$rDvs|                      zGNUTranslations._parsecCspddl}|dtdddl}t}|j||}||ur(|jr&|j|S|}|j r1| |j S| | S)Nrrxr_) rSrTrUrobjectrrHrprror}r~)rrrwrSrmissingrr#r#r$rs  zGNUTranslations.lgettextcCsddl}|dtdddl}z |j|||f}Wnty:|jr/|j|||YS|dkr6|}n|}Ynw|j rD| |j S| | S)Nrrr_r5) rSrTrUrrrKeyErrorrprror}r~rr#r#r$rs$  zGNUTranslations.lngettextcCs6t}|j||}||ur|jr|j|S|S|Srl)rrrHrpr )rrrwrrr#r#r$r s zGNUTranslations.gettextcCs`z |j|||f}W|Sty/|jr!|j|||YS|dkr*|}Y|S|}Y|Swr)rrrrpr)rrrrr<rr#r#r$rs zGNUTranslations.ngettextcCsF|j||f}t}|j||}||ur!|jr|j||S|S|Srl)CONTEXTrrrHrpr)rrrrw ctxt_msg_idrrr#r#r$rszGNUTranslations.pgettextc Csp|j||f}z |j|||f}W|Sty7|jr)|j||||YS|dkr2|}Y|S|}Y|Swr)rrrrrpr)rrrrrr<rrr#r#r$rs zGNUTranslations.npgettextN)rRrrrrrrrrDrrr rrrr#r#r#r$rfsY  rFc Cs|durt}|dur)g}dD]}tj|}|r|d}nqd|vr)|dg}|D]}t|D] }||vr>||q3q-|rEg} nd} |D]&}|dkrR| Stj||dd|} tj | ro|rk| | qI| SqI| S)N)ZLANGUAGELC_ALL LC_MESSAGESZLANGrBCrz%s.mo) _default_localedirosenvironrHrrerkpathjoinexists) domain localedir languagesallZenvarrjZnelangsZlangZnelangrJmofiler#r#r$rsB       rZ unspecifiedc Cs<|durt}t|||dd}|s!|rtSddlm}t|d|d}|D]v} |tj| f} t | } | durUt | d} t | || } Wdn1sPwYddl } | | } |turddl}|dtd|r||d d t| |Wdn1swY|dur| }q%|| q%|S) NT)rr)ENOENTz$No translation file found for domainrbzparameter codeset is deprecatedr_ryz.*\bset_output_charset\b.*)rrrerrnorFileNotFoundErrorrrabspath _translationsrHopen setdefaultcopy _unspecifiedrSrTrUr{r|rru)rrrZclass_rvriZmofilesrrJrkeytrsrrSr#r#r$rGsH       rcCst||d|d}||dS)NT)rvri)rr)rrrirrr#r#r$rrsrZmessagescCs|dur|atSrl)_current_domain)rr#r#r$rsrcCs|dur|t|<t|tSrl) _localedirsrHr)rrr#r#r$r s r cCs0ddl}|dtd|dur|t|<t|S)Nrz'bind_textdomain_codeset() is deprecatedr_)rSrTrU_localecodesetsrH)rrirSr#r#r$r s r cCs8z t|t|d}Wn ty|YSw||Srl)rrrHrr )rrwrr#r#r$r s   r cCsddl}|dtdddl}t|}z(||ddtt|t |d|d}Wdn1s6wYWnt yN| |pJ| YSw||ddt| |WdS1sjwYdS)Nrz1ldgettext() is deprecated, use dgettext() insteadr_ry.*\bparameter codeset\b.*rirz)rSrTrUrrrHr{r|rrrr}r~r)rrwrSrrirr#r#r$rs.    $rcCsLz t|t|d}Wnty|dkr|YS|YSw||||Sr)rrrHrr)rrrr<rr#r#r$r s r c Csddl}|dtdddl}t|}z(||ddtt|t |d|d}Wdn1s6wYWnt yW|dkrJ|}n|}| |pS| YSw||ddt| |||WdS1suwYdS) Nrz3ldngettext() is deprecated, use dngettext() insteadr_ryrrr5r)rSrTrUrrrHr{r|rrrr}r~r) rrrr<rSrrirrr#r#r$rs4     $rcCs:z t|t|d}Wn ty|YSw|||Srl)rrrHrr)rrrwrr#r#r$rs   rcCsNz t|t|d}Wnty|dkr|YS|YSw|||||Sr)rrrHrr)rrrrr<rr#r#r$rs rcCs tt|Srl)r r)rwr#r#r$r s r cCsZddl}|dtd||ddttt|WdS1s&wYdS)Nrrxr_ryz.*\bldgettext\b.*)rSrTrUr{r|rr)rwrSr#r#r$rs $rcCstt|||Srl)r r)rrr<r#r#r$rsrcCs^ddl}|dtd||ddttt|||WdS1s(wYdS)Nrrr_ryz.*\bldngettext\b.*)rSrTrUr{r|rr)rrr<rSr#r#r$rs  $rcCs tt||Srl)rr)rrwr#r#r$rs rcCstt||||Srl)rr)rrrr<r#r#r$rsr)r8)NNFrl)0__doc__rrsys__all__rr base_prefixrcompileVERBOSEDOTALLrr%r&rFrrGrDrVr^rkrrrrrrrrrrrr r r rr rrrr rrrrrrr#r#r#r$s^0     1 $+h 9& +