class documentation

class TextWrapper(textwrap.TextWrapper):

View In Hierarchy

Custom subclass that uses a different word separator regex.
Method ​_break​_word _break_word(word : string, space_left : int) -> (string, string)
Method ​_handle​_long​_word _handle_long_word(chunks : [string], cur_line : [string], cur_len : int, width : int)
Method ​_split _split(text : string) -> [string]
Method ​_wrap​_chunks _wrap_chunks(chunks : [string]) -> [string]
Class Variable wordsep​_re Undocumented
def _break_word(self, word, space_left):

_break_word(word : string, space_left : int) -> (string, string)

Break line by unicode width instead of len(word).

Parameters
word:strUndocumented
space​_left:intUndocumented
Returns
Tuple[str, str]Undocumented
def _handle_long_word(self, reversed_chunks, cur_line, cur_len, width):
_handle_long_word(chunks : [string],
cur_line : [string], cur_len : int, width : int)

Override original method for using self._break_word() instead of slice.

Parameters
reversed​_chunks:List[str]Undocumented
cur​_line:List[str]Undocumented
cur​_len:intUndocumented
width:intUndocumented
def _split(self, text):

_split(text : string) -> [string]

Override original method that only split by 'wordsep_re'. This '_split' splits wide-characters into chunks by one character.

Parameters
text:strUndocumented
Returns
List[str]Undocumented
def _wrap_chunks(self, chunks):

_wrap_chunks(chunks : [string]) -> [string]

The original _wrap_chunks uses len() to calculate width. This method respects wide/fullwidth characters for width adjustment.

Parameters
chunks:List[str]Undocumented
Returns
List[str]Undocumented
wordsep_re =

Undocumented