Skip to content

Commit 28dae23

Browse files
authored
Merge pull request #1397 from ryan-hansen/webbaser
Webbaser
2 parents 23f7eed + 95abf39 commit 28dae23

9 files changed

Lines changed: 2184 additions & 1547 deletions

File tree

docs/keri_app.rst

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ keri.app.configing
2525
.. automodule:: keri.app.configing
2626
:members:
2727

28-
keri.app.connecting
29-
-------------------
30-
31-
.. automodule:: keri.app.connecting
32-
:members:
33-
3428
keri.app.delegating
3529
-------------------
3630

@@ -85,8 +79,8 @@ keri.app.notifying
8579
.. automodule:: keri.app.notifying
8680
:members:
8781

88-
keri.app.oobing
89-
---------------
82+
keri.app.oobiing
83+
----------------
9084

9185
.. automodule:: keri.app.oobiing
9286
:members:

docs/keri_vdr.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ keri.vdr.verifying
2222
keri.vdr.viring
2323
---------------
2424

25-
.. automodule:: keri.vdr.viring
25+
.. automodule:: keri.vdr.vdring
2626
:members:

src/keri/app/apping.py

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,56 +15,69 @@
1515

1616

1717
class Consoler(doing.Doer):
18-
"""
19-
Manages command console
18+
"""Manages a command-line serial console
19+
20+
Reads lines from a serial console, parses simple movement commands,
21+
and echoes feedback. Inherits lifecycle management (enter/recur/exit)
22+
from :class:`hio.base.doing.Doer`.
23+
24+
Attributes:
25+
db (Baser): Database instance used by this doer.
26+
console (serialing.Console): Serial console for input/output.
2027
"""
2128

2229
def __init__(self, db=None, console=None, **kwa):
23-
"""
24-
30+
"""Initializes Consoler with optional database and console.
31+
32+
Args:
33+
db (Baser, optional): Database instance. Defaults to a new
34+
:class:`~keri.db.basing.Baser` instance if None.
35+
console (serialing.Console, optional): Serial console instance.
36+
Defaults to a new :class:`~hio.core.serial.serialing.Console`
37+
instance if None.
38+
**kwa: Additional keyword arguments passed to
39+
:class:`~hio.base.doing.Doer`.
2540
"""
2641
super(Consoler, self).__init__(**kwa)
2742
self.db = db if db is not None else Baser()
2843
self.console = console if console is not None else serialing.Console()
2944

3045
def enter(self, *, temp=None):
31-
""""""
32-
if not self.console.reopen(): # reopen(temp=temp)
33-
raise IOError("Unable to open serial console.")
46+
"""Opens the serial console resource.
3447
35-
def recur(self, tyme):
48+
Called by the Doer framework when entering the task context.
49+
50+
Args:
51+
temp (bool, optional): Unused. Reserved for interface compatibility.
52+
53+
Raises:
54+
IOError: If the console cannot be opened.
3655
"""
37-
Do 'recur' context actions. Override in subclass.
38-
Regular method that perform repetitive actions once per invocation.
39-
Assumes resource setup in .enter() and resource takedown in .exit()
40-
(see ReDoer below for example of .recur that is a generator method)
56+
if not self.console.reopen():
57+
raise IOError("Unable to open serial console.")
4158

42-
Returns completion state of recurrence actions.
43-
True means done False means continue
59+
def recur(self, tyme):
60+
"""Reads one line from the console and dispatches a movement command.
4461
45-
Parameters:
46-
Doist feeds its .tyme through .send to .do yield which passes it here.
62+
Recognized commands (matched on the first character, case-insensitive):
4763
64+
- ``r`` / ``right``: turn right
65+
- ``l`` / ``left``: turn left
66+
- ``w`` / ``walk``: walk 1 step
67+
- ``s`` / ``stop``: stop
4868
49-
.recur maybe implemented by a subclass either as a non-generator method
50-
or a generator method. This stub here is as a non-generator method.
51-
The base class .do detects which type:
52-
If non-generator .do method runs .recur method once per iteration
53-
until .recur returns (True)
54-
If generator .do method runs .recur with (yield from) until .recur
55-
returns (see ReDoer for example of generator .recur)
69+
Args:
70+
tyme (float): Current loop time provided by the Doist scheduler.
5671
72+
Returns:
73+
bool: Always ``False``; signals the Doer to continue recurring.
5774
"""
58-
line = self.console.get() # process one line of input
75+
line = self.console.get()
5976
if not line:
6077
return False
6178
chunks = line.lower().split()
6279

63-
# args = parser.parse_args(chunks)
64-
# if hasattr(args, "handler"):
65-
# args.handler(args)
66-
67-
if not chunks: # empty list
80+
if not chunks:
6881
self.console.put("Try one of: l[eft] r[ight] w[alk] s[top]\n")
6982
return False
7083
verb = chunks[0]
@@ -91,5 +104,8 @@ def recur(self, tyme):
91104
return False
92105

93106
def exit(self):
94-
""""""
107+
"""Closes the serial console resource.
108+
109+
Called by the Doer framework when leaving the task context.
110+
"""
95111
self.console.close()

0 commit comments

Comments
 (0)