Method summary
- __init__(self, nspace = 4)
- __repr__(self)
- decr(self)
- format(self, txt)
- incr(self)
- reset(self)
- set_tab(self, nspace)
Methods
- __init__(self, nspace = 4)
Initializes the object.
Parameters
nspace : int
Specifies the number of spaces to use for each indentation level. Defaults to 4.
- __repr__(self)
- decr(self)
Decrease the indentation level.
- format(self, txt)
Formats given text as per current indentation levels.
Note that the returned string always ends with a newline to avoid problems for subsequent lines in the output that have to deal trailing garbage in the last line.
Parameters
txt : string
Input text string to be formatted. Can contain newlines.
If the input text is a single line of text then leading space is stripped and the current indentation is added to the left along with a newline and the resulting string is returned.
If the input text is multi-line input the indentation of the first line is ignored, and the second line is considered. All subsequent lines have the current indentation followed by any extra space from the default indentation.
- incr(self)
Increase the indentation level.
- reset(self)
Reset the indentation level to 0.
- set_tab(self, nspace)
Set the number of spaces a tab represents.