當前位置: 首頁>>代碼示例>>Python>>正文


Python ATMT.condition方法代碼示例

本文整理匯總了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 
開發者ID:tintinweb,項目名稱:scapy-ssl_tls,代碼行數:31,代碼來源:ssl_tls_automata.py


注:本文中的scapy.automaton.ATMT.condition方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。