本文整理匯總了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