yum.i18n

yum.i18n.dummy_wrapper(str)

Dummy Translation wrapper, just returning the same string.

yum.i18n.dummyP_wrapper(str1, str2, n)

Dummy Plural Translation wrapper, just returning the singular or plural string.

yum.i18n.utf8_width(msg)

Get the textual width of a utf8 string.

yum.i18n.utf8_width_chop(msg, chop=None)

Return the textual width of a utf8 string, chopping it to a specified value. This is what you want to use instead of %.*s, as it does the “right” thing with regard to utf-8 sequences. Eg. “%.*s” % (10, msg) <= becomes => “%s” % (utf8_width_chop(msg, 10))

yum.i18n.utf8_width_fill(msg, fill, chop=None, left=True, prefix='', suffix='')

Expand a utf8 msg to a specified “width” or chop to same. Expansion can be left or right. This is what you want to use instead of %*.*s, as it does the “right” thing with regard to utf-8 sequences. prefix and suffix should be used for “invisible” bytes, like highlighting. Eg. “%-*.*s” % (10, 20, msg)

<= becomes =>

“%s” % (utf8_width_fill(msg, 10, 20)).

“%20.10s” % (msg)
<= becomes =>

“%s” % (utf8_width_fill(msg, 20, 10, left=False)).

“%s%.10s%s” % (prefix, msg, suffix)
<= becomes =>

“%s” % (utf8_width_fill(msg, 0, 10, prefix=prefix, suffix=suffix)).

yum.i18n.utf8_valid(msg)

Return True/False is the text is valid utf8.

yum.i18n.utf8_text_wrap(text, width=70, initial_indent='', subsequent_indent='')

Works like we want textwrap.wrap() to work, uses utf-8 data and doesn’t screw up lists/blocks/etc.

yum.i18n.utf8_text_fill(text, *args, **kwargs)

Works like we want textwrap.fill() to work, uses utf-8 data and doesn’t screw up lists/blocks/etc.

yum.i18n.to_unicode(obj, encoding='utf-8', errors='replace')

convert a ‘str’ to ‘unicode’

yum.i18n.to_utf8(obj, errors='replace')

convert ‘unicode’ to an encoded utf-8 byte string

yum.i18n.to_unicode_maybe(obj, encoding='utf-8', errors='replace')

Don’t ask don’t tell, only use when you must

yum.i18n.to_str(obj)

Convert something to a string, if it isn’t one.

yum.i18n.str_eq(a, b)

convert between unicode and not and compare them, w/o warning or being annoying

yum.i18n.exception2msg(e)

Convert an exception to a message. This function will convert the exception using to_unicode, unicode, or str, whichever works correctly.

Parameters:e – an exception
Returns:a string representation of the exception

Previous topic

yum.history

Next topic

yum.logginglevels

This Page