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
typing
functools0
base640
transport0
types0
protocol0
protocol = 'http://fault.io/protocol/status/frames'
protocol = "http://fault.io/protocol/status/frames"
ttyn_data_url0
ttyn_data_url = b'data:text/plain;charset=utf-8;base64,'
compose0types.Frame
compose(ftype, synopsis)
Create a status frame using the envelope's symbol and synopsis.
_frame_pack_extension0bytes
_frame_pack_extension(data)
_frame_unpack_extension0object
_frame_unpack_extension(data)
type_codes0
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_code0int
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_string0str
type_identifier_string(typcode)
Convert an integer type code into the two-character string used for serialization and display.
_ttyn_signature0
_ttyn_signature = "\x1b]\x03\x1b\\"
_ttyn_open_url0
_ttyn_open_url = "\x1b[34;2m" "\x1b]8;;"
_ttyn_close_url0
_ttyn_close_url = "\x1b\\"
_ttyn_reset_url0
_ttyn_reset_url = "\x1b]8;;" "\x1b\\" "\x1b[39;22m"
_frame_open0
_frame_open = "[{ts} "
_frame_exit0
_frame_exit = "]\n"
_loaded_frame_start0
_loaded_frame_start = _frame_open + "{image}"
_loaded_frame_partition0
_loaded_frame_partition = " ({channel}{open}"
_loaded_frame_stop0
_loaded_frame_stop = "{finish}{signal}{size}{close}" + _ttyn_signature + ")]\n"
_empty_frame_stop0
_empty_frame_stop = _ttyn_signature + "]\n"
_pack196%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.
sequence0str
sequence(frame)
Pack a status frame into a str for transmission.
Constructs a single str instance.
sequenceParameters
_unpack973%types.Frame
_unpack(line, offset, limit)
Unpack a serialized status frame.
structure0types.Frame
structure(line)
Extract a status frame, fault.status.types.Frame, from the given line.
structureParameters
declaration0
declaration()
Construct a custom protocol declaration message.
tty_notation_1_message0
tty_notation_1_message = declaration()
tty_notation_1_string0
tty_notation_1_string = "[!? " + tty_notation_1_message.f_event.abstract + "]\n"
message_directed_areas0
message_directed_areas(fields, start, end)
Return the slices marking the areas before and after the first item contained in arrows.