Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for key, value in type_descriptor['choices'].items():
choices[key] = self.compile_type(key,
value,
module_name)
compiled = AnyDefinedBy(name,
type_descriptor['value'],
choices)
elif type_name == 'NULL':
compiled = Null(name)
elif type_name == 'EXTERNAL':
compiled = Sequence(
name,
*self.compile_members(self.external_type_descriptor()['members'],
module_name))
compiled.set_tag(Tag.EXTERNAL, 0)
elif type_name == 'ObjectDescriptor':
compiled = ObjectDescriptor(name)
else:
if type_name in self.types_backtrace:
compiled = Recursive(name,
type_name,
module_name)
self.recursive_types.append(compiled)
else:
compiled = self.compile_user_type(name,
type_name,
module_name)
return compiled
class NumericString(StringType):
TAG = Tag.NUMERIC_STRING
ENCODING = 'ascii'
class PrintableString(StringType):
TAG = Tag.PRINTABLE_STRING
ENCODING = 'ascii'
class IA5String(StringType):
TAG = Tag.IA5_STRING
ENCODING = 'ascii'
class VisibleString(StringType):
TAG = Tag.VISIBLE_STRING
ENCODING = 'ascii'
class GeneralString(StringType):
TAG = Tag.GENERAL_STRING
ENCODING = 'latin-1'
class BMPString(StringType):
class BMPString(KnownMultiplierStringType):
TAG = Tag.BMP_STRING
ENCODING = 'utf-16-be'
class GraphicString(KnownMultiplierStringType):
TAG = Tag.GENERAL_STRING
ENCODING = 'latin-1'
class UniversalString(KnownMultiplierStringType):
TAG = Tag.UNIVERSAL_STRING
ENCODING = 'utf-32-be'
class TeletexString(KnownMultiplierStringType):
TAG = Tag.T61_STRING
ENCODING = 'iso-8859-1'
class ObjectDescriptor(GraphicString):
TAG = Tag.OBJECT_DESCRIPTOR
class UTCTime(VisibleString):
class TeletexString(KnownMultiplierStringType):
TAG = Tag.T61_STRING
ENCODING = 'iso-8859-1'
class ObjectDescriptor(GraphicString):
TAG = Tag.OBJECT_DESCRIPTOR
class UTCTime(VisibleString):
TAG = Tag.UTC_TIME
def encode(self, data, encoder):
encoded = utc_time_from_datetime(data)
return super(UTCTime, self).encode(encoded, encoder)
def decode(self, decoder):
decoded = super(UTCTime, self).decode(decoder)
return utc_time_to_datetime(decoded)
class GeneralizedTime(VisibleString):
TAG = Tag.GENERALIZED_TIME
class BMPString(StringType):
TAG = Tag.BMP_STRING
ENCODING = 'utf-16-be'
class GraphicString(StringType):
TAG = Tag.GRAPHIC_STRING
ENCODING = 'latin-1'
class UniversalString(StringType):
TAG = Tag.UNIVERSAL_STRING
ENCODING = 'utf-32-be'
class TeletexString(StringType):
TAG = Tag.T61_STRING
ENCODING = 'iso-8859-1'
class ObjectDescriptor(GraphicString):
TAG = Tag.OBJECT_DESCRIPTOR
class UTCTime(Type):
def __init__(self, name, element_type):
super(SequenceOf, self).__init__(name,
'SEQUENCE OF',
Tag.SEQUENCE,
element_type)
class NumericString(KnownMultiplierStringType):
TAG = Tag.NUMERIC_STRING
ENCODING = 'ascii'
class PrintableString(KnownMultiplierStringType):
TAG = Tag.PRINTABLE_STRING
ENCODING = 'ascii'
class IA5String(KnownMultiplierStringType):
TAG = Tag.IA5_STRING
ENCODING = 'ascii'
class VisibleString(KnownMultiplierStringType):
TAG = Tag.VISIBLE_STRING
ENCODING = 'ascii'
class GeneralString(KnownMultiplierStringType):
TAG = Tag.GENERAL_STRING
ENCODING = 'latin-1'
class BMPString(KnownMultiplierStringType):
def __init__(self, name, root_members, additions):
super(Set, self).__init__(name,
'SET',
Tag.SET,
root_members,
additions)
def __init__(self, name):
super(Boolean, self).__init__(name,
'BOOLEAN',
Tag.BOOLEAN)
class UTF8String(StringType):
TAG = Tag.UTF8_STRING
ENCODING = 'utf-8'
class NumericString(StringType):
TAG = Tag.NUMERIC_STRING
ENCODING = 'ascii'
class PrintableString(StringType):
TAG = Tag.PRINTABLE_STRING
ENCODING = 'ascii'
class IA5String(StringType):
TAG = Tag.IA5_STRING
ENCODING = 'ascii'
class VisibleString(StringType):
TAG = Tag.VISIBLE_STRING
ENCODING = 'ascii'
class GeneralString(StringType):