Package docutils :: Module statemachine :: Class StateMachineWS
[show private | hide private]
[frames | no frames]

Class StateMachineWS

StateMachine --+
               |
              StateMachineWS

Known Subclasses:
NestedStateMachine, RSTStateMachine, SearchStateMachineWS

StateMachine subclass specialized for whitespace recognition.

There are three methods provided for extracting indented text blocks:


Method Summary
  get_first_known_indented(self, indent, until_blank, strip_indent, strip_top)
Return an indented block and info.
  get_indented(self, until_blank, strip_indent)
Return a block of indented lines of text, and info.
  get_known_indented(self, indent, until_blank, strip_indent)
Return an indented block and info.
    Inherited from StateMachine
  __init__(self, state_classes, initial_state, debug)
Initialize a StateMachine object; add state objects.
  abs_line_number(self)
Return line number of current line (counting from 1).
  abs_line_offset(self)
Return line offset of current line, from beginning of file.
  add_state(self, state_class)
Initialize & add a state_class (State subclass) object.
  add_states(self, state_classes)
Add state_classes (a list of State subclasses).
  at_bof(self)
Return 1 if the input is at or before beginning-of-file.
  at_eof(self)
Return 1 if the input is at or past end-of-file.
  attach_observer(self, observer)
The observer parameter is a function or bound method which takes two arguments, the source and offset of the current line.
  check_line(self, context, state, transitions)
Examine one line of input for a transition match & execute its method.
  detach_observer(self, observer)
  error(self)
Report error details.
  get_state(self, next_state)
Return current state object; set it first if next_state given.
  get_text_block(self, flush_left)
Return a contiguous block of text.
  goto_line(self, line_offset)
Jump to absolute line offset line_offset, load and return it.
  insert_input(self, input_lines, source)
  is_next_line_blank(self)
Return 1 if the next line is blank or non-existant.
  match(self, pattern)
Return the result of a regular expression match.
  next_line(self, n)
Load self.line with the n'th next line and return it.
  notify_observers(self)
  previous_line(self, n)
Load self.line with the n'th previous line and return it.
  run(self, input_lines, input_offset, context, input_source)
Run the state machine on input_lines.
  runtime_init(self)
Initialize self.states.
  unlink(self)
Remove circular references to objects no longer required.

Method Details

get_first_known_indented(self, indent, until_blank=0, strip_indent=1, strip_top=1)

Return an indented block and info.

Extract an indented block where the indent is known for the first line and unknown for all other lines.

Parameters:
indent - The first line's indent (# of columns/characters).
until_blank - Stop collecting at the first blank line if true (1).
strip_indent - Strip indent characters of indentation if true (1, default).
strip_top - Strip blank lines from the beginning of the block.
Returns:
  • the indented block,
  • its indent,
  • its first line offset from BOF, and
  • whether or not it finished with a blank line.

get_indented(self, until_blank=0, strip_indent=1)

Return a block of indented lines of text, and info.

Extract an indented block where the indent is unknown for all lines.

Parameters:
until_blank - Stop collecting at the first blank line if true (1).
strip_indent - Strip common leading indent if true (1, default).
Returns:
  • the indented block (a list of lines of text),
  • its indent,
  • its first line offset from BOF, and
  • whether or not it finished with a blank line.

get_known_indented(self, indent, until_blank=0, strip_indent=1)

Return an indented block and info.

Extract an indented block where the indent is known for all lines. Starting with the current line, extract the entire text block with at least indent indentation (which must be whitespace, except for the first line).

Parameters:
indent - The number of indent columns/characters.
until_blank - Stop collecting at the first blank line if true (1).
strip_indent - Strip indent characters of indentation if true (1, default).
Returns:
  • the indented block,
  • its first line offset from BOF, and
  • whether or not it finished with a blank line.

Generated by Epydoc 2.0 on Tue Jul 22 05:30:49 2003 http://epydoc.sf.net