MCPcopy Index your code
hub / github.com/pywebio/PyWebIO / use_scope

Function use_scope

pywebio/output.py:2099–2138  ·  view source on GitHub ↗

use_scope(name=None, clear=False) Open or enter a scope. Can be used as context manager and decorator. See :ref:`User manual - use_scope() ` :param str name: Scope name. If it is None, a globally unique scope name is generated. (When used as context manager, the con

(name: str = None, clear: bool = False, **kwargs)

Source from the content-addressed store, hash-verified

2097
2098
2099def use_scope(name: str = None, clear: bool = False, **kwargs):
2100 """use_scope(name=None, clear=False)
2101
2102 Open or enter a scope. Can be used as context manager and decorator.
2103
2104 See :ref:`User manual - use_scope() <use_scope>`
2105
2106 :param str name: Scope name. If it is None, a globally unique scope name is generated.
2107 (When used as context manager, the context manager will return the scope name)
2108 :param bool clear: Whether to clear the contents of the scope before entering the scope.
2109
2110 :Usage:
2111
2112 ::
2113
2114 with use_scope(...) as scope_name:
2115 put_xxx()
2116
2117 @use_scope(...)
2118 def app():
2119 put_xxx()
2120
2121 """
2122 # For backward compatible
2123 # :param bool create_scope: Whether to create scope when scope does not exist.
2124 # :param scope_params: Extra parameters passed to `set_scope()` when need to create scope.
2125 # Only available when ``create_scope=True``.
2126 create_scope = kwargs.pop('create_scope', True)
2127 scope_params = kwargs
2128
2129 if name is None:
2130 name = random_str(10)
2131 check_dom_name_value(name, 'scope name')
2132
2133 def before_enter():
2134 if create_scope:
2135 if_exist = 'blank' if clear else None
2136 set_scope(name, if_exist=if_exist, **scope_params) # lock the height of the scope and clear its content
2137
2138 return use_scope_(name=name, before_enter=before_enter)
2139
2140
2141class use_scope_:

Callers 13

targetFunction · 0.85
basic_outputFunction · 0.85
mainFunction · 0.85
on_key_pressFunction · 0.85
output_widgetsFunction · 0.85
mainFunction · 0.85
bg_taskFunction · 0.85
run_codeFunction · 0.85
code_blockFunction · 0.85
mainFunction · 0.85
run_codeFunction · 0.85
handle_codeFunction · 0.85

Calls 3

random_strFunction · 0.85
check_dom_name_valueFunction · 0.85
use_scope_Class · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…