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dd6dd6dd6dd6dd6dd6dd6d d 6d d 6d d6dd6dd6dd6dd6dd6dd6dd6dd6dd 6dd!6dd"6d#d$6d%d&6d'd(6d)d*6d+d,6d-d.6d/d06d-d16d2d36d4d56d6d76d8d96d:d;6d<d=6d>d?6d@dA6dBdC6dDdE6dFdG6dHdI6dJdK6dLdM6dNdO6dPdQ6dRdS6dTdU6dVdW6dXdY6dZd[6d\d]6d^d_6d`da6dbdc6ddde6dfdg6dhdi6djdk6dldm6dndo6dpdq6drds6dtdu6dvdw6dxdy6dzd{6d|d}6d|d~6dd6dd6dd6dd6dd6dd6dd6dd6ZDddZEyeWne;k rYnXe jFdeGdkreHdeHeEeHeHdeHe-ndS(a Locale support. 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/usr/lib/python3.4/locale.py_strcoll"srcCs|S)z\ strxfrm(string) -> string. Returns a string that behaves for cmp locale-aware. r)srrr_strxfrm(sr)*cCsidgd6dd6dd6dd6dd6gd6dd 6d d 6dd 6dd 6dd6dd6dd6dd6dd6dd6dd6dd6S)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$ cCs|dkrtdndS)zd setlocale(integer,string=None) -> string. Activates/queries locale processing. Nr)Cz*_locale emulation only supports "C" locale)Nr)r<)r)categoryvaluerrrrXs cCs#t}tr|jtn|S)N) _localeconv_override_localeconvupdate)drrrr ms ccsld}x_|D]W}|tkr#dS|dkrY|dkrJtdnx |VqMWn|V|}q WdS)Nrzinvalid grouping)r ValueError)r(Z last_intervalintervalrrr_grouping_intervals{s     rEFc CsHt}||rdpd}||r.dp1d}|sE|dfS|d dkr|j}|t|d}|}nd}d}g}xdt|D]V} | s|d d kr|}d}Pn|j|| d|d| }qW|r|j|n|j||j||t|t|dfS) Nr8r7r.r(rr& r) 0123456789rH)r rstriplenrEappendreversejoin) rmonetaryconvr7r(ZstrippedZ right_spacesZ left_spacesgroupsrDrrr_groups0     rQcCsd}x.|r6||dkr6|d7}|d8}q Wt|d}x.|rw||dkrw|d8}|d8}qJW|||dS)NrrFr&)rJ)rZamountZlposZrposrrr_strip_paddings  rRzG%(?:\((?P.*?)\))?(?P[-#0-9 +*.hlL]*?)[eEfFgGdiouxXcrs%]cGsctj|}| s4t|jt|krMtdt|nt|||||S)zReturns the locale-aware substitution of a %? specifier (percent). additional is for format strings which contain one or more '*' modifiers.zHformat() must be given exactly one %%char format specifier, %s not valid) _percent_rematchrJgrouprCrepr_format)percentr>r(rN additionalrTrrrrs %c Gs |r||f|}n ||}|d dkrd}|jd}|rrt|dd|\|d<}nt|rdpd}|j|}|rt||}qnR|d dkrd}|rt|d|\}}n|rt||}qn|S) Nr&ZeEfFgGrr0rNr:r1ZdiurHrH)splitrQr rMrR) rXr>r(rNrYZ formattedZsepspartsr1rrrrWs( #rWc Csottj|}tjd|}t|tjrg}x|D]K}|jddkrr|jdqF|jt |j||qFWnt|t s|f}ng}d}x|D]}|jd dkr|jdq|jdj d}|jt |j|||d||d|d||d|7}qWt |}||S) zFormats 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.z%sr&%rZ modifiersr FrHrH) listrSfinditersub isinstance collectionsMappingrUrKrtuplecountrW) fvalr(ZpercentsZnew_fZnew_valZperciZ starcountrrrrs0 &    Tc Cst}||rdpd}|dkr:tdntd|t||dd}d|d }|r||rd pd }||d krd pd}||d krdpd} |r|| rdpd|}q|| rdpd|}n||d krdpd} ||d kr/dp2d} | d krSd|d}n~| dkrl| |}ne| dkr|| }nL| dkr|jd| }n+| dkr|jd | }n | |}|jddjd dS)zIFormats val according to the currency settings in the current locale.r;r9r!z9Currency formatting is not possible using the 'C' locale.z%%.%ifrNT<>r5r*rr-r,r/r4rFr)r+r6r2r3()r&r'r#r%)r rCrabsreplace) rfZsymbolr(Z internationalrOZdigitsrZsmbZprecedesZ separatedZsign_posZsignrrrrs6  "        cCs td|S)z9Convert float to integer, taking the locale into account.z%.12g)r)rfrrrr,scCsZtd}|r(|j|d}ntd}|rP|j|d}n||S)zZms_BNi>Zml_INiLZmt_MTi:Zmi_NZiZarn_CLizZmr_INiNZmoh_CAi|Zmn_MNiPZmn_CNiPZne_NPiaZnb_NOiZnn_NOiZoc_FRiZor_INiHZps_AFicZfa_IRi)Zpl_PLiZpt_BRiZpt_PTiZpa_INiFZquz_BOikZquz_ECikZquz_PEik Zro_ROiZrm_CHiZru_RUiZsmn_FIi;$Zsmj_NOi;Zsmj_SEi;Zse_NOi;Zse_SEi;Zse_FIi; Zsms_FIi; Zsma_NOi;Zsma_SEi;Zsa_INiOZsr_SPi Zsr_BAiiiZsi_LKi[Zns_ZAilZtn_ZAi2Zsk_SKiZsl_SIi$Zes_ESi Zes_MXi i Zes_GTi Zes_CRi Zes_PAi Zes_DOi Zes_VEi Zes_COi $Zes_PEi (Zes_ARi ,Zes_ECi 0Zes_CLi 4Zes_URi 8Zes_PYi <Zes_BOi @Zes_SVi DZes_HNi HZes_NIi LZes_PRi PZes_USi TZsw_KEiAZsv_SEiZsv_FIiZsyr_SYiZZtg_TJi(Ztmz_DZi_Zta_INiIZtt_RUiDZte_INiJZth_THiZbo_BTiQZbo_CNiQZtr_TRiZtk_TMiBZug_CNiZuk_UAi"Zwen_DEi.Zur_PKi Zur_INi Zuz_UZiCiCZvi_VNi*Zcy_GBiRZwo_SNiZxh_ZAi4Zsah_RUiZii_CNixZyo_NGijZzu_ZAi5c CsMi}|dd}||d=tdtddt\}}td|pYdtd |pldttd tddxf|jD]X\}}t|d t|\}}td |pdtd |pdtqWttdtddtxf|jD]X\}}t|d t|\}}td |pedtd |pxdtq+WyttdWn&tdtdtdYnXttdtddxf|jD]X\}}t|d t|\}}td |p'dtd |p:dtqWdS)z Test function. cSsGx@tjD]/\}}|dddkr|||._init_categoriesrz4Locale defaults as determined by getdefaultlocale():rwHz 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)rsrrrrrr)rrZlangencnamer=rrr _print_localeDsV           r LC_MESSAGES__main__zLocale aliasing:zNumber formatting:)zLC_ALLzLC_CTYPErzLANGUAGE)I__doc__rryZencodings.aliasesrerabuiltinsrr functools__all__rrrrrrrrrrrrrCrr rrr r r?r@wrapsrErQrRcompilerSrrWrrfloatr r rurrrrrrrrrr startswithrCODESET NameErrorr~sortedrrrrm setdefaultrrrrK__name__rsrrrr s                 "-     S  5    r   :