本文整理汇总了Python中scapy.automaton.ATMT.condition方法的典型用法代码示例。如果您正苦于以下问题:Python ATMT.condition方法的具体用法?Python ATMT.condition怎么用?Python ATMT.condition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scapy.automaton.ATMT
的用法示例。
在下文中一共展示了ATMT.condition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: hookable
# 需要导入模块: from scapy.automaton import ATMT [as 别名]
# 或者: from scapy.automaton.ATMT import condition [as 别名]
def hookable(f):
@functools.wraps(f)
def wrapped_f(*args, **kwargs):
if args and isinstance(args[0], Automaton):
obj = args[0]
cb_f = obj.callbacks.get(f.__name__.rsplit("_wrapper", 1)[0], None)
if cb_f:
obj.debug(1, "*** CALLBACK *** calling '%s' -> %s" % (f.__name__, cb_f))
return cb_f(*args, **kwargs)
return f(*args, **kwargs)
if f.atmt_type == ATMT.CONDITION:
'''tin: ugly hack Part I
its not possible to easily decorate ATMT.Conditions
without breaking ATMT.graph() as the graph method relies on
inspecting the caller functions code :/
see scapy\automaton.py::graph()
for n in f.func_code.co_names+f.func_code.co_consts
therefore we're only saving the wrapper as an attribute to that
function and have ATMT.run() cleanup the ATMT.conditions map
to use hookable(condition) that is stored in f.wrapper_f instead
of the unwrapped function.
this way, ATMT.graph() works fine as long as it is called before
ATMT.run()
'''
f.wrapper_f = wrapped_f
return f
else:
return wrapped_f