def __init__(self, name, attribute, value, fuzz_attribute=False, fuzz_value=True):
'''
:param name: name of the block
:param attribute: attribute
:type value: str/unicode/int
:param value: value of the attribute
:param fuzz_attribute: should we fuzz the attribute field (default: False)
:param fuzz_value: should we fuzz the value field (default: True)
'''
_check_type(attribute, StringTypes, 'attribute')
_check_type(value, StringTypes + (IntType, ), 'value')
value_name = _valuename(name)
if isinstance(value, StringTypes):
value_field = String(value, name=value_name, fuzzable=fuzz_value)
else:
value_field = SInt32(value, encoder=ENC_INT_DEC, fuzzable=fuzz_value, name=value_name)
fields = [
String(attribute, fuzzable=fuzz_attribute, name='%s_attribute' % name),
Static('='),
Static('"'),
value_field,
Static('"')
]
super(XmlAttribute, self).__init__(fields, name=name)
评论列表
文章目录