Skip to content

vtf io modem

srccircumflex edited this page Apr 24, 2023 · 5 revisions

↑ vtf-io

modem

The module contains concepts for the complete processing of inputs. These are based on the input types from io and uses the binder module.

Module contents

Objects

class modem.InputModem(Input)

Input type as an overall concept for processing inputs via stdin.

When the thread is started, inputs are continuously read from stdin, parsed/interpreted and passed to the binder.

stdin --> interpreter --> [ SpamHandler ] --> binder

The send method is also an indirect interface from input to the binder.

See also documentation of Input and Binder

__binder__: Binder

__init__(thread_smoothness=.003, thread_block=False, thread_spam=SpamHandle(), mod=True, find_all_bindings=False, find_instance_bindings_only=False, find_class_bindings_first=False, use_alter_bindings=False)

run() -> None

Read with or without blocking (self.t_block) while self.t_keepalive is True and send the objects to the binder. Wait self.t_smoothness seconds in an iteration if self.t_block is False.

stdin --> interpreter --> [ SpamHandler ] --> binder

send(block=False) -> bool

Read with or without blocking and send the object to the binder.

Returns whether something was executed

class modem.InputSuperModem(InputSuper)

InputSuper type as an overall concept for processing inputs via stdin.

When the thread is started, inputs are continuously read from stdin, parsed/interpreted and passed to the binder.

adapter --> interpreter --> [ SpamHandler ] --> binder

The send method is also an indirect interface from input to the binder.

See also documentation of InputSuper and Binder.

__binder__: Binder

__init__(thread_smoothness=.003, thread_block=False, thread_spam=SpamHandle(), manual_esc_tt=.8, manual_esc_finals=(0xa, 0xd, 0x1b), find_all_bindings=False, find_instance_bindings_only=False, find_class_bindings_first=False, use_alter_bindings=False)

run() -> None

Read with or without blocking (self.t_block) while self.t_keepalive is True and send the objects to the binder. Wait self.t_smoothness seconds in an iteration if self.t_block is False.

stdin --> adapter --> interpreter --> [ SpamHandler ] --> binder

Recognize and supervise manual input of esc.

send(block=False) -> bool

Read with or without blocking and send the object to the binder.

Returns whether something was executed

class modem.InputRouter(Thread)

This object offers a central handling for several InputModem | InputSuperModem objects.

If the thread is started, inputs are processed from the modem defined as current_modem continuously. The method send is also oriented to the current_modem and processes one input [ in blocking mode ].

Before any of the actions can be performed, entries must be entered and switch_gate must be executed a first time. Entries can be created during the initialization or afterwards via methods.

>>> router = InputRouter(main_modem=<InputModem>)
>>>
>>> router.setdefault_table_entry(42, <InputSuperModem>)
>>> router[object] = <InputModem>
>>>
>>> router.switch_gate("main_modem")
>>>
>>> router.start(daemon=True)

current_modem: InputModem | InputSuperModem

t_block: bool

t_keepalive: bool

t_smoothness: float

__contains__(entry) -> bool

entry in table

__delitem__(entry) -> None

del router[modem entry]

raises:
  • KeyError(entry)

__getitem__(entry) -> InputModem | InputSuperModem

modem = router[modem entry]

raises:
  • KeyError(entry)

__init__(thread_smoothness=.003, thread_block=False, **modems)

The thread loop can be slowed down for a smoother run over thread_smoothness. If thread_block is True, this parameter is ignored and blocking read from stdin is enabled.

__setitem__(entry, modem) -> None

router[modem entry] = modem

add_table_entry(entry, modem) -> None

Add a table entry.

raises:
  • KeyError(entry): entry is already set

entries() -> Iterable[Hashable]

Iterable[entry keys]

modems() -> Iterable[InputModem | InputSuperModem]

Iterable[modems]

pop_table_entry(entry) -> InputModem | InputSuperModem | None

Pop an entry from the table. Returns the modem entry or None.

run() -> None

Process inputs from stdin [ in blocking mode (self.t_block) ] by the modem defined as current_modem while self.t_keepalive is True . Wait self.t_smoothness seconds in an iteration if self.t_block is False.

send(block=False) -> bool

Process an input from stdin by the current_modem [ in blocking mode ].

set_table_entry(entry, modem) -> None

Set a table entry.

setdefault_table_entry(entry, modem) -> bool

Set default table entry.

Returns whether the entry was free and modem was thus set.

start(*, daemon=True) -> None

[Re-]Start the thread [ as daemon ].

stop() -> None

Stop the thread loop in self.run.

switch_gate(entry) -> None

set current_modem

table_items() -> Iterable[tuple[Hashable, InputModem | InputSuperModem]]

Iterable[(entry key, modem)]

Date: 15 Nov 2022
Version: 0.1
Author: Adrian Hoefflin [srccircumflex]
Doc-Generator: "pyiStructure-RSTGenerator" <prototype>
Clone this wiki locally