diff options
author | elie <elie> | 2013-12-02 07:34:52 +0000 |
---|---|---|
committer | elie <elie> | 2013-12-02 07:34:52 +0000 |
commit | 6ab22c92a5833238047749ff7ce20f3f507637c1 (patch) | |
tree | bc2c96dbef3800a95720888262d41121f5d5bcb7 /pyasn1/type/base.py | |
parent | 78ba77094a788190c3403201bf101f22297b9aba (diff) | |
download | pyasn1-6ab22c92a5833238047749ff7ce20f3f507637c1.tar.gz |
when comparing ASN.1 types, by-tag and/or by-constraints matching
can now be performed with the isSuperTypeOf()/isSameTypeWith() optional
flags
Diffstat (limited to 'pyasn1/type/base.py')
-rw-r--r-- | pyasn1/type/base.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/pyasn1/type/base.py b/pyasn1/type/base.py index 7d3445c..2380fb0 100644 --- a/pyasn1/type/base.py +++ b/pyasn1/type/base.py @@ -38,14 +38,19 @@ class Asn1ItemBase(Asn1Item): def getEffectiveTagSet(self): return self._tagSet # used by untagged types def getTagMap(self): return tagmap.TagMap({self._tagSet: self}) - def isSameTypeWith(self, other): + def isSameTypeWith(self, other, ignoreTags=False, ignoreConstraints=False): return self is other or \ - self._tagSet == other.getTagSet() and \ - self._subtypeSpec == other.getSubtypeSpec() - def isSuperTypeOf(self, other): + (ignoreTags or \ + self._tagSet == other.getTagSet()) and \ + (ignoreConstraints or \ + self._subtypeSpec==other.getSubtypeSpec()) + + def isSuperTypeOf(self, other, ignoreTags=False, ignoreConstraints=False): """Returns true if argument is a ASN1 subtype of ourselves""" - return self._tagSet.isSuperTagSetOf(other.getTagSet()) and \ - self._subtypeSpec.isSuperTypeOf(other.getSubtypeSpec()) + return (ignoreTags or \ + self._tagSet.isSuperTagSetOf(other.getTagSet())) and \ + (ignoreConstraints or \ + (self._subtypeSpec.isSuperTypeOf(other.getSubtypeSpec()))) class NoValue: def __getattr__(self, attr): |