本文整理汇总了Python中component.Component.plug_into方法的典型用法代码示例。如果您正苦于以下问题:Python Component.plug_into方法的具体用法?Python Component.plug_into怎么用?Python Component.plug_into使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类component.Component
的用法示例。
在下文中一共展示了Component.plug_into方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_test_component_outputs_failure
# 需要导入模块: from component import Component [as 别名]
# 或者: from component.Component import plug_into [as 别名]
def test_test_component_outputs_failure(self):
"""test_component_outputs should return false if
an unmet output requirement exists"""
requirement = lambda component : 'IS_BAR' in component.state.flags
subject = Component()
the_output = Component()
the_output.state.set_flag('IS_FOO')
subject.plug_into(the_output)
self.assertEqual(bool(req.test_component_outputs(subject, requirement)), False)
示例2: test_test_component_inputs_pass
# 需要导入模块: from component import Component [as 别名]
# 或者: from component.Component import plug_into [as 别名]
def test_test_component_inputs_pass(self):
"""test_component_inputs should return True if
all input requirements are met"""
requirement = lambda component : 'IS_FOO' in component.state.flags
subject = Component()
the_input = Component()
the_input.state.set_flag('IS_FOO')
subject.register_component(the_input)
the_input.plug_into(subject)
self.assertEqual(len(subject.item_inputs()), 1)
self.assertEqual(req.test_component_inputs(subject, requirement), True)
示例3: get_nodes
# 需要导入模块: from component import Component [as 别名]
# 或者: from component.Component import plug_into [as 别名]
def get_nodes(self):
return self._graph.nodes()
def get_edges(self):
return self._graph.edges()
if __name__ == "__main__":
from component import Component
a = Component(name="a")
b = Component(name="b")
c = Component(name="c")
d = Component(name="d")
e = Component(name="e")
f = Component(name="f")
g = Component(name="g")
b.plug_into(a)
d.plug_into(b)
c.plug_into(d)
e.plug_into(f)
e.plug_into(d)
e.plug_into(g)
e.graph_proxy.get_components()
d.unplug_from(e)
print str(e.graph_proxy.get_components()[1].nodes())