Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
... import uavcan.si.sample.volumetric_flow_rate
... except (ImportError, AttributeError):
... _ = pyuavcan.dsdl.generate_package(root_namespace_directory='tests/dsdl/namespaces/sirius_cyber_corp',
... lookup_directories=['tests/public_regulated_data_types/uavcan'],
... output_directory=dsdl_generated_dir)
... _ = pyuavcan.dsdl.generate_package(root_namespace_directory='tests/public_regulated_data_types/uavcan',
... output_directory=dsdl_generated_dir)
... importlib.invalidate_caches()
... import sirius_cyber_corp
... import uavcan.si.sample.volumetric_flow_rate
"""
# Read the DSDL definitions
if isinstance(lookup_directories, (str, bytes)):
# https://forum.uavcan.org/t/nestedrootnamespaceerror-in-basic-usage-demo/794
raise TypeError(f'Lookup directories shall be an iterable of strings, not {type(lookup_directories).__name__}')
composite_types = pydsdl.read_namespace(root_namespace_directory=str(root_namespace_directory),
lookup_directories=list(map(str, lookup_directories or [])),
allow_unregulated_fixed_port_id=allow_unregulated_fixed_port_id)
root_namespace_name, = set(map(lambda x: x.root_namespace, composite_types)) # type: str,
# Template primitives
filters = {
'pickle': _pickle_object,
'numpy_scalar_type': _numpy_scalar_type,
}
tests = {
'PaddingField': lambda x: isinstance(x, pydsdl.PaddingField),
'saturated': _test_if_saturated,
}
# Generate code