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.cluster_api_egs_conflict
							parent
							
								
									2bd8bf16d7
								
							
						
					
					
						commit
						b71afdc615
					
				| 
						 | 
					@ -139,8 +139,8 @@ def _trio_main(
 | 
				
			||||||
            +
 | 
					            +
 | 
				
			||||||
            pformat.nest_from_op(
 | 
					            pformat.nest_from_op(
 | 
				
			||||||
                input_op='>(',  # see syntax ideas above
 | 
					                input_op='>(',  # see syntax ideas above
 | 
				
			||||||
                tree_str=actor_info,
 | 
					                text=actor_info,
 | 
				
			||||||
                back_from_op=2,  # since "complete"
 | 
					                nest_indent=2,  # since "complete"
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    logmeth = log.info
 | 
					    logmeth = log.info
 | 
				
			||||||
| 
						 | 
					@ -149,8 +149,8 @@ def _trio_main(
 | 
				
			||||||
        +
 | 
					        +
 | 
				
			||||||
        pformat.nest_from_op(
 | 
					        pformat.nest_from_op(
 | 
				
			||||||
            input_op=')>',  # like a "closed-to-play"-icon from super perspective
 | 
					            input_op=')>',  # like a "closed-to-play"-icon from super perspective
 | 
				
			||||||
            tree_str=actor_info,
 | 
					            text=actor_info,
 | 
				
			||||||
            back_from_op=1,
 | 
					            nest_indent=1,
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
| 
						 | 
					@ -167,7 +167,7 @@ def _trio_main(
 | 
				
			||||||
            +
 | 
					            +
 | 
				
			||||||
            pformat.nest_from_op(
 | 
					            pformat.nest_from_op(
 | 
				
			||||||
                input_op='c)>',  # closed due to cancel (see above)
 | 
					                input_op='c)>',  # closed due to cancel (see above)
 | 
				
			||||||
                tree_str=actor_info,
 | 
					                text=actor_info,
 | 
				
			||||||
            )
 | 
					            )
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
    except BaseException as err:
 | 
					    except BaseException as err:
 | 
				
			||||||
| 
						 | 
					@ -177,7 +177,7 @@ def _trio_main(
 | 
				
			||||||
            +
 | 
					            +
 | 
				
			||||||
            pformat.nest_from_op(
 | 
					            pformat.nest_from_op(
 | 
				
			||||||
                input_op='x)>',  # closed by error
 | 
					                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
 | 
					        # NOTE since we raise a tb will already be shown on the
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -521,7 +521,7 @@ async def open_root_actor(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    op_nested_actor_repr: str = _pformat.nest_from_op(
 | 
					                    op_nested_actor_repr: str = _pformat.nest_from_op(
 | 
				
			||||||
                        input_op='>) ',
 | 
					                        input_op='>) ',
 | 
				
			||||||
                        tree_str=actor.pformat(),
 | 
					                        text=actor.pformat(),
 | 
				
			||||||
                        nest_prefix='|_',
 | 
					                        nest_prefix='|_',
 | 
				
			||||||
                    )
 | 
					                    )
 | 
				
			||||||
                    logger.info(
 | 
					                    logger.info(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1698,10 +1698,10 @@ async def async_main(
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    op_nested_actor_repr: str = _pformat.nest_from_op(
 | 
					    op_nested_actor_repr: str = _pformat.nest_from_op(
 | 
				
			||||||
        input_op=')> ',
 | 
					        input_op=')>',
 | 
				
			||||||
        tree_str=actor.pformat(),
 | 
					        text=actor.pformat(),
 | 
				
			||||||
        nest_prefix='|_',
 | 
					        nest_prefix='|_',
 | 
				
			||||||
        back_from_op=2,
 | 
					        nest_indent=1,  # under >
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    teardown_report += (
 | 
					    teardown_report += (
 | 
				
			||||||
        'Actor runtime exited\n'
 | 
					        'Actor runtime exited\n'
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -250,11 +250,28 @@ def pformat_cs(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def nest_from_op(
 | 
					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
 | 
					    # ?TODO? aa more fomal idea for a syntax to the state of
 | 
				
			||||||
    # as a "3-domain" (execution, scope, storage) model and using
 | 
					    # concurrent systems as a "3-domain" (execution, scope, storage)
 | 
				
			||||||
    # a minimal ascii/utf-8 operator-set.
 | 
					    # model and using a minimal ascii/utf-8 operator-set.
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    # try not to take any of this seriously yet XD
 | 
					    # try not to take any of this seriously yet XD
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
| 
						 | 
					@ -320,24 +337,7 @@ def nest_from_op(
 | 
				
			||||||
    #
 | 
					    #
 | 
				
			||||||
    # =>{  recv-req to open
 | 
					    # =>{  recv-req to open
 | 
				
			||||||
    # <={  send-status that it closed
 | 
					    # <={  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 (
 | 
					    if (
 | 
				
			||||||
        nest_prefix
 | 
					        nest_prefix
 | 
				
			||||||
        and
 | 
					        and
 | 
				
			||||||
| 
						 | 
					@ -350,7 +350,7 @@ def nest_from_op(
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    tree_str_indent: int = len(nest_prefix)
 | 
					    tree_str_indent: int = len(nest_prefix)
 | 
				
			||||||
    indented_tree_str: str = textwrap.indent(
 | 
					    indented_tree_str: str = textwrap.indent(
 | 
				
			||||||
        tree_str,
 | 
					        text,
 | 
				
			||||||
        prefix=' '*tree_str_indent
 | 
					        prefix=' '*tree_str_indent
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
    # inject any provided nesting-prefix chars
 | 
					    # inject any provided nesting-prefix chars
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue