grepros 1.3.0
grep for ROS bag files and live topics
Loading...
Searching...
No Matches
TextWrapper Class Reference
Inheritance diagram for TextWrapper:
Inheritance graph

Public Member Functions

 __init__ (self, width=80, subsequent_indent=" ", break_long_words=True, drop_whitespace=False, max_lines=None, placeholder=" ...", custom_widths=None)
 
 reserve_width (self, reserved="")
 
 strip (self, v)
 
 strlen (self, v)
 
 wrap (self, text)
 

Public Attributes

 break_long_words
 
 custom_lens
 
 custom_rgx
 
 customs
 
 disabled
 
 drop_whitespace
 
 lencache
 
 max_lines
 
 minwidth
 
 placeholder
 
 realwidth
 
 subsequent_indent
 
 width
 

Static Public Attributes

int LENCACHEMAX = 10000
 Max length of strlen cache.
 
 SPACE_RGX = re.compile(r"([%s]+)" % re.escape("\t\n\x0b\x0c\r "))
 Regex for breaking text at whitespace.
 

Detailed Description

TextWrapper that supports custom substring widths in line width calculation.

Intended for wrapping text containing ANSI control codes.
Heavily refactored from Python standard library textwrap.TextWrapper.

Definition at line 674 of file common.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self,
  width = 80,
  subsequent_indent = "  ",
  break_long_words = True,
  drop_whitespace = False,
  max_lines = None,
  placeholder = " ...",
  custom_widths = None 
)
@param   width              default maximum width to wrap at, 0 disables
@param   subsequent_indent  string prepended to all consecutive lines
@param   break_long_words   break words longer than width
@param   drop_whitespace    drop leading and trailing whitespace from lines
@param   max_lines          count to truncate lines from
@param   placeholder        appended to last retained line when truncating
@param   custom_widths      {substring: len} to use in line width calculation

Definition at line 689 of file common.py.

Member Function Documentation

◆ reserve_width()

reserve_width (   self,
  reserved = "" 
)
Decreases the configured width by given amount (number or string).

Definition at line 739 of file common.py.

◆ strip()

strip (   self,
  v 
)
Returns string with custom substrings and whitespace stripped.

Definition at line 752 of file common.py.

◆ strlen()

strlen (   self,
  v 
)
Returns length of string, using custom substring widths.

Definition at line 745 of file common.py.

◆ wrap()

wrap (   self,
  text 
)
Returns a list of wrapped text lines, without linebreaks.

Definition at line 718 of file common.py.

Member Data Documentation

◆ break_long_words

break_long_words

Definition at line 702 of file common.py.

◆ custom_lens

custom_lens

Definition at line 709 of file common.py.

◆ custom_rgx

custom_rgx

Definition at line 710 of file common.py.

◆ customs

customs

Definition at line 708 of file common.py.

◆ disabled

disabled

Definition at line 711 of file common.py.

◆ drop_whitespace

drop_whitespace

Definition at line 703 of file common.py.

◆ lencache

lencache

Definition at line 707 of file common.py.

◆ LENCACHEMAX

int LENCACHEMAX = 10000
static

Max length of strlen cache.

Definition at line 686 of file common.py.

◆ max_lines

max_lines

Definition at line 704 of file common.py.

◆ minwidth

minwidth

Definition at line 712 of file common.py.

◆ placeholder

placeholder

Definition at line 705 of file common.py.

◆ realwidth

realwidth

Definition at line 715 of file common.py.

◆ SPACE_RGX

SPACE_RGX = re.compile(r"([%s]+)" % re.escape("\t\n\x0b\x0c\r "))
static

Regex for breaking text at whitespace.

Definition at line 683 of file common.py.

◆ subsequent_indent

subsequent_indent

Definition at line 701 of file common.py.

◆ width

width

Definition at line 700 of file common.py.


The documentation for this class was generated from the following file: