当前位置: 首页>>代码示例>>Python>>正文


Python Enum_metaclass.__new__方法代码示例

本文整理汇总了Python中scapy.utils.Enum_metaclass.__new__方法的典型用法代码示例。如果您正苦于以下问题:Python Enum_metaclass.__new__方法的具体用法?Python Enum_metaclass.__new__怎么用?Python Enum_metaclass.__new__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scapy.utils.Enum_metaclass的用法示例。


在下文中一共展示了Enum_metaclass.__new__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __new__

# 需要导入模块: from scapy.utils import Enum_metaclass [as 别名]
# 或者: from scapy.utils.Enum_metaclass import __new__ [as 别名]
def __new__(cls, name, bases, dct): # XXX factorise a bit with Enum_metaclass.__new__()
        for b in bases:
            for k,v in b.__dict__.iteritems():
                if k not in dct and isinstance(v,ASN1Tag):
                    dct[k] = v.clone()

        rdict = {}
        for k,v in dct.iteritems():
            if type(v) is int:
                v = ASN1Tag(k,v) 
                dct[k] = v
                rdict[v] = v
            elif isinstance(v, ASN1Tag):
                rdict[v] = v
        dct["__rdict__"] = rdict

        cls = type.__new__(cls, name, bases, dct)
        for v in cls.__dict__.values():
            if isinstance(v, ASN1Tag): 
                v.context = cls # overwrite ASN1Tag contexts, even cloned ones
        return cls 
开发者ID:medbenali,项目名称:CyberScan,代码行数:23,代码来源:asn1.py

示例2: __new__

# 需要导入模块: from scapy.utils import Enum_metaclass [as 别名]
# 或者: from scapy.utils.Enum_metaclass import __new__ [as 别名]
def __new__(cls, name, bases, dct):  # XXX factorise a bit with Enum_metaclass.__new__()  # noqa: E501
        for b in bases:
            for k, v in six.iteritems(b.__dict__):
                if k not in dct and isinstance(v, ASN1Tag):
                    dct[k] = v.clone()

        rdict = {}
        for k, v in six.iteritems(dct):
            if isinstance(v, int):
                v = ASN1Tag(k, v)
                dct[k] = v
                rdict[v] = v
            elif isinstance(v, ASN1Tag):
                rdict[v] = v
        dct["__rdict__"] = rdict

        cls = type.__new__(cls, name, bases, dct)
        for v in six.itervalues(cls.__dict__):
            if isinstance(v, ASN1Tag):
                v.context = cls  # overwrite ASN1Tag contexts, even cloned ones
        return cls 
开发者ID:secdev,项目名称:scapy,代码行数:23,代码来源:asn1.py

示例3: __new__

# 需要导入模块: from scapy.utils import Enum_metaclass [as 别名]
# 或者: from scapy.utils.Enum_metaclass import __new__ [as 别名]
def __new__(cls, name, bases, dct): # XXX factorise a bit with Enum_metaclass.__new__()
        for b in bases:
            for k,v in b.__dict__.items():
                if k not in dct and isinstance(v,ASN1Tag):
                    dct[k] = v.clone()

        rdict = {}
        for k,v in dct.items():
            if type(v) is int:
                v = ASN1Tag(k,v) 
                dct[k] = v
                rdict[v] = v
            elif isinstance(v, ASN1Tag):
                rdict[v] = v
        dct["__rdict__"] = rdict

        cls = type.__new__(cls, name, bases, dct)
        for v in cls.__dict__.values():
            if isinstance(v, ASN1Tag): 
                v.context = cls # overwrite ASN1Tag contexts, even cloned ones
        return cls 
开发者ID:entynetproject,项目名称:arissploit,代码行数:23,代码来源:asn1.py


注:本文中的scapy.utils.Enum_metaclass.__new__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。