python-igraph API reference

List of all classes, functions and methods in python-igraph

class documentation

class TerminalController:

View In Hierarchy

A class that can be used to portably generate formatted output to a terminal.

`TerminalController` defines a set of instance variables whose values are initialized to the control sequence necessary to perform a given action. These can be simply included in normal output to the terminal:

>>> term = TerminalController()
>>> print('This is '+term.GREEN+'green'+term.NORMAL)
This is green

Alternatively, the `render()` method can used, which replaces '${action}' with the string required to perform 'action':

>>> term = TerminalController()
>>> print(term.render('This is ${GREEN}green${NORMAL}'))
This is green

If the terminal doesn't support a given action, then the value of the corresponding instance variable will be set to ''. As a result, the above code will still work on terminals that do not support color, except that their output will not be colored. Also, this means that you can test whether the terminal supports a given action by simply testing the truth value of the corresponding instance variable:

>>> term = TerminalController()
>>> if term.CLEAR_SCREEN:
...     print 'This terminal supports clearning the screen.'
...

Finally, if the width and height of the terminal are known, then they will be stored in the `COLS` and `LINES` attributes.

AuthorEdward Loper
Class Variable BOL Undocumented
Class Variable UP Undocumented
Class Variable DOWN Undocumented
Class Variable LEFT Undocumented
Class Variable RIGHT Undocumented
Class Variable CLEAR_SCREEN Undocumented
Class Variable CLEAR_EOL Undocumented
Class Variable CLEAR_BOL Undocumented
Class Variable CLEAR_EOS Undocumented
Class Variable BOLD Undocumented
Class Variable BLINK Undocumented
Class Variable DIM Undocumented
Class Variable REVERSE Undocumented
Class Variable NORMAL Undocumented
Class Variable HIDE_CURSOR Undocumented
Class Variable SHOW_CURSOR Undocumented
Instance Variable COLS Undocumented
Instance Variable LINES Undocumented
Class Variable BLACK Undocumented
Class Variable BLUE Undocumented
Class Variable GREEN Undocumented
Class Variable CYAN Undocumented
Class Variable RED Undocumented
Class Variable MAGENTA Undocumented
Class Variable YELLOW Undocumented
Class Variable WHITE Undocumented
Class Variable BG_BLACK Undocumented
Class Variable BG_BLUE Undocumented
Class Variable BG_GREEN Undocumented
Class Variable BG_CYAN Undocumented
Class Variable BG_RED Undocumented
Class Variable BG_MAGENTA Undocumented
Class Variable BG_YELLOW Undocumented
Class Variable BG_WHITE Undocumented
Method __init__ No summary
Method render Replace each $-substitutions in the given template string with the corresponding terminal control string (if it's defined) or '' (if it's not).
Class Variable _STRING_CAPABILITIES Undocumented
Class Variable _COLORS Undocumented
Class Variable _ANSICOLORS Undocumented
Static Method _tigetstr Rewrites string capabilities to remove "delays" which are not required for modern terminals
Static Method _tparm Undocumented
Method _render_sub Helper function for render
BOL =

Undocumented

(type: str)
UP =

Undocumented

(type: str)
DOWN =

Undocumented

(type: str)
LEFT =

Undocumented

(type: str)
RIGHT =

Undocumented

(type: str)
CLEAR_SCREEN =

Undocumented

(type: str)
CLEAR_EOL =

Undocumented

(type: str)
CLEAR_BOL =

Undocumented

(type: str)
CLEAR_EOS =

Undocumented

(type: str)
BOLD =

Undocumented

(type: str)
BLINK =

Undocumented

(type: str)
DIM =

Undocumented

(type: str)
REVERSE =

Undocumented

(type: str)
NORMAL =

Undocumented

(type: str)
HIDE_CURSOR =

Undocumented

(type: str)
SHOW_CURSOR =

Undocumented

(type: str)
COLS =

Undocumented

LINES =

Undocumented

BLACK =

Undocumented

(type: str)
BLUE =

Undocumented

(type: str)
GREEN =

Undocumented

(type: str)
CYAN =

Undocumented

(type: str)
RED =

Undocumented

(type: str)
MAGENTA =

Undocumented

(type: str)
YELLOW =

Undocumented

(type: str)
WHITE =

Undocumented

(type: str)
BG_BLACK =

Undocumented

(type: str)
BG_BLUE =

Undocumented

(type: str)
BG_GREEN =

Undocumented

(type: str)
BG_CYAN =

Undocumented

(type: str)
BG_RED =

Undocumented

(type: str)
BG_MAGENTA =

Undocumented

(type: str)
BG_YELLOW =

Undocumented

(type: str)
BG_WHITE =

Undocumented

(type: str)
_STRING_CAPABILITIES =

Undocumented

_COLORS =

Undocumented

_ANSICOLORS =

Undocumented

def __init__(self, term_stream=sys.stdout):

Create a `TerminalController` and initialize its attributes with appropriate values for the current terminal. `term_stream` is the stream that will be used for terminal output; if this stream is not a tty, then the terminal is assumed to be a dumb terminal (i.e., have no capabilities).

@staticmethod
def _tigetstr(cap_name):

Rewrites string capabilities to remove "delays" which are not required for modern terminals

@staticmethod
def _tparm(cap_name, param):

Undocumented

def render(self, template):

Replace each $-substitutions in the given template string with the corresponding terminal control string (if it's defined) or '' (if it's not).

def _render_sub(self, match):

Helper function for render

API Documentation for python-igraph, generated by pydoctor 21.2.2 at 2021-03-26 11:21:53.