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

Class OutputHandler

pywebio/output.py:1854–1893  ·  view source on GitHub ↗

与 `Output` 的不同在于, 不会在销毁时(__del__)自动输出 The difference with `Output` is that `OutputHandler` will not automatically output when destroyed (__del__)

Source from the content-addressed store, hash-verified

1852 "use `pywebio.output.put_scope()` instead", DeprecationWarning, stacklevel=2)
1853
1854 class OutputHandler(Output):
1855 """
1856 与 `Output` 的不同在于, 不会在销毁时(__del__)自动输出
1857 The difference with `Output` is that `OutputHandler` will not automatically output when destroyed (__del__)
1858 """
1859
1860 def __del__(self):
1861 pass
1862
1863 def __init__(self, spec, scope):
1864 super().__init__(spec)
1865 self.scope = scope
1866
1867 @safely_destruct_output_when_exp('outputs')
1868 def reset(self, *outputs):
1869 clear_scope(scope=self.scope)
1870 self.append(*outputs)
1871
1872 @safely_destruct_output_when_exp('outputs')
1873 def append(self, *outputs):
1874 for o in outputs:
1875 if not isinstance(o, Output):
1876 o = put_text(o)
1877 o.spec['scope'] = scope2dom(self.scope)
1878 o.spec['position'] = OutputPosition.BOTTOM
1879 o.send()
1880
1881 @safely_destruct_output_when_exp('outputs')
1882 def insert(self, idx, *outputs):
1883 """
1884 idx可为负
1885 idx can be negative
1886 """
1887 direction = 1 if idx >= 0 else -1
1888 for acc, o in enumerate(outputs):
1889 if not isinstance(o, Output):
1890 o = put_text(o)
1891 o.spec['scope'] = scope2dom(self.scope)
1892 o.spec['position'] = idx + direction * acc
1893 o.send()
1894
1895 contents = [c if isinstance(c, Output) else put_text(c) for c in contents]
1896

Callers 1

outputFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…