frames1091%python.module
fault.status

Formatting and parsing tools for status frame transport envelopes.

This module provides conceptual definitions for Status Frame events (fault.status.types.EStruct) and I/O operations supporting the transmission of those events.

Status Frames are fault.status.types.Frame instances that can be serialized into and parsed from a data stream.

Usage

The operation used to serialize and load the data extension is decoupled, so an allocation function is provided to apply the defaults for the data extension transport:

from fault.status import frames

Frame envelopes may or may not have content (data extensions):

msg = compose('!#', "ERROR: no such resource")
sys.stdout.write(frames.sequence(msg))

"[!# ERROR: no such resource]

"

Serialized messages are expected to include the trailing newline:

for line in sys.stdin.readlines():
	msg = frames.structure(line)

Properties

protocol

String identifying the status frames (event) protocol.

typing
import

functools0
import

base640
import

transport0
import

types0
import

protocol0
data

protocol = 'http://fault.io/protocol/status/frames'
protocol = "http://fault.io/protocol/status/frames"

ttyn_data_url0
data

ttyn_data_url = b'data:text/plain;charset=utf-8;base64,'

compose0
function
types.Frame

compose(ftype, synopsis)

Create a status frame using the envelope's symbol and synopsis.

_frame_pack_extension0
function
bytes

_frame_pack_extension(data)

_frame_unpack_extension0
function
object

_frame_unpack_extension(data)

type_codes0
data

type_codes = {
	# [!? PROTOCOL: http://fault.io/protocol/status/frames tty-notation-1]
	"!?": 'message-protocol',
	"!&": 'reference',

	# Abstract Transaction progress.
	"><": 'transaction-failed',
	"<>": 'transaction-executed',
	"->": 'transaction-started',
	"--": 'transaction-event',
	"<-": 'transaction-stopped',

	# Warnings, Errors, and Information with respect to some conceptual level of a frame source.
	"!#": 'message-application',
	"!*": 'message-framework',
	"!~": 'message-trace',

	# Messages sent by user entities.
	"!%": 'message-administrative',
	"!>": 'message-entity',

	# Resource Content Manipulations
	"+=": 'elements-inserted', # Added
	"-=": 'elements-deleted', # Removed
	"Δ=": 'elements-delta', # Compound Change
	"<=": 'elements-reverted',
	"==": 'elements-committed',

	# Resource Container Manipulations
	"+.": 'resource-initialized',
	"-.": 'resource-deleted',
	"±.": 'resource-relocated',
	"*.": 'resource-replicated',
	"&.": 'resource-referenced',
	"=.": 'resource-rewritten',
	"Δ.": 'resource-delta', # Property/metadata changes.

	# Archive I/O
	"^*": 'archive-extraction-replicated',
	"^+": 'archive-extraction-replicated-merge',

	"√*": 'archive-delta-replicated-into',
	"√+": 'archive-delta-merged-into',
	"√-": 'archive-delta-deleted',
	"√&": 'archive-delta-referenced',

	# Transfer Snapshots.
	"↑.": 'resource-transmitted',
	"↓.": 'resource-received',

	# Transfer Progress Information.
	"↑:": 'data-transmitted',
	"↓:": 'data-received',
	"↓↑": 'data-transferred',
}

@functools.lru_cache(16)

type_integer_code0
function
int

type_integer_code(typstring)

Convert a two-character type code symbol into an unsigned 32-bit integer. Currently, only supporting unicode characters in the 16-bit range.

type_identifier_string0
function
str

type_identifier_string(typcode)

Convert an integer type code into the two-character string used for serialization and display.

_ttyn_signature0
data

_ttyn_signature = "\x1b]\x03\x1b\\"

_ttyn_open_url0
data

_ttyn_open_url = "\x1b[34;2m" "\x1b]8;;"

_ttyn_close_url0
data

_ttyn_close_url = "\x1b\\"

_ttyn_reset_url0
data

_ttyn_reset_url = "\x1b]8;;" "\x1b\\" "\x1b[39;22m"

_frame_open0
data

_frame_open = "[{ts} "

_frame_exit0
data

_frame_exit = "]\n"

_loaded_frame_start0
data

_loaded_frame_start = _frame_open + "{image}"

_loaded_frame_partition0
data

_loaded_frame_partition = " ({channel}{open}"

_loaded_frame_stop0
data

_loaded_frame_stop = "{finish}{signal}{size}{close}" + _ttyn_signature + ")]\n"

_empty_frame_stop0
data

_empty_frame_stop = _ttyn_signature + "]\n"

_pack196%
function
typing.Tuple[str, bytes, str]

_pack(frame)

Pack a status frame for transmission.

Constructs a triple containing the leading envelope string, the encoded bytes of data extending the frame and the terminating trailer.

sequence0
function
str

sequence(frame)

Pack a status frame into a str for transmission.

Constructs a single str instance.

sequenceParameters

frame

The status frame to be represented in serial form.

channel

Undocumented.

_unpack973%
function
types.Frame

_unpack(line, offset, limit)

Unpack a serialized status frame.

structure0
function
types.Frame

structure(line)

Extract a status frame, fault.status.types.Frame, from the given line.

structureParameters

line

A single serialized line.

declaration0
function

declaration()

Construct a custom protocol declaration message.

tty_notation_1_message0
data

tty_notation_1_message = declaration()

tty_notation_1_string0
data

tty_notation_1_string = "[!? " + tty_notation_1_message.f_event.abstract + "]\n"

message_directed_areas0
function

message_directed_areas(fields, start, end)

Return the slices marking the areas before and after the first item contained in arrows.

None if no items in fields are contained in arrows.