Ñò ur™Vc@s§dZddkZddklZdZdZdZd„Zd„Zd „Z e a d „Z d „Z d d d„Zd d„Zd d„Zd d„Zd„ZdS(s› methods for internationalized text processing, which counts "columns" in applicable cases, rather than assuming columns are same as characters or bytes. iÿÿÿÿN(teast_asian_widthtlefttrighttcentercCs7titiƒd}|djotiƒ}n|S(s$ Get encoding of current locale iN(tlocalet getlocaletLC_CTYPEtNonetgetpreferredencoding(tenc((s ../i18n.pyt get_encoding)s cCsYt|tƒo|itƒƒ}nt|ƒ}|djp |djodSdSdS(s; Count column width needed for given Unicode character tFtWiiN(t isinstancetstrtdecodeR R(tct width_class((s ../i18n.pyt charwidth3s  cCs`t|tƒo|itƒƒ}n|idƒ}d}x|D]}|t|ƒ7}qBW|S(sl Count column width needed for given string. text passed in should be a str or unicode object. ii(R RRR t expandtabsR(ttextt width_totaltchar((s ../i18n.pyt textwidth@scCstS(s± Get information on whether wrapping text should be done on white space or on arbitrary position. Default is True as in English. See also: set_wrap_on_whitespace() (t_WHITESPACE_WRAP(((s ../i18n.pytif_wrap_on_whitespaceSscCs0t|tƒo|iƒdj}n|adS(s`Sets the global flag which indicates whether text should be wrapped on whitespace. The default value is True, but varies by language. A gettext call such as the one below should be used to determine whether or not the current language wraps on whitespace: _("DONT_TRANSLATE_BUT_REPLACE_msgstr_WITH_True_OR_False: " "Should wrap text on whitespace in this language") The result of that call can be directly passed into this function; if "do_wrap" is the literal string "False" (case-insensitive), then wrapping will be done. Non-strings will be interpreted as booleans. tFalseN(R t basestringt capitalizeR(tdo_wrap((s ../i18n.pytset_wrap_on_whitespace\s tu c Cs›t|tƒo|itƒƒ}n|idƒ}|d jo d}nt|tƒo|itƒƒ}nt|ƒdjotd|ƒ‚nd}d}xD|D]<}t|ƒ}|||joPn||7}||7}q¬W||}|oš|djo|tjo|||}q—|t jo|||}q—|t jo.|d} || } || ||| }q—td|ƒ‚n|S( s« Fit a text in max_width columns, by truncating the text if needed. If just is one of LEFT, RIGHT, or CENTER, justify text and fill unused room with fillchar. iu is3Cannot use multi-column character "%c" as fillchar.uiisUnknown just=%sN( R RRR RRRt ValueErrortLEFTtRIGHTtCENTER( Rt max_widthtjusttfillchart fitted_textRRtwidthtnpadtnlefttnright((s ../i18n.pytfit_text_truncateps>          cCst||dtd|ƒS(sE alternative to ljust(); counts multicolumn characters correctly R%R&(R,R!(RR$R&((s ../i18n.pyt ljust_columnsscCst||dtd|ƒS(sE alternative to rjust(); counts multicolumn characters correctly R%R&(R,R"(RR$R&((s ../i18n.pyt rjust_columns£scCst||dtd|ƒS(sF alternative to center(); counts multicolumn characters correctly R%R&(R,R#(RR$R&((s ../i18n.pytcenter_columns©scCs–tƒ}t|tƒo|itƒƒ}n|idƒiƒ}g}xE|D]=}d}d}d}d} xt|ƒD]÷\} } t | ƒ} || |joŒ|oU|dj oH|d} |i || | !i ƒƒ|d} ||8}d}d}q1| } |i || | !i ƒƒ| } d}n|| 7}| djo+| | jo|| 8}qs| }|}q|q|W|i || i ƒƒqQW|S(sêBreak a paragraph of text up into chunks that will each fit within max_chars. Splits on whitespace (if wrapping on whitespace is used in current language) and newlines. max_chars defaults to the size of this window. iiiu N( RR RRR Rt splitlinesRt enumerateRtappendtlstrip(Rt max_charstwrap_on_whitespacet text_linestparagraphed_linestlineRtlast_whitespacetwidth_upto_last_whitespacetstart_pttiRR(tend_pt((s ../i18n.pytconvert_paragraph¯sD           (t__doc__Rt unicodedataRR!R"R#R RRtTrueRRRR,R-R.R/R>(((s ../i18n.pyts    -