class documentation

class StringList(ViewList): (source)

View In Hierarchy

A ViewList with string-specific methods.
Method get_2​D_block Undocumented
Method get​_indented Extract and return a StringList of indented lines of text.
Method get​_text​_block Return a contiguous block of text.
Method pad​_double​_width Pad all double-width characters in self by appending pad_char to each. For East Asian language support.
Method replace Replace all occurrences of substring old with new.
Method trim​_left Trim length characters off the beginning of each item, in-place, from index start to end. No whitespace-checking is done on the trimmed text. Does not affect slice parent.

Inherited from ViewList:

Method __add__ Undocumented
Method __cmp__ Undocumented
Method __contains__ Undocumented
Method __delitem__ Undocumented
Method __eq__ Undocumented
Method __ge__ Undocumented
Method __getitem__ Undocumented
Method __gt__ Undocumented
Method __iadd__ Undocumented
Method __imul__ Undocumented
Method __init__ Undocumented
Method __le__ Undocumented
Method __len__ Undocumented
Method __lt__ Undocumented
Method __mul__ Undocumented
Method __ne__ Undocumented
Method __radd__ Undocumented
Method __repr__ Undocumented
Method __setitem__ Undocumented
Method __str__ Undocumented
Method append Undocumented
Method count Undocumented
Method disconnect Break link between this list and parent list.
Method extend Undocumented
Method index Undocumented
Method info Return source & offset for index i.
Method insert Undocumented
Method offset Return offset for index i.
Method pop Undocumented
Method pprint Print the list in grep format (source:offset:value lines)
Method remove Undocumented
Method reverse Undocumented
Method sort Undocumented
Method source Return source for index i.
Method trim​_end Remove items from the end of the list, without touching the parent.
Method trim​_start Remove items from the start of the list, without touching the parent.
Method xitems Return iterator yielding (source, offset, value) tuples.
Instance Variable data The actual list of data, flattened from various sources.
Instance Variable items A list of (source, offset) pairs, same length as self.data: the source of each line and the offset of each line from the beginning of its source.
Instance Variable parent The parent list.
Instance Variable parent​_offset Offset of this list from the beginning of the parent list.
Method __cast Undocumented
def get_2D_block(self, top, left, bottom, right, strip_indent=True): (source)

Undocumented

def get_indented(self, start=0, until_blank=False, strip_indent=True, block_indent=None, first_indent=None): (source)

Extract and return a StringList of indented lines of text.

Collect all lines with indentation, determine the minimum indentation, remove the minimum indentation from all indented lines (unless strip_indent is false), and return them. All lines up to but not including the first unindented line will be returned.

Parameters
startThe index of the first line to examine.
until​_blankStop collecting at the first blank line if true.
strip​_indentStrip common leading indent if true (default).
block​_indentThe indent of the entire block, if known.
first​_indentThe indent of the first line, if known.
Returns
  • a StringList of indented lines with mininum indent removed;
  • the amount of the indent;
  • a boolean: did the indented block finish with a blank line or EOF?
def get_text_block(self, start, flush_left=False): (source)

Return a contiguous block of text.

If flush_left is true, raise UnexpectedIndentationError if an indented line is encountered before the text block ends (with a blank line).

def pad_double_width(self, pad_char): (source)
Pad all double-width characters in self by appending pad_char to each. For East Asian language support.
def replace(self, old, new): (source)
Replace all occurrences of substring old with new.
def trim_left(self, length, start=0, end=sys.maxsize): (source)
Trim length characters off the beginning of each item, in-place, from index start to end. No whitespace-checking is done on the trimmed text. Does not affect slice parent.