本文整理汇总了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
示例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
示例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
示例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