asn1rt: add experimental method to iter over all basic objects of any ASN.1 constructed / open type

This commit is contained in:
mich 2019-06-11 11:17:07 +02:00
parent 52fe840e3c
commit d960f1f483
1 changed files with 21 additions and 0 deletions

View File

@ -705,6 +705,27 @@ class ASN1Obj(Element):
del self._proto_fields[-1]
return ret
# experimental: to be improved
def iter_cont(self):
if self.TYPE == TYPE_OPEN:
cont = ASN1Dict()
for (ident, Comp) in self._get_const_tr().items():
Comp.iter_cont()
#
elif self.TYPE in TYPES_BASIC + TYPES_EXT:
print('%s: %s, %r' % (self._name, self.TYPE, self.get_const()))
#
elif self.TYPE in (TYPE_SEQ_OF, TYPE_SET_OF):
self._cont.iter_cont()
#
elif self.TYPE in (TYPE_CHOICE, TYPE_SEQ, TYPE_SET, TYPE_CLASS):
cont = ASN1Dict()
for (ident, Comp) in self._cont.items():
Comp.iter_cont()
#
else:
assert()
def get_complexity(self, w_open=True, print_recurs=False):
"""
returns the number of basic types referenced from self,