ape.parts.helppage.helppage.HelpPage

class ape.parts.helppage.helppage.HelpPage(sections, headers=None, wrap=70, pager='less -R', body_indent=' ', add_formatting=True)

A class to construct and print help-pages.

HelpPage constructor

Param:
  • sections: a dict of header: section-text
  • headers : a list of keys for the sections (in the order you want them)
  • wrap: Maximum width for the output
  • pager: Command to pipe the output to
  • body_indent: string to use to indent the section-text
  • add_formatting: If False, print without ANSI codes
__init__(sections, headers=None, wrap=70, pager='less -R', body_indent=' ', add_formatting=True)

HelpPage constructor

Param:
  • sections: a dict of header: section-text
  • headers : a list of keys for the sections (in the order you want them)
  • wrap: Maximum width for the output
  • pager: Command to pipe the output to
  • body_indent: string to use to indent the section-text
  • add_formatting: If False, print without ANSI codes

Methods

__init__(sections[, headers, wrap, pager, ...]) HelpPage constructor
log_error(error[, message]) Logs the error in bold red

Attributes

bold_headers A dictionary of header: formatted bold header
command List of strings to send to the Popen
formatted_text A dictionary of header:formatted body text
formatting Dictionary of format-name: ANSI code
headers The headers for the text
logger
return:A logging object.
text The concatenated and formatted text
text_wrapper TextWrapper to fill the text
log_error(error, message='')

Logs the error in bold red

Param:
  • error: error type (prefix in red and bold)
  • message: descriptive message (red but not bold)
bold_headers

A dictionary of header: formatted bold header

command

List of strings to send to the Popen

formatted_text

A dictionary of header:formatted body text

formatting

Dictionary of format-name: ANSI code

headers

The headers for the text

logger
Returns:A logging object.
text

The concatenated and formatted text

text_wrapper

TextWrapper to fill the text

Navigation