Create a new scope. :param str name: scope name :param str container_scope: Specify the parent scope of this scope. When the scope doesn't exist, no operation is performed. :param int position: The location where this scope is created in the parent scope. (see :ref:`Scope
(name: str, container_scope: str = None, position: int = OutputPosition.BOTTOM, if_exist: str = None)
| 276 | |
| 277 | |
| 278 | def set_scope(name: str, container_scope: str = None, position: int = OutputPosition.BOTTOM, if_exist: str = None): |
| 279 | """Create a new scope. |
| 280 | |
| 281 | :param str name: scope name |
| 282 | :param str container_scope: Specify the parent scope of this scope. |
| 283 | When the scope doesn't exist, no operation is performed. |
| 284 | :param int position: The location where this scope is created in the parent scope. |
| 285 | (see :ref:`Scope related parameters <scope_param>`) |
| 286 | :param str if_exist: What to do when the specified scope already exists: |
| 287 | |
| 288 | - `None`: Do nothing |
| 289 | - `'remove'`: Remove the old scope first and then create a new one |
| 290 | - `'clear'`: Just clear the contents of the old scope, but don't create a new scope |
| 291 | |
| 292 | Default is `None` |
| 293 | """ |
| 294 | if container_scope is None: |
| 295 | container_scope = get_scope() |
| 296 | check_dom_name_value(name, 'scope name') |
| 297 | send_msg('output_ctl', dict(set_scope=scope2dom(name, no_css_selector=True), |
| 298 | container=scope2dom(container_scope), |
| 299 | position=position, if_exist=if_exist)) |
| 300 | |
| 301 | |
| 302 | def get_scope(stack_idx: int = -1): |
no test coverage detected
searching dependent graphs…