def getTagMap(self, uniq=False): if self.__tagMap[uniq] is None: tagMap = tagmap.TagMap() for nt in self.__namedTypes: tagMap = tagMap.clone( nt.getType(), nt.getType().getTagMap() or tagmap.TagMap(), uniq) self.__tagMap[uniq] = tagMap return self.__tagMap[uniq]
def tagMap(self): """Return a :class:`~pyasn1.type.tagmap.TagMap` object mapping ASN.1 tags to ASN.1 objects within callee object. """ try: return self._tagMap except AttributeError: self._tagMap = tagmap.TagMap({self._tagSet: self}) return self._tagMap
def getTagMap(self, unique=False): """Create a *TagMap* object from tags and types recursively. Create a new :class:`~pyasn1.type.tagmap.TagMap` object by combining tags from *TagMap* objects of children types and associating them with their immediate child type. Example ------- .. code-block:: python OuterType ::= CHOICE { innerType INTEGER } Calling *.getTagMap()* on *OuterType* will yield a map like this: .. code-block:: python Integer.tagSet -> Choice Parameters ---------- unique: :py:class:`bool` If `True`, duplicate *TagSet* objects occurring while building new *TagMap* would cause error. Returns ------- : :class:`~pyasn1.type.tagmap.TagMap` New *TagMap* holding *TagSet* object gathered from childen types. """ if unique not in self.__tagMap: presentTypes = {} skipTypes = {} defaultType = None for namedType in self.__namedTypes: tagMap = namedType.asn1Object.tagMap for tagSet in tagMap: if unique and tagSet in presentTypes: raise error.PyAsn1Error('Non-unique tagSet %s' % (tagSet, )) presentTypes[tagSet] = namedType.asn1Object skipTypes.update(tagMap.skipTypes) if defaultType is None: defaultType = tagMap.defaultType elif tagMap.defaultType is not None: raise error.PyAsn1Error( 'Duplicate default ASN.1 type at %s' % (self, )) self.__tagMap[unique] = tagmap.TagMap(presentTypes, skipTypes, defaultType) return self.__tagMap[unique]
def getPositionByType(self, tagSet): if not self.__tagToPosIdx: idx = self.__namedTypesLen while idx > 0: idx -= 1 tagMap = self.__namedTypes[idx].getType().getTagMap( ) or tagmap.TagMap() for t in tagMap.getPosMap(): if t in self.__tagToPosIdx: raise error.PyAsn1Error('Duplicate type %s' % (t, )) self.__tagToPosIdx[t] = idx try: return self.__tagToPosIdx[tagSet] except KeyError: raise error.PyAsn1Error('Type %s not found' % (tagSet, ))
def __computeTagMaps(self, unique): presentTypes = {} skipTypes = {} defaultType = None for namedType in self.__namedTypes: tagMap = namedType.asn1Object.tagMap if isinstance(tagMap, NamedTypes.PostponedError): return tagMap for tagSet in tagMap: if unique and tagSet in presentTypes: return NamedTypes.PostponedError('Non-unique tagSet %s of %s at %s' % (tagSet, namedType, self)) presentTypes[tagSet] = namedType.asn1Object skipTypes.update(tagMap.skipTypes) if defaultType is None: defaultType = tagMap.defaultType elif tagMap.defaultType is not None: return NamedTypes.PostponedError('Duplicate default ASN.1 type at %s' % (self,)) return tagmap.TagMap(presentTypes, skipTypes, defaultType)
def __getTagMap(self, unique): if unique not in self.__tagMap: presentTypes = {} skipTypes = {} defaultType = None for namedType in self.__namedTypes: tagMap = namedType.asn1Object.tagMap for tagSet in tagMap: if unique and tagSet in presentTypes: raise error.PyAsn1Error('Non-unique tagSet %s' % (tagSet,)) presentTypes[tagSet] = namedType.asn1Object skipTypes.update(tagMap.skipTypes) if defaultType is None: defaultType = tagMap.defaultType elif tagMap.defaultType is not None: raise error.PyAsn1Error('Duplicate default ASN.1 type at %s' % (self,)) self.__tagMap[unique] = tagmap.TagMap(presentTypes, skipTypes, defaultType) return self.__tagMap[unique]
def getTagMap(self): return tagmap.TagMap({self._tagSet: self})
def getTagMap(self): return tagmap.TagMap({self.getTagSet(): self}, {eoo.endOfOctets.getTagSet(): eoo.endOfOctets}, self)
def tagMap(self): """Return a :class:`~pyasn1.type.tagmap.TagMap` object mapping ASN.1 tags to ASN.1 objects within callee object. """ return tagmap.TagMap({self.tagSet: self})
def getTagMap(self): return tagmap.TagMap({self._tagSet: self}) def isSameTypeWith(self, other, matchTags=True, matchConstraints=True):
def getTagMap(self): return tagmap.TagMap({self._tagSet: self}) def isSameTypeWith(self, other):