Attention is currently required from: laforge, neels.
1 comment:
Patchset:
(Slight counter argument: This is not a map to the binary representation. […]
as far as I know the compiled asn1 representation loses the schema information/name, so you would need to access the schema instead. a somewhat concise way would be something like this, by getting the schema as well in compile_asn1_subdir and then working with the schema dict. this would basically leave the compiled asn1 alone and would not interfere with anything else:
def compile_asn1_subdir(subdir_name:str, codec='der'):
"""Helper function that compiles ASN.1 syntax from all files within given subdir"""
import asn1tools
asn_txt = ''
__ver = sys.version_info
if (__ver.major, __ver.minor) >= (3, 9):
for i in resources.files('pySim.esim').joinpath('asn1').joinpath(subdir_name).iterdir():
asn_txt += i.read_text()
asn_txt += "\n"
#else:
#print(resources.read_text(__name__, 'asn1/rsp.asn'))
asn1_schema = asn1tools.parse_string(asn_txt, codec=codec)
return asn1tools.compile_dict(asn1_schema, codec='ber'), asn1_schema
in saip/__init__.py
asn1, asn1_schema = compile_asn1_subdir('saip') # or asn, _ = compile_asn1_subdir(...) if schema not needed
somewhere else
from pySim.esim.saip import asn1_schema as saip_schema
print(saip_schema['PEDefinitions']['types']['AlgoParameter']['members'][0]['named-numbers'])
# {'milenage': 1, 'tuak': 2, 'usim-test-algorithm': 3}
To view, visit change 40201. To unsubscribe, or for help writing mail filters, visit settings.