Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
elif isinstance(type_, uper.Real):
return self.format_real_inner()
elif isinstance(type_, uper.Null):
return [], []
elif isinstance(type_, uper.Boolean):
return self.format_boolean_inner()
elif is_user_type(type_):
return self.format_user_type_inner(type_.type_name,
type_.module_name)
elif isinstance(type_, uper.OctetString):
return self.format_octet_string_inner(type_, checker)
elif isinstance(type_, uper.Sequence):
return self.format_sequence_inner(type_, checker)
elif isinstance(type_, uper.Choice):
return self.format_choice_inner(type_, checker)
elif isinstance(type_, uper.SequenceOf):
return self.format_sequence_of_inner(type_, checker)
elif isinstance(type_, uper.Enumerated):
return self.format_enumerated_inner(type_)
else:
raise self.error(type_)
Give `numeric_enums` as ``True`` for numeric enumeration values
instead of strings.
>>> foo = asn1tools.compile_dict(asn1tools.parse_files('foo.asn'))
"""
codecs = {
'ber': ber,
'der': der,
'gser': gser,
'jer': jer,
'oer': oer,
'per': per,
'uper': uper,
'xer': xer
}
try:
codec = codecs[codec]
except KeyError:
raise CompileError("Unsupported codec '{}'.".format(codec))
if any_defined_by_choices:
_compile_any_defined_by_choices(specification,
any_defined_by_choices)
return Specification(codec.compile_dict(specification,
numeric_enums),
codec.decode_length,
type_checker.compile_dict(specification,
def format_type_inner(self, type_, checker):
if isinstance(type_, uper.Integer):
return self.format_integer_inner(type_, checker)
elif isinstance(type_, uper.Real):
return self.format_real_inner()
elif isinstance(type_, uper.Null):
return [], []
elif isinstance(type_, uper.Boolean):
return self.format_boolean_inner()
elif is_user_type(type_):
return self.format_user_type_inner(type_.type_name,
type_.module_name)
elif isinstance(type_, uper.OctetString):
return self.format_octet_string_inner(type_, checker)
elif isinstance(type_, uper.Sequence):
return self.format_sequence_inner(type_, checker)
elif isinstance(type_, uper.Choice):
return self.format_choice_inner(type_, checker)
elif isinstance(type_, uper.SequenceOf):
return self.format_sequence_of_inner(type_, checker)
elif isinstance(type_, uper.Enumerated):
return self.format_enumerated_inner(type_)
def format_type(self, type_, checker):
if isinstance(type_, uper.Integer):
return self.format_integer(checker)
elif isinstance(type_, uper.Boolean):
return self.format_boolean()
elif isinstance(type_, uper.Real):
return self.format_real()
elif isinstance(type_, uper.Null):
return []
elif is_user_type(type_):
return self.format_user_type(type_.type_name,
type_.module_name)
elif isinstance(type_, uper.OctetString):
return self.format_octet_string(checker)
elif isinstance(type_, uper.Sequence):
return self.format_sequence(type_, checker)
elif isinstance(type_, uper.Choice):
return self.format_choice(type_, checker)
elif isinstance(type_, uper.SequenceOf):
return self.format_sequence_of(type_, checker)
elif isinstance(type_, uper.Enumerated):
return self.format_enumerated(type_)
def format_type_inner(self, type_, checker):
if isinstance(type_, uper.Integer):
return self.format_integer_inner(type_, checker)
elif isinstance(type_, uper.Real):
return self.format_real_inner()
elif isinstance(type_, uper.Null):
return [], []
elif isinstance(type_, uper.Boolean):
return self.format_boolean_inner()
elif is_user_type(type_):
return self.format_user_type_inner()
elif isinstance(type_, uper.OctetString):
return self.format_octet_string_inner(type_, checker)
elif isinstance(type_, uper.Sequence):
return self.format_sequence_inner(type_, checker)
elif isinstance(type_, uper.Choice):
return self.format_choice_inner(type_, checker)
elif isinstance(type_, uper.SequenceOf):
return self.format_sequence_of_inner(type_, checker)
elif isinstance(type_, uper.Enumerated):
return self.format_enumerated_inner(type_)
else:
raise self.error(type_)
def format_type_inner(self, type_, checker):
if isinstance(type_, uper.Integer):
return self.format_integer_inner(type_, checker)
elif isinstance(type_, uper.Real):
return self.format_real_inner()
elif isinstance(type_, uper.Null):
return [], []
elif isinstance(type_, uper.Boolean):
return self.format_boolean_inner()
elif is_user_type(type_):
return self.format_user_type_inner()
elif isinstance(type_, uper.OctetString):
return self.format_octet_string_inner(type_, checker)
elif isinstance(type_, uper.Sequence):
return self.format_sequence_inner(type_, checker)
elif isinstance(type_, uper.Choice):
return self.format_choice_inner(type_, checker)
elif isinstance(type_, uper.SequenceOf):
return self.format_sequence_of_inner(type_, checker)
elif isinstance(type_, uper.Enumerated):
return self.format_enumerated_inner(type_)
else:
raise self.error(type_)
def format_type_inner(self, type_, checker):
if isinstance(type_, uper.Integer):
return self.format_integer_inner(type_, checker)
elif isinstance(type_, uper.Real):
return self.format_real_inner()
elif isinstance(type_, uper.Null):
return [], []
elif isinstance(type_, uper.Boolean):
return self.format_boolean_inner()
elif is_user_type(type_):
return self.format_user_type_inner()
elif isinstance(type_, uper.OctetString):
return self.format_octet_string_inner(type_, checker)
elif isinstance(type_, uper.Sequence):
return self.format_sequence_inner(type_, checker)
elif isinstance(type_, uper.Choice):
return self.format_choice_inner(type_, checker)
elif isinstance(type_, uper.SequenceOf):
return self.format_sequence_of_inner(type_, checker)
elif isinstance(type_, uper.Enumerated):
return self.format_enumerated_inner(type_)
else:
raise self.error(type_)
if isinstance(type_, uper.Integer):
return self.format_integer_inner(type_, checker)
elif isinstance(type_, uper.Real):
return self.format_real_inner()
elif isinstance(type_, uper.Null):
return [], []
elif isinstance(type_, uper.Boolean):
return self.format_boolean_inner()
elif is_user_type(type_):
return self.format_user_type_inner(type_.type_name,
type_.module_name)
elif isinstance(type_, uper.OctetString):
return self.format_octet_string_inner(type_, checker)
elif isinstance(type_, uper.Sequence):
return self.format_sequence_inner(type_, checker)
elif isinstance(type_, uper.Choice):
return self.format_choice_inner(type_, checker)
elif isinstance(type_, uper.SequenceOf):
return self.format_sequence_of_inner(type_, checker)
elif isinstance(type_, uper.Enumerated):
return self.format_enumerated_inner(type_)
else:
raise self.error(type_)
def format_type_inner(self, type_, checker):
if isinstance(type_, uper.Integer):
return self.format_integer_inner(type_, checker)
elif isinstance(type_, uper.Real):
return self.format_real_inner()
elif isinstance(type_, uper.Null):
return [], []
elif isinstance(type_, uper.Boolean):
return self.format_boolean_inner()
elif is_user_type(type_):
return self.format_user_type_inner()
elif isinstance(type_, uper.OctetString):
return self.format_octet_string_inner(type_, checker)
elif isinstance(type_, uper.Sequence):
return self.format_sequence_inner(type_, checker)
elif isinstance(type_, uper.Choice):
return self.format_choice_inner(type_, checker)
elif isinstance(type_, uper.SequenceOf):
return self.format_sequence_of_inner(type_, checker)
elif isinstance(type_, uper.Enumerated):
return self.format_enumerated_inner(type_)
else:
elif isinstance(type_, uper.Null):
return [], []
elif isinstance(type_, uper.Boolean):
return self.format_boolean_inner()
elif is_user_type(type_):
return self.format_user_type_inner(type_.type_name,
type_.module_name)
elif isinstance(type_, uper.OctetString):
return self.format_octet_string_inner(type_, checker)
elif isinstance(type_, uper.Sequence):
return self.format_sequence_inner(type_, checker)
elif isinstance(type_, uper.Choice):
return self.format_choice_inner(type_, checker)
elif isinstance(type_, uper.SequenceOf):
return self.format_sequence_of_inner(type_, checker)
elif isinstance(type_, uper.Enumerated):
return self.format_enumerated_inner(type_)
else:
raise self.error(type_)