本文整理汇总了Python中prompt_toolkit.filters.Filter方法的典型用法代码示例。如果您正苦于以下问题:Python filters.Filter方法的具体用法?Python filters.Filter怎么用?Python filters.Filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类prompt_toolkit.filters
的用法示例。
在下文中一共展示了filters.Filter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _create_merged_style
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Filter [as 别名]
def _create_merged_style(self, include_default_pygments_style: Filter) -> BaseStyle:
"""
Create a `Style` object that merges the default UI style, the default
pygments style, and the custom user style.
"""
dummy_style = DummyStyle()
pygments_style = default_pygments_style()
@DynamicStyle
def conditional_pygments_style() -> BaseStyle:
if include_default_pygments_style():
return pygments_style
else:
return dummy_style
return merge_styles(
[
default_ui_style(),
conditional_pygments_style,
DynamicStyle(lambda: self.style),
]
)
示例2: test_to_filter
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Filter [as 别名]
def test_to_filter():
f1 = to_filter(True)
f2 = to_filter(False)
f3 = to_filter(Condition(lambda: True))
f4 = to_filter(Condition(lambda: False))
assert isinstance(f1, Filter)
assert isinstance(f2, Filter)
assert isinstance(f3, Filter)
assert isinstance(f4, Filter)
assert f1()
assert not f2()
assert f3()
assert not f4()
with pytest.raises(TypeError):
to_filter(4)
示例3: test_or
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Filter [as 别名]
def test_or():
for a in (True, False):
for b in (True, False):
c1 = Condition(lambda: a)
c2 = Condition(lambda: b)
c3 = c1 | c2
assert isinstance(c3, Filter)
assert c3() == a or b
示例4: test_and
# 需要导入模块: from prompt_toolkit import filters [as 别名]
# 或者: from prompt_toolkit.filters import Filter [as 别名]
def test_and():
for a in (True, False):
for b in (True, False):
c1 = Condition(lambda: a)
c2 = Condition(lambda: b)
c3 = c1 & c2
assert isinstance(c3, Filter)
assert c3() == (a and b)