terminal6085%python.module
fault.transcript

Terminal support for status displays.

os
import

io0
import

typing0
import

itertools0
import

collections0
import

tools0
import

frames0
import

duration_repr827%
function
typing.Tuple[float, str]

duration_repr(seconds)

Phrase
class

Phrase__slots__0
data

__slots__ = ()

Phrasecellcount0
method

cellcount(self)

Legacy0
class

Abstraction for legacy ANSI/DEC escapes.

Legacy_escape0
data

_escape = b'\x1b'

Legacy_csi_open0
data

_csi_open = _escape + b'['

Legacy_pm_open0
data

_pm_open = _csi_open + b'?'

Legacy_pm_save0
data

_pm_save = _pm_open + b'6;1049s'

Legacy_pm_restore0
data

_pm_restore = _pm_open + b'6;1049r'

Legacy_pm_origin_set0
data

_pm_origin_set = _pm_open + b'6h'

Legacy_pm_origin_reset0
data

_pm_origin_reset = _pm_open + b'6l'

Legacy_pm_screen_set0
data

_pm_screen_set = _pm_open + b'1049h'

Legacy_pm_screen_reset0
data

_pm_screen_reset = _pm_open + b'1049l'

Legacy_pm_show_cursor0
data

_pm_show_cursor = _pm_open + b'25h'

Legacy_pm_hide_cursor0
data

_pm_hide_cursor = _pm_open + b'25l'

Legacy_restore_cursor0
data

_restore_cursor = _escape + b'8'

Legacy_store_cursor0
data

_store_cursor = _escape + b'7'

Legacy_nl0
data

_nl = _csi_open + b'1B'

Legacy_reset_sgr0
data

_reset_sgr = _csi_open + b'0;39;49;59m'

Legacy_styles0
data

_styles = {
	'default': b'39',
	'black': b'30',
	'red': b'31',
	'green': b'32',
	'yellow': b'33',
	'blue': b'34',
	'magenta': b'35',
	'cyan': b'36',
	'white': b'37',
		'orange': b'38;5;208',
	'violet': b'38;5;135',
	'teal': b'38;5;23',
	'purple': b'38;5;93',
	'dark': b'38;5;236',
	'gray': b'38;5;241',
}

Legacy_reset_text0
data

_reset_text = _csi_open + _styles['default'] + b'm'
	@classmethod

Legacy_join0
classmethod

_join(Class, *i)

Legacy__init__0
method

__init__(self)

Legacyset_cursor_visible0
method

set_cursor_visible(self, visible)

Adjust cursor visibility.

Legacyset_scrolling_region0
method

set_scrolling_region(self, top, bottom)

Confine the scrolling region to the given rows.

Legacyreset_scrolling_region0
method

reset_scrolling_region(self)

Release confinements on scrolling region.

Legacyopen_scrolling_region0
method

open_scrolling_region(self, top, bottom)

Set the scrolling region, enter it, and seek the bottom. Subsequent exit_scrolling_region and enter_scrolling_region should be use to maintain the SR's state.

Legacyclose_scrolling_region0
method

close_scrolling_region(self)

Save the screen buffer, reset the scrolling region, and restore the buffer. This preserves the screen's state after the transition.

Legacyenter_scrolling_region0
method

enter_scrolling_region(self)

Enter scrolling region; normal terminal output; restores cursor location.

Legacyexit_scrolling_region0
method

exit_scrolling_region(self)

Exit scrolling region; allow out of region printing; saves cursor location.

Legacyclear0
method

clear(self)

Clear the staionary area according to its configured width and default text properties.

Legacyerase0
method

erase(self, area)

Erase the given area.

Legacyseek0
method
bytes

seek(self, monitor, top_offset, left_offset)

Primitive relative seek; Context cursor position is not updated.

Legacystyle0
method

style(self, name, text)

Style the given text as name.

Text color will be reset to the default.

Legacyrender0
method

render(self, phrase)

Translate the color names to SGR codes.

Legacyconfigure0
method

configure(self, height, width, lines)

Update the dimensions of the screen.

Legacyposition0
property

Layout0
class

The set, sizes, and ordering of fields present in a monitor.

LayoutDefinition0
data

Definition = typing.Tuple[str, int]

LayoutFields0
data

Fields = typing.Sequence[Definition]
	@staticmethod

Layoutseparators0
staticmethod

separators(fields)

Generate a series of separators finished with a terminator. Given a number of a fields, emit separators until the final index is reached.

Layoutlabel0
method

label(self, field, text)

The display text for the field's label.

Layout__init__0
method

__init__(self, fields, **updates)

Layoutfields0
method

fields(self)

Iterate over the fields in their designated order along with separators that can be used to follow the rendered field.

Layoutpositions0
method

positions(self)

Join the field identifier, cell allocation, and field label in the order designated by order.

Theme0
class

The rendering methods and parameters used by a Status.

ThemeFormatter0
data

Formatter = tuple[str, str]

Themedefault_render_method0
method

default_render_method(self, key, field)

Renders the string form of field with the style set identified by key.

Themer_transparent20%
staticmethod

r_transparent(value)

Render method expecting and returning a sequence of formatting pairs.

Used in cases where the field wishes to control theme-relative formatting directly.

Themer_duration0
staticmethod

r_duration(value)

Render method for common duration fields.

Themedefine0
method

define(self, name, style)

Define the style to use with the given name.

Themeimplement0
method

implement(self, type, render)

Assign a render method, call, for the field.

Theme__init__0
method

__init__(self)

Themeconfigure0
method

configure(self)

Themestyle0
method

style(self, celltexts)

Emit words formatted according to their associated style set.

Themerender0
method

render(self, type, field)

Render the given field according to the configured type' render method.

Status0
class

Allocated area for status display of a set of changing fields.

Statusview_state_loop0
data

view_state_loop = {
	'total': 'rate_window',
	'rate_window': 'rate_overall',
	'rate_overall': 'total',
}

Statusunit_type_separators0
data

unit_type_separators = {
	'total': '+',
	'rate_window': '<',
	'rate_overall': '^',
}

Status__init__0
method

__init__(self, theme, layout, position)

Status_calculate_fields190%
method

_calculate_fields(self)

Status_update_field_cache0
method

_update_field_cache(self)

Statusreset0
method

reset(self, time, metrics)

Reset the metrics records using the given entry as the only one.

Statuscurrent0
property

Statuselapse0
method

elapse(self, time)

Update the time field on the last metrics record.

Statusupdate0
method

update(self, time, metrics)

Update the metrics record for the given point in time.

Statusduration0
method

duration(self)

Statuscycle40%
method

cycle(self, field)

Select the next read type for the given field using the view_state_loop.

Statusset_field_read_type166%
method

set_field_read_type(self, field, units)

Statusprefix20%
method

prefix(self, *words)

Attach a constant phrase to the beginning of the monitor.

Statussuffix20%
method

suffix(self, *words)

Attach a constant phrase to the end of the monitor.

Statustitle0
method

title(self, title, *dimensions)

Assign the monitor's title and dimension identifiers.

Statuswindow_period0
method

window_period(self)

Calculate the current metrics window size.

Statusorigin10%
method

origin(self, field)

Statuswindow_delta40%
method

window_delta(self, field)

Statusedge0
method

edge(self, field)

Statustotal0
method

total(self, field)

Statusrate_window0
method

rate_window(self, field)

Statusrate_overall0
method

rate_overall(self, field)

Statusrender0
method

render(self)

Statusdelta190%
method

delta(self, fields)

Statusphrase0
method

phrase(self)

The monitor's image as a single phrase instance.

Statussnapshot0
method

snapshot(self)

A bytes form of the Status.phrase. (The image without cursor movement)

Statusprofile0
method

profile(self)

Construct a triple containing the start and stop time and the final metrics.

Statussynopsis283%
method

synopsis(self)

Construct a status frame synopsis using the monitor's configuration and metrics.

Statusframe0
method

frame(self, control, type, identifier)

Construct a transaction frame for reporting the status. Used after the completion of the dispatcher.

Monitor0
class

Terminal display management for monitoring changes in Status instances.

Monitorrender_status_text0
method
str

render_status_text(self, monitor, identifier)

Construct the string representation of the given monitor' status.

Monitor__init__0
method

__init__(self, screen, fileno)

Monitorinstall0
method

install(self, monitor)

Erase, reframe, and update the given monitor.

Monitorframe469%
method

frame(self, monitor)

Render and emit the prefix, title, and suffix of the monitor.

Operation is buffered and must be flushed to be displayed.

Monitorupdate191%
method

update(self, monitor, fields)

Render and emit the given fields.

Operation is buffered and must be flushed to be displayed.

Monitorflush191%
method

flush(self)

Write any buffered terminal changes to the device.

Monitorclear0
method

clear(self)

Clear the entire status regions.

Monitorconfigure191%
method

configure(self, lines)

Configure the scrolling region allocating lines at the top or bottom of the screen for status display.

This method should be called after window changes of any type. The window size is refreshed from the device; monitors should also be reallocated so that their Context positions can be adjusted.

Monitor_save0
method

_save(self)

Monitor_restore0
method

_restore(self)

_metric_units0
data

_metric_units = [
	('', '', 0),
	('kilo', 'k', 3),
	('mega', 'M', 6),
	('giga', 'G', 9),
	('tera', 'T', 12),
	('peta', 'P', 15),
	('exa', 'E', 18),
	('zetta', 'Z', 21),
	('yotta', 'Y', 24),
]

_precision180%
function

_precision(count)

_strings0
function

_strings(value)

r_count0
function

r_count(field, value)

Render method for counts providing compression using metric units.

r_title0
function

r_title(value)

Render method for monitor titles.

form0
function

form(module)

Construct a Layout and Theme from the provided order and formatting structures.

identify_device60%
function

identify_device()

Use the first three file descriptors to determine the path to the tty device. If no path can be identified, return the given path which defaults to /dev/tty.

setup0
function

setup()

aggregate0
function

aggregate(control, module)

Construct Status instances allocated using control for displaying the aggregate of the dimension allocations.

Returns a sequence of Status instances for the dimensions and a single Status for the aggregation.