OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __init__ (self, indent_increment=2, width=None, max_width=None) |
def | write (self, string) |
def | indent (self) |
def | dedent (self) |
def | write_usage (self, prog, args="", prefix="Usage: ") |
def | write_heading (self, heading) |
def | write_paragraph (self) |
def | write_text (self, text) |
def | write_dl (self, rows, col_max=30, col_spacing=2) |
def | section (self, name) |
def | indentation (self) |
def | getvalue (self) |
Data Fields | |
indent_increment | |
width | |
current_indent | |
buffer | |
This class helps with formatting text-based help pages. It's usually just needed for very special internal cases, but it's also exposed so that developers can write their own fancy outputs. At present, it always writes into memory. :param indent_increment: the additional increment for each level. :param width: the width for the text. This defaults to the terminal width clamped to a maximum of 78.
def __init__ | ( | self, | |
indent_increment = 2 , |
|||
width = None , |
|||
max_width = None |
|||
) |
def dedent | ( | self | ) |
Decreases the indentation.
def getvalue | ( | self | ) |
Returns the buffer contents.
def indent | ( | self | ) |
Increases the indentation.
def indentation | ( | self | ) |
A context manager that increases the indentation.
def section | ( | self, | |
name | |||
) |
Helpful context manager that writes a paragraph, a heading, and the indents. :param name: the section name that is written as heading.
def write | ( | self, | |
string | |||
) |
Writes a unicode string into the internal buffer.
def write_dl | ( | self, | |
rows, | |||
col_max = 30 , |
|||
col_spacing = 2 |
|||
) |
Writes a definition list into the buffer. This is how options and commands are usually formatted. :param rows: a list of two item tuples for the terms and values. :param col_max: the maximum width of the first column. :param col_spacing: the number of spaces between the first and second column.
def write_heading | ( | self, | |
heading | |||
) |
Writes a heading into the buffer.
def write_paragraph | ( | self | ) |
Writes a paragraph into the buffer.
def write_text | ( | self, | |
text | |||
) |
Writes re-indented text into the buffer. This rewraps and preserves paragraphs.
def write_usage | ( | self, | |
prog, | |||
args = "" , |
|||
prefix = "Usage: " |
|||
) |
Writes a usage line into the buffer. :param prog: the program name. :param args: whitespace separated list of arguments. :param prefix: the prefix for the first line.
buffer |
current_indent |
indent_increment |
width |