Update libs
This commit is contained in:
@@ -0,0 +1 @@
|
||||
# This file is necessary to make this directory a package.
|
||||
|
||||
@@ -120,7 +120,12 @@ class AbstractSimpleAsn1Item(Asn1ItemBase):
|
||||
def prettyIn(self, value): return value
|
||||
def prettyOut(self, value): return str(value)
|
||||
|
||||
def prettyPrint(self, scope=0): return self.prettyOut(self._value)
|
||||
def prettyPrint(self, scope=0):
|
||||
if self._value is noValue:
|
||||
return '<no value>'
|
||||
else:
|
||||
return self.prettyOut(self._value)
|
||||
|
||||
# XXX Compatibility stub
|
||||
def prettyPrinter(self, scope=0): return self.prettyPrint(scope)
|
||||
|
||||
|
||||
@@ -60,12 +60,12 @@ class NamedTypes:
|
||||
tagMap = self.__namedTypes[idx].getType().getTagMap()
|
||||
for t in tagMap.getPosMap():
|
||||
if t in self.__tagToPosIdx:
|
||||
raise error.PyAsn1Error('Duplicate type %s' % t)
|
||||
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)
|
||||
raise error.PyAsn1Error('Type %s not found' % (tagSet,))
|
||||
|
||||
def getNameByPosition(self, idx):
|
||||
try:
|
||||
@@ -79,12 +79,12 @@ class NamedTypes:
|
||||
idx = idx - 1
|
||||
n = self.__namedTypes[idx].getName()
|
||||
if n in self.__nameToPosIdx:
|
||||
raise error.PyAsn1Error('Duplicate name %s' % n)
|
||||
raise error.PyAsn1Error('Duplicate name %s' % (n,))
|
||||
self.__nameToPosIdx[n] = idx
|
||||
try:
|
||||
return self.__nameToPosIdx[name]
|
||||
except KeyError:
|
||||
raise error.PyAsn1Error('Name %s not found' % name)
|
||||
raise error.PyAsn1Error('Name %s not found' % (name,))
|
||||
|
||||
def __buildAmbigiousTagMap(self):
|
||||
ambigiousTypes = ()
|
||||
|
||||
@@ -15,10 +15,10 @@ class NamedValues:
|
||||
name = namedValue
|
||||
val = automaticVal
|
||||
if name in self.nameToValIdx:
|
||||
raise error.PyAsn1Error('Duplicate name %s' % name)
|
||||
raise error.PyAsn1Error('Duplicate name %s' % (name,))
|
||||
self.nameToValIdx[name] = val
|
||||
if val in self.valToNameIdx:
|
||||
raise error.PyAsn1Error('Duplicate value %s' % name)
|
||||
raise error.PyAsn1Error('Duplicate value %s=%s' % (name, val))
|
||||
self.valToNameIdx[val] = name
|
||||
self.namedValues = self.namedValues + ((name, val),)
|
||||
automaticVal = automaticVal + 1
|
||||
|
||||
@@ -18,7 +18,7 @@ class Tag:
|
||||
def __init__(self, tagClass, tagFormat, tagId):
|
||||
if tagId < 0:
|
||||
raise error.PyAsn1Error(
|
||||
'Negative tag ID (%s) not allowed' % tagId
|
||||
'Negative tag ID (%s) not allowed' % (tagId,)
|
||||
)
|
||||
self.__tag = (tagClass, tagFormat, tagId)
|
||||
self.uniq = (tagClass, tagId)
|
||||
|
||||
@@ -28,7 +28,7 @@ class TagMap:
|
||||
|
||||
def clone(self, parentType, tagMap, uniq=False):
|
||||
if self.__defType is not None and tagMap.getDef() is not None:
|
||||
raise error.PyAsn1Error('Duplicate default value at %s' % self)
|
||||
raise error.PyAsn1Error('Duplicate default value at %s' % (self,))
|
||||
if tagMap.getDef() is not None:
|
||||
defType = tagMap.getDef()
|
||||
else:
|
||||
@@ -37,7 +37,7 @@ class TagMap:
|
||||
posMap = self.__posMap.copy()
|
||||
for k in tagMap.getPosMap():
|
||||
if uniq and k in posMap:
|
||||
raise error.PyAsn1Error('Duplicate positive key %s' % k)
|
||||
raise error.PyAsn1Error('Duplicate positive key %s' % (k,))
|
||||
posMap[k] = parentType
|
||||
|
||||
negMap = self.__negMap.copy()
|
||||
|
||||
@@ -69,13 +69,18 @@ class Integer(base.AbstractSimpleAsn1Item):
|
||||
|
||||
def prettyIn(self, value):
|
||||
if not isinstance(value, str):
|
||||
return int(value)
|
||||
try:
|
||||
return int(value)
|
||||
except:
|
||||
raise error.PyAsn1Error(
|
||||
'Can\'t coerce %s into integer: %s' % (value, sys.exc_info()[1])
|
||||
)
|
||||
r = self.__namedValues.getValue(value)
|
||||
if r is not None:
|
||||
return r
|
||||
try:
|
||||
return int(value)
|
||||
except ValueError:
|
||||
except:
|
||||
raise error.PyAsn1Error(
|
||||
'Can\'t coerce %s into integer: %s' % (value, sys.exc_info()[1])
|
||||
)
|
||||
@@ -224,14 +229,14 @@ class BitString(base.AbstractSimpleAsn1Item):
|
||||
return tuple(r)
|
||||
else:
|
||||
raise error.PyAsn1Error(
|
||||
'Bad BIT STRING value notation %s' % value
|
||||
'Bad BIT STRING value notation %s' % (value,)
|
||||
)
|
||||
else:
|
||||
for i in value.split(','):
|
||||
j = self.__namedValues.getValue(i)
|
||||
if j is None:
|
||||
raise error.PyAsn1Error(
|
||||
'Unknown bit identifier \'%s\'' % i
|
||||
'Unknown bit identifier \'%s\'' % (i,)
|
||||
)
|
||||
if j >= len(r):
|
||||
r.extend([0]*(j-len(r)+1))
|
||||
@@ -528,7 +533,7 @@ class Real(base.AbstractSimpleAsn1Item):
|
||||
)
|
||||
if value[1] not in (2, 10):
|
||||
raise error.PyAsn1Error(
|
||||
'Prohibited base for Real value: %s' % value[1]
|
||||
'Prohibited base for Real value: %s' % (value[1],)
|
||||
)
|
||||
if value[1] == 10:
|
||||
value = self.__normalizeBase10(value)
|
||||
@@ -648,7 +653,7 @@ class SetOf(base.AbstractConstructedAsn1Item):
|
||||
def _verifyComponent(self, idx, value):
|
||||
if self._componentType is not None and \
|
||||
not self._componentType.isSuperTypeOf(value):
|
||||
raise error.PyAsn1Error('Component type error %s' % value)
|
||||
raise error.PyAsn1Error('Component type error %s' % (value,))
|
||||
|
||||
def getComponentByPosition(self, idx): return self._componentValues[idx]
|
||||
def setComponentByPosition(self, idx, value=None, verifyConstraints=True):
|
||||
@@ -924,9 +929,9 @@ class Choice(Set):
|
||||
return self._componentValues[self._currentIdx] >= other
|
||||
return NotImplemented
|
||||
if sys.version_info[0] <= 2:
|
||||
def __nonzero__(self, other): return bool(self._componentValues)
|
||||
def __nonzero__(self): return bool(self._componentValues)
|
||||
else:
|
||||
def __bool__(self, other): return bool(self._componentValues)
|
||||
def __bool__(self): return bool(self._componentValues)
|
||||
|
||||
def __len__(self): return self._currentIdx is not None and 1 or 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user