ó i­:Oc@s×dZddlZddlmZddlmZmZddlmZddl m Z m Z m Z m Z mZmZd„Zd„Zdd „Zded d d „Zd d d d „Zd„Zd„ZdZdS(sü ----- UTF-8 ----- Functions for operating on byte :class:`str` encoded as :term:`UTF-8` .. note:: In many cases, it is better to convert to :class:`unicode`, operate on the strings, then convert back to :term:`UTF-8`. :class:`unicode` type can handle many of these functions itself. For those that it doesn't (removing control characters from length calculations, for instance) the code to do so with a :class:`unicode` type is often simpler. .. warning:: All of the functions in this module are deprecated. Most of them have been replaced with functions that operate on unicode values in :mod:`kitchen.text.display`. :func:`kitchen.text.utf8.utf8_valid` has been replaced with a function in :mod:`kitchen.text.misc`. iÿÿÿÿN(tb_(t to_unicodetto_bytes(tbyte_string_valid_encoding(t_textual_width_letbyte_string_textual_width_filltfillt textual_widthttextual_width_choptwrapcCs&tjtdƒtddƒt|ƒS(s„**Deprecated** Detect if a string is valid :term:`utf-8` Use :func:`kitchen.text.misc.byte_string_valid_encoding` instead. sjkitchen.text.utf8.utf8_valid is deprecated. Use kitchen.text.misc.byte_string_valid_encoding(msg) insteadt stackleveli(twarningstwarnRtDeprecationWarningR(tmsg((s5/usr/lib/python2.7/site-packages/kitchen/text/utf8.pyt utf8_valid@s cCs&tjtdƒtddƒt|ƒS(sˆ**Deprecated** Get the :term:`textual width` of a :term:`utf-8` string Use :func:`kitchen.text.display.textual_width` instead. s`kitchen.text.utf8.utf8_width is deprecated. Use kitchen.text.display.textual_width(msg) insteadR i(R R RR R(R((s5/usr/lib/python2.7/site-packages/kitchen/text/utf8.pyt utf8_widthJs cCs|tjtdƒtddƒ|dkr8t|ƒ|fSt|tƒ }t||ƒ}|rlt |ƒ}nt|ƒ|fS(sA**Deprecated** Return a string chopped to a given :term:`textual width` Use :func:`~kitchen.text.display.textual_width_chop` and :func:`~kitchen.text.display.textual_width` instead:: >>> msg = 'ã ku ら ra 㨠to ã¿ mi' >>> # Old way: >>> utf8_width_chop(msg, 5) (5, 'ã ku') >>> # New way >>> from kitchen.text.converters import to_bytes >>> from kitchen.text.display import textual_width, textual_width_chop >>> (textual_width(msg), to_bytes(textual_width_chop(msg, 5))) (5, 'ã ku') sekitchen.text.utf8.utf8_width_chop is deprecated. Use kitchen.text.display.textual_width_chop insteadR iN( R R RR tNoneRt isinstancetunicodeRR(Rtchoptas_bytest chopped_msg((s5/usr/lib/python2.7/site-packages/kitchen/text/utf8.pytutf8_width_chopUs tc CsAtjtdƒtddƒt||d|d|d|d|ƒS(s–**Deprecated** Pad a :term:`utf-8` string to fill a specified width Use :func:`~kitchen.text.display.byte_string_textual_width_fill` instead sqkitchen.text.utf8.utf8_width_fill is deprecated. Use kitchen.text.display.byte_string_textual_width_fill insteadR iRtlefttprefixtsuffix(R R RR R(RRRRRR((s5/usr/lib/python2.7/site-packages/kitchen/text/utf8.pytutf8_width_fillss iFcCs‚tjtdƒtddƒt|tƒ }t|ƒ}t|d|d|d|ƒ}|r~g|D]}t|ƒ^qc}n|S(s´**Deprecated** Similar to :func:`textwrap.wrap` but understands :term:`utf-8` data and doesn't screw up lists/blocks/etc Use :func:`kitchen.text.display.wrap` instead sVkitchen.text.utf8.utf8_text_wrap is deprecated. Use kitchen.text.display.wrap insteadR itwidthtinitial_indenttsubsequent_indent( R R RR RRRR R(ttextRRRRtlinestm((s5/usr/lib/python2.7/site-packages/kitchen/text/utf8.pytutf8_text_wraps   "cOs,tjtdƒtddƒt|||ŽS(s¹**Deprecated** Similar to :func:`textwrap.fill` but understands :term:`utf-8` strings and doesn't screw up lists/blocks/etc. Use :func:`kitchen.text.display.fill` instead. sVkitchen.text.utf8.utf8_text_fill is deprecated. Use kitchen.text.display.fill insteadR i(R R RR R(R targstkwargs((s5/usr/lib/python2.7/site-packages/kitchen/text/utf8.pytutf8_text_fill“s cGs8tjtdƒtddƒt|tdj|ƒƒƒS(sx**Deprecated** Convert the arguments to unicode and use :func:`kitchen.text.display._textual_width_le` instead. sckitchen.text.utf8._utf8_width_le is deprecated. Use kitchen.text.display._textual_width_le insteadR iR(R R RR RRtjoin(RR$((s5/usr/lib/python2.7/site-packages/kitchen/text/utf8.pyt_utf8_width_leŸs R&R#RRRR(sutf8_text_fillsutf8_text_wraps utf8_valids utf8_widthsutf8_width_chopsutf8_width_fill(t__doc__R tkitchenRtkitchen.text.convertersRRtkitchen.text.miscRtkitchen.text.displayRRRRRR RRRRtTrueRR#R&R(t__all__(((s5/usr/lib/python2.7/site-packages/kitchen/text/utf8.pyt2s .