SequenceOf Sequence: doubt
GuilhermeUtech opened this issue · 2 comments
GuilhermeUtech commented
How could I assign values to the 'attributes' elements: 'type' and 'vals'?
# (last modified on 2020-03-23 14:38:47.141034)
from pyasn1.type import univ, char, namedtype, namedval, tag, constraint, useful
class SearchResultEntry(univ.Sequence):
pass
SearchResultEntry.tagSet = univ.Sequence.tagSet.tagExplicitly(tag.Tag(tag.tagClassApplication, tag.tagFormatConstructed, 4))
SearchResultEntry.componentType = namedtype.NamedTypes(
namedtype.NamedType('objectName', univ.OctetString()),
namedtype.NamedType('attributes', univ.SequenceOf(componentType=univ.Sequence(componentType=namedtype.NamedTypes(
namedtype.NamedType('type', univ.OctetString()),
namedtype.NamedType('vals', univ.SetOf(componentType=univ.OctetString()))
))
))
)
russhousley commented
sre = SearchResultEntry()
sre['attributes'][0]['type'].fromHexString('313233')
'123'
sre['attributes'][0]['vals'][0].fromHexString('313233')
'123'
GuilhermeUtech commented
ty buddy