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


Python Field.set_list_validation方法代码示例

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


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

示例1: __init__

# 需要导入模块: from field import Field [as 别名]
# 或者: from field.Field import set_list_validation [as 别名]
    def __init__(self, platforms):
        """Create a new delegator instance.

        'platforms' is a set of all platforms to support
        """
        super().__init__('luastructs', Platform.mappings['default'], None)
        self.platforms = platforms
        self.field_var = 'f.'
        self.description = 'Lua C Structs'
        self.dissectors = {self.platform.name: self}

        self.var = create_lua_var('delegator')
        self.table_var = create_lua_var('dissector_table')
        self.id_table = create_lua_var('message_ids')
        self.sizes_table = create_lua_var('dissector_sizes')
        self.msg_var = create_lua_var('msg_node')

        # Add fields, don't change sizes!
        endian = Platform.big
        self.add_field(Field('Version', 'uint8', 1, 0, endian))
        values = {p.flag: p.name for name, p in self.platforms.items()}
        field = Field('Flags', 'uint8', 1, 0, endian)
        field.set_list_validation(values)
        self.add_field(field)
        self.add_field(Field('Message', 'uint16', 2, 0, endian))
        self.add_field(Field('Message length', 'uint32', 4, 0, endian))

        self.version, self.flags, self.msg_id, self.length = self.children
开发者ID:Rad0x6f,项目名称:kpro9,代码行数:30,代码来源:dissector.py

示例2: create_enum_field

# 需要导入模块: from field import Field [as 别名]
# 或者: from field.Field import set_list_validation [as 别名]
def create_enum_field():
    """Create a Protocol instance with some fields."""
    proto, diss = dissector.Protocol.create_dissector('test')
    field = Field('enum', 'int32', 4, 0, Platform.big)
    field.set_list_validation(dict(enumerate('ABCDE')))
    diss.add_field(field)
    diss.push_modifiers()
    yield diss.children[0]
    dissector.Protocol.protocols = {}
    del proto, diss
开发者ID:Rad0x6f,项目名称:kpro9,代码行数:12,代码来源:test_dissector.py

示例3: _create_enum

# 需要导入模块: from field import Field [as 别名]
# 或者: from field.Field import set_list_validation [as 别名]
 def _create_enum(self, name, enum):
     """Create a new enum field."""
     if enum not in self.enums.keys():
         raise ParseError('Unknown enum: %s' % enum)
     type = self.map_type('enum')
     size = self.size_of('enum')
     alignment = self.alignment('enum')
     field = Field(name, type, size, alignment, self.platform.endian)
     field.set_list_validation(self.enums[enum])
     return field
开发者ID:Rad0x6f,项目名称:kpro9,代码行数:12,代码来源:cparser.py

示例4: create_lua_keywords_field

# 需要导入模块: from field import Field [as 别名]
# 或者: from field.Field import set_list_validation [as 别名]
def create_lua_keywords_field():
    """Create a Protocol instance with some fields."""
    proto, diss = dissector.Protocol.create_dissector('test')
    field = Field('elseif', 'int32', 4, 0, Platform.big)
    field.set_list_validation(dict(enumerate('VWXYZ')))
    diss.add_field(field)
    diss.add_field(Field('in', 'float', 4, 0, Platform.big))
    diss.push_modifiers()
    yield diss.children[0], diss.children[1]
    dissector.Protocol.protocols = {}
    del proto, diss
开发者ID:Rad0x6f,项目名称:kpro9,代码行数:13,代码来源:test_dissector.py


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