a DOg1M@s dZddlZddlZddlZddlZddlZddlmZddl Z gdZ ddZ ddZ z dd l TWnJeyd Zd Zd ZdZd ZdZdZdZeZddZdddZYn0devre Zdevre ZeZiZe eddZddZ!dddZ"ddZ#e$dZ%dd d!Z&dd"d#Z'dd$d%Z(dd'd(Z)d)d*Zd+d,Z*e+fd-d.Z,d/d0Z-d1d2Z.eZ/d3d4Z0d5d6Z1d7d8Z2d9d:Z3d;d<Z4dd>d?Z5efd@dAZ6ddBdZefdCdDZ7ej89dErddFdGZ:nPze;Wn:e<y"e=edHrddIdGZ:n ddJdGZ:Yn0ddKdGZ:dLdLdMdNdNdOdPdQdRdSdMdTdUdVdMdMdMdWdXdYdZdVd[dTd\d]dUd^d_d`dadNdbdcdOdddedfdgdhdidQdRdSdj,Z>e?e>@D]"\ZAZBeACdkdlZAe>DeAeBqdmdmdmdndodpdqdqdrdsdtdtdudvdwdxdxdydzd{d|d}d~ddddddddddddddxddddddddddddddddddddddddddddddddddddLddLdLduddLdLdddddddddudddddddddddddddddddddddddddddddddddddddddddudddddddddddddddddddudddddddduddudLdudddddddddddddddddddddddddddddddddddddddddddddddddddddddd d d d d d d d ddddddd d dǐdddddddddddddddddddddddddddd d d!d"d d dddudduddudېd#d$d#d#d%d%d%ddd&d'd'd'd(d(d'd'd'd'd'd)d)d)d*d)d+d,d-d-d.d/d/d0d0d0d1d0d0d2d2d3d4d5d5d6d6d7d8d9d:d;d<d=d>d>d?d?d>d<d<d@d@dAdBdCdCdDdEdFdGdHdHdIdJdKdKdLdLdMdNdOdOdPdPdQdQdRdSdddTdUdVdWdXdYddZddd[d[d\d]d\d\d\d\d^d^d_d_d]d]d[d`d`dadbdcdcdddededfdgdhdidjdkdjdldldmdmdmdndodLdLdpdpdqdndodndrdsdtdtdtdududvdtdwdxdxdydzd{d|d|d}d~ddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddÐdÐdĐdŐdddǐdddɐdɐdʐdːdddd̐d̐d͐LZEdΐdϐdАdѐdҐdӐdԐdՐd֐dאdؐdِdڐdېdܐdݐdސdߐdddddddddddddddddddddddddddddddddddddddddddd d d d d d ddddddddddddddddddd d!d"d#d$d%d&d'd'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`d_d`dadbdcdddedfdgdfdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddddddZFddZGzeWne< yYn0e HdeIdk reJdeJeGeJeJdeJe.dS(aLocale support module. The module provides low-level access to the C lib's locale APIs and adds high level number formatting APIs as well as a locale aliasing engine to complement these. The aliasing engine includes support for many commonly used locale names and maps them to values suitable for passing to the C lib's setlocale() function. It also includes default encodings for all supported locale names. N)str) getlocalegetdefaultlocalegetpreferredencodingError setlocale resetlocale localeconvstrcollstrxfrmratofatoiformat format_stringcurrency normalizeLC_CTYPE LC_COLLATELC_TIME LC_MONETARY LC_NUMERICLC_ALLCHAR_MAXcCs||k||kS)zZ strcoll(string,string) -> int. Compares two strings according to the locale. )abrr+/opt/alt/python39/lib64/python3.9/locale.py_strcoll!srcCs|S)z\ strxfrm(string) -> string. Returns a string that behaves for cmp locale-aware. r)srrr_strxfrm'sr)*cCs,dgddddgdddddddddddddS)zd localeconv() -> dict. Returns numeric and monetary locale-specific parameters. r!.)groupingcurrency_symbol n_sign_posn p_cs_precedes n_cs_precedes mon_groupingn_sep_by_space decimal_point negative_sign positive_signp_sep_by_spaceint_curr_symbol p_sign_posn thousands_sepmon_thousands_sep frac_digitsmon_decimal_pointint_frac_digitsrrrrrr ?s&r cCs|dvrtddS)zd setlocale(integer,string=None) -> string. Activates/queries locale processing. )Nr(Cz*_locale emulation only supports "C" localer<)r)categoryvaluerrrrWsrr r cCst}tr|t|S)N) _localeconv_override_localeconvupdate)drrrr ls ccsJd}|D]<}|tkrdS|dkr:|dur2td|Vq2|V|}qdS)Nrzinvalid grouping)r ValueError)r*Z last_intervalintervalrrr_grouping_intervalszsrEFc Cst}||rdpd}||r dp"d}|s2|dfS|ddkr\|}|t|d}|}nd}d}g}t|D]B} |r|dd vr|}d}q||| d|d| }qp|r|||||||t|t|d fS) Nr8r7r/r*r r( 0123456789r&)r rstriplenrEappendreversejoin) rmonetaryconvr7r*strippedZ right_spacesZ left_spacesgroupsrDrrr_groups2   rRcCsdd}|r&||dkr&|d7}|d8}qt|d}|rT||dkrT|d8}|d8}q2|||dS)NrrGr&)rJ)rZamountZlposZrposrrr_strip_paddings   rSzG%(?:\((?P.*?)\))?(?P[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]c Gs|r||f|}n||}|ddvr~d}|d}|rRt|d|d\|d<}t|r^dp`d}||}|rt||}n2|ddvrd}|rt||d\}}|rt||}|S) NrFZeEfFgGrr)rNr:r1Zdiu)splitrRr rMrS) percentr>r*rN additionalZ formattedZsepspartsr1rrr_formats*       rYc Cs tt|}td|}t|tjrjg}|D]8}|ddkrN|dq.|t ||||q.nt|t sz|f}g}d}|D]t}|ddkr|dq|d d} |t |||||g||d|d| R|d| 7}qt |}||S)aFormats a string in the same way that the % formatting would use, but takes the current locale into account. Grouping is applied if the third parameter is true. Conversion uses monetary thousands separator and grouping strings if forth parameter monetary is true.z%srF%rZ modifiersr r&) list _percent_refinditersub isinstance_collections_abcMappinggrouprKrYtuplecount) fvalr*rNZpercentsZnew_fZnew_valZperciZ starcountrrrrs4       rcGs`ddl}|jdtddt|}|r:t|t|krJtdt|t ||||g|RS)z&Deprecated, use format_string instead.rNz`This method will be removed in a future version of Python. Use 'locale.format_string()' instead.r') stacklevelzHformat() must be given exactly one %%char format specifier, %s not valid) warningswarnDeprecationWarningr\matchrJrbrCreprrY)rVr>r*rNrWrirlrrrrs rTc Cst}||rdpd}|dkr&tdtd|t||dd}d|d }|r||rXd pZd }||d krld pnd}||d krdpd} |r|| rdpd|}n0|r|ddkr|dd}|| rdpd|}||d krdpd} ||d krdpd} | d krd|d}n`| dkr$| |}nL| dkr8|| }n8| dkrP|d| }n | dkrh|d | }n| |}|ddd dS)zIFormats val according to the currency settings in the current locale.r;r9r!z9Currency formatting is not possible using the 'C' locale.z%%.%ifTrT<>r5r+rr.r-r0r4rGr(rFNr,r6r2r3()r&r'r#r%)r rCrYabsreplace) rfZsymbolr*Z internationalrOZdigitsrZsmbZprecedesZ separatedZsign_posZsignrrrrs:         rcCs td|S)z8Convert float to string, taking the locale into account.z%.12g)rY)rfrrrr2srcCs:t}|d}|r||d}|d}|r6||d}|S)zHParses a string as a normalized number according to the locale settings.r7r(r1r))r rs)stringrOtsZddrrr delocalize6s  rvcCs |t|S)zi>iLi:iiziNi|iPiPiaiiiiHici)iiiiFikikik iiii;$i;i;i;i;i; i; i;i;iOi iiii[ili2ii$i i i i i i i i i $i (i ,i 0i 4i 8i <i @i Di Hi Li Pi TiAiiiZi(i_iIiDiJiiQiQiiBii"i.i i iCiCi*iRii4iixiji5cCsi}|fdd}||d=tdtdt\}}td|p@dtd|pNdttd td|D]@\}}t|d t|\}}td |pdtd |pdtqpttd tdt|D]B\}}t|d t|\}}td |pdtd |pdtqzttdWn$tdtdtdYnh0ttdtd|D]F\}}t|d t|\}}td |pdtd |pdtqldS)z Test function. cSs0tD] \}}|dddkr |||<q dS)Nr#ZLC_)globalsitems) categorieskvrrr_init_categoriessz'_print_locale.._init_categoriesrz4Locale defaults as determined by getdefaultlocale():zH------------------------------------------------------------------------z Language: z (undefined)z Encoding: zLocale settings on startup:z...z Language: z Encoding: z,Locale settings after calling resetlocale():r(zNOTE:z9setlocale(LC_ALL, "") does not support the default localez&given in the OS environment variables.z4Locale settings after calling setlocale(LC_ALL, ""):N)rzrrrrrr)rrZlangencnamer=rrr _print_localesV        r LC_MESSAGES__main__zLocale aliasing:zNumber formatting:)N)F)FF)FF)FF)TFF)r)N)T)T)T)T)K__doc__rrZencodings.aliasesrer`builtinsrr functools__all__rrrrrrrrrrrrrCrr rrr r r?r@wrapsrErRrScompiler\rYrrrrvfloatr r r|rrrrrrrrrr startswithrCODESET NameErrorhasattrrsortedrrrrs setdefaultrrrrK__name__rzrrrrsL           %  /  S" 5     $6 } aV :