Bah! just refine `devx.pformat.nest_from_op()`now!

Since we're gonna prolly start using it for serious..
- drop `back_from_op`.
- rename `tree_str` -> `text`
- move the huge comment-doc for "sclang" into the fn body.
- change all usage to reflect.
enable_tpts
Tyler Goodlet 2025-06-17 17:47:27 -04:00
parent 2bd8bf16d7
commit b71afdc615
4 changed files with 33 additions and 33 deletions

View File

@ -139,8 +139,8 @@ def _trio_main(
+
pformat.nest_from_op(
input_op='>(', # see syntax ideas above
tree_str=actor_info,
back_from_op=2, # since "complete"
text=actor_info,
nest_indent=2, # since "complete"
)
)
logmeth = log.info
@ -149,8 +149,8 @@ def _trio_main(
+
pformat.nest_from_op(
input_op=')>', # like a "closed-to-play"-icon from super perspective
tree_str=actor_info,
back_from_op=1,
text=actor_info,
nest_indent=1,
)
)
try:
@ -167,7 +167,7 @@ def _trio_main(
+
pformat.nest_from_op(
input_op='c)>', # closed due to cancel (see above)
tree_str=actor_info,
text=actor_info,
)
)
except BaseException as err:
@ -177,7 +177,7 @@ def _trio_main(
+
pformat.nest_from_op(
input_op='x)>', # closed by error
tree_str=actor_info,
text=actor_info,
)
)
# NOTE since we raise a tb will already be shown on the

View File

@ -521,7 +521,7 @@ async def open_root_actor(
op_nested_actor_repr: str = _pformat.nest_from_op(
input_op='>) ',
tree_str=actor.pformat(),
text=actor.pformat(),
nest_prefix='|_',
)
logger.info(

View File

@ -1698,10 +1698,10 @@ async def async_main(
)
op_nested_actor_repr: str = _pformat.nest_from_op(
input_op=')> ',
tree_str=actor.pformat(),
input_op=')>',
text=actor.pformat(),
nest_prefix='|_',
back_from_op=2,
nest_indent=1, # under >
)
teardown_report += (
'Actor runtime exited\n'

View File

@ -250,11 +250,28 @@ def pformat_cs(
def nest_from_op(
input_op: str,
input_op: str, # TODO, Literal of all op-"symbols" from below?
text: str,
nest_prefix: str = '|_',
nest_indent: int = 0,
# XXX indent `next_prefix` "to-the-right-of" `input_op`
# by this count of whitespaces (' ').
) -> str:
'''
Depth-increment the input (presumably hierarchy/supervision)
input "tree string" below the provided `input_op` execution
operator, so injecting a `"\n|_{input_op}\n"`and indenting the
`tree_str` to nest content aligned with the ops last char.
'''
# `sclang` "structurred-concurrency-language": an ascii-encoded
# symbolic alphabet to describe concurrent systems.
#
# ?TODO? an idea for a syntax to the state of concurrent systems
# as a "3-domain" (execution, scope, storage) model and using
# a minimal ascii/utf-8 operator-set.
# ?TODO? aa more fomal idea for a syntax to the state of
# concurrent systems as a "3-domain" (execution, scope, storage)
# model and using a minimal ascii/utf-8 operator-set.
#
# try not to take any of this seriously yet XD
#
@ -320,24 +337,7 @@ def nest_from_op(
#
# =>{ recv-req to open
# <={ send-status that it closed
tree_str: str,
# NOTE: so move back-from-the-left of the `input_op` by
# this amount.
back_from_op: int = 0,
nest_prefix: str = '|_',
nest_indent: int = 0,
) -> str:
'''
Depth-increment the input (presumably hierarchy/supervision)
input "tree string" below the provided `input_op` execution
operator, so injecting a `"\n|_{input_op}\n"`and indenting the
`tree_str` to nest content aligned with the ops last char.
'''
nest_indent = nest_indent or back_from_op # <- rm latter!
#
if (
nest_prefix
and
@ -350,7 +350,7 @@ def nest_from_op(
tree_str_indent: int = len(nest_prefix)
indented_tree_str: str = textwrap.indent(
tree_str,
text,
prefix=' '*tree_str_indent
)
# inject any provided nesting-prefix chars