GNU Info

Info Node: (python2.1-lib.info)Writer Interface

(python2.1-lib.info)Writer Interface


Next: Writer Implementations Prev: Formatter Implementations Up: formatter
Enter node , (file) or (file)node

The Writer Interface
--------------------

Interfaces to create writers are dependent on the specific writer class
being instantiated.  The interfaces described below are the required
interfaces which all writers must support once initialized.  Note that
while most applications can use the `AbstractFormatter' class as a
formatter, the writer must typically be provided by the application.

`flush()'
     Flush any buffered output or device control events.

`new_alignment(align)'
     Set the alignment style.  The ALIGN value can be any object, but
     by convention is a string or `None', where `None' indicates that
     the writer's "preferred" alignment should be used.  Conventional
     ALIGN values are `'left'', `'center'', `'right'', and `'justify''.

`new_font(font)'
     Set the font style.  The value of FONT will be `None', indicating
     that the device's default font should be used, or a tuple of the
     form `('SIZE, ITALIC, BOLD, TELETYPE`)'.  Size will be a string
     indicating the size of font that should be used; specific strings
     and their interpretation must be defined by the application.  The
     ITALIC, BOLD, and TELETYPE values are boolean indicators
     specifying which of those font attributes should be used.

`new_margin(margin, level)'
     Set the margin level to the integer LEVEL and the logical tag to
     MARGIN.  Interpretation of the logical tag is at the writer's
     discretion; the only restriction on the value of the logical tag
     is that it not be a false value for non-zero values of LEVEL.

`new_spacing(spacing)'
     Set the spacing style to SPACING.

`new_styles(styles)'
     Set additional styles.  The STYLES value is a tuple of arbitrary
     values; the value `AS_IS' should be ignored.  The STYLES tuple may
     be interpreted either as a set or as a stack depending on the
     requirements of the application and writer implementation.

`send_line_break()'
     Break the current line.

`send_paragraph(blankline)'
     Produce a paragraph separation of at least BLANKLINE blank lines,
     or the equivalent.  The BLANKLINE value will be an integer.  Note
     that the implementation will receive a call to `send_line_break()'
     before this call if a line break is needed; this method should not
     include ending the last line of the paragraph.  It is only
     responsible for vertical spacing between paragraphs.

`send_hor_rule(*args, **kw)'
     Display a horizontal rule on the output device.  The arguments to
     this method are entirely application- and writer-specific, and
     should be interpreted with care.  The method implementation may
     assume that a line break has already been issued via
     `send_line_break()'.

`send_flowing_data(data)'
     Output character data which may be word-wrapped and re-flowed as
     needed.  Within any sequence of calls to this method, the writer
     may assume that spans of multiple whitespace characters have been
     collapsed to single space characters.

`send_literal_data(data)'
     Output character data which has already been formatted for
     display.  Generally, this should be interpreted to mean that line
     breaks indicated by newline characters should be preserved and no
     new line breaks should be introduced.  The data may contain
     embedded newline and tab characters, unlike data provided to the
     `send_formatted_data()' interface.

`send_label_data(data)'
     Set DATA to the left of the current left margin, if possible.  The
     value of DATA is not restricted; treatment of non-string values is
     entirely application- and writer-dependent.  This method will only
     be called at the beginning of a line.


automatically generated by info2www version 1.2.2.9