How to use nunavut - 7 common examples

To help you get started, we’ve selected a few nunavut examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UAVCAN / pyuavcan / pyuavcan / dsdl / _compiler.py View on Github external
# 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
    output_directory = pathlib.Path.cwd() if output_directory is None else output_directory
    language_context = nunavut.lang.LanguageContext('py', namespace_output_stem='__init__')
    root_ns = nunavut.build_namespace_tree(types=composite_types,
                                           root_namespace_dir=root_namespace_directory,
                                           output_dir=str(output_directory),
                                           language_context=language_context)
    generator = nunavut.jinja.Generator(namespace=root_ns,
                                        generate_namespace_types=nunavut.YesNoDefault.YES,
                                        templates_dir=_TEMPLATE_DIRECTORY,
                                        followlinks=True,
                                        additional_filters=filters,
                                        additional_tests=tests,
                                        post_processors=[
                                            nunavut.postprocessors.SetFileMode(_OUTPUT_FILE_PERMISSIONS),
                                            nunavut.postprocessors.LimitEmptyLines(2),
                                            nunavut.postprocessors.TrimTrailingWhitespace(),
                                        ])
    generator.generate_all()
github UAVCAN / pyuavcan / pyuavcan / dsdl / _compiler.py View on Github external
'numpy_scalar_type': _numpy_scalar_type,
    }

    tests = {
        'PaddingField': lambda x: isinstance(x, pydsdl.PaddingField),
        'saturated':    _test_if_saturated,
    }

    # Generate code
    output_directory = pathlib.Path.cwd() if output_directory is None else output_directory
    language_context = nunavut.lang.LanguageContext('py', namespace_output_stem='__init__')
    root_ns = nunavut.build_namespace_tree(types=composite_types,
                                           root_namespace_dir=root_namespace_directory,
                                           output_dir=str(output_directory),
                                           language_context=language_context)
    generator = nunavut.jinja.Generator(namespace=root_ns,
                                        generate_namespace_types=nunavut.YesNoDefault.YES,
                                        templates_dir=_TEMPLATE_DIRECTORY,
                                        followlinks=True,
                                        additional_filters=filters,
                                        additional_tests=tests,
                                        post_processors=[
                                            nunavut.postprocessors.SetFileMode(_OUTPUT_FILE_PERMISSIONS),
                                            nunavut.postprocessors.LimitEmptyLines(2),
                                            nunavut.postprocessors.TrimTrailingWhitespace(),
                                        ])
    generator.generate_all()

    return GeneratedPackageInfo(path=pathlib.Path(output_directory) / pathlib.Path(root_namespace_name),
                                models=composite_types,
                                name=root_namespace_name)
github UAVCAN / pyuavcan / pyuavcan / dsdl / _compiler.py View on Github external
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
    output_directory = pathlib.Path.cwd() if output_directory is None else output_directory
    language_context = nunavut.lang.LanguageContext('py', namespace_output_stem='__init__')
    root_ns = nunavut.build_namespace_tree(types=composite_types,
                                           root_namespace_dir=root_namespace_directory,
                                           output_dir=str(output_directory),
                                           language_context=language_context)
    generator = nunavut.jinja.Generator(namespace=root_ns,
                                        generate_namespace_types=nunavut.YesNoDefault.YES,
                                        templates_dir=_TEMPLATE_DIRECTORY,
                                        followlinks=True,
                                        additional_filters=filters,
                                        additional_tests=tests,
                                        post_processors=[
                                            nunavut.postprocessors.SetFileMode(_OUTPUT_FILE_PERMISSIONS),
                                            nunavut.postprocessors.LimitEmptyLines(2),
                                            nunavut.postprocessors.TrimTrailingWhitespace(),
                                        ])
    generator.generate_all()
github UAVCAN / pyuavcan / pyuavcan / dsdl / _compiler.py View on Github external
# Generate code
    output_directory = pathlib.Path.cwd() if output_directory is None else output_directory
    language_context = nunavut.lang.LanguageContext('py', namespace_output_stem='__init__')
    root_ns = nunavut.build_namespace_tree(types=composite_types,
                                           root_namespace_dir=root_namespace_directory,
                                           output_dir=str(output_directory),
                                           language_context=language_context)
    generator = nunavut.jinja.Generator(namespace=root_ns,
                                        generate_namespace_types=nunavut.YesNoDefault.YES,
                                        templates_dir=_TEMPLATE_DIRECTORY,
                                        followlinks=True,
                                        additional_filters=filters,
                                        additional_tests=tests,
                                        post_processors=[
                                            nunavut.postprocessors.SetFileMode(_OUTPUT_FILE_PERMISSIONS),
                                            nunavut.postprocessors.LimitEmptyLines(2),
                                            nunavut.postprocessors.TrimTrailingWhitespace(),
                                        ])
    generator.generate_all()

    return GeneratedPackageInfo(path=pathlib.Path(output_directory) / pathlib.Path(root_namespace_name),
                                models=composite_types,
                                name=root_namespace_name)
github UAVCAN / pyuavcan / pyuavcan / dsdl / _compiler.py View on Github external
# Generate code
    output_directory = pathlib.Path.cwd() if output_directory is None else output_directory
    language_context = nunavut.lang.LanguageContext('py', namespace_output_stem='__init__')
    root_ns = nunavut.build_namespace_tree(types=composite_types,
                                           root_namespace_dir=root_namespace_directory,
                                           output_dir=str(output_directory),
                                           language_context=language_context)
    generator = nunavut.jinja.Generator(namespace=root_ns,
                                        generate_namespace_types=nunavut.YesNoDefault.YES,
                                        templates_dir=_TEMPLATE_DIRECTORY,
                                        followlinks=True,
                                        additional_filters=filters,
                                        additional_tests=tests,
                                        post_processors=[
                                            nunavut.postprocessors.SetFileMode(_OUTPUT_FILE_PERMISSIONS),
                                            nunavut.postprocessors.LimitEmptyLines(2),
                                            nunavut.postprocessors.TrimTrailingWhitespace(),
                                        ])
    generator.generate_all()

    return GeneratedPackageInfo(path=pathlib.Path(output_directory) / pathlib.Path(root_namespace_name),
                                models=composite_types,
                                name=root_namespace_name)
github UAVCAN / pyuavcan / pyuavcan / dsdl / _compiler.py View on Github external
output_directory = pathlib.Path.cwd() if output_directory is None else output_directory
    language_context = nunavut.lang.LanguageContext('py', namespace_output_stem='__init__')
    root_ns = nunavut.build_namespace_tree(types=composite_types,
                                           root_namespace_dir=root_namespace_directory,
                                           output_dir=str(output_directory),
                                           language_context=language_context)
    generator = nunavut.jinja.Generator(namespace=root_ns,
                                        generate_namespace_types=nunavut.YesNoDefault.YES,
                                        templates_dir=_TEMPLATE_DIRECTORY,
                                        followlinks=True,
                                        additional_filters=filters,
                                        additional_tests=tests,
                                        post_processors=[
                                            nunavut.postprocessors.SetFileMode(_OUTPUT_FILE_PERMISSIONS),
                                            nunavut.postprocessors.LimitEmptyLines(2),
                                            nunavut.postprocessors.TrimTrailingWhitespace(),
                                        ])
    generator.generate_all()

    return GeneratedPackageInfo(path=pathlib.Path(output_directory) / pathlib.Path(root_namespace_name),
                                models=composite_types,
                                name=root_namespace_name)
github UAVCAN / pyuavcan / pyuavcan / dsdl / _compiler.py View on Github external
}

    tests = {
        'PaddingField': lambda x: isinstance(x, pydsdl.PaddingField),
        'saturated':    _test_if_saturated,
    }

    # Generate code
    output_directory = pathlib.Path.cwd() if output_directory is None else output_directory
    language_context = nunavut.lang.LanguageContext('py', namespace_output_stem='__init__')
    root_ns = nunavut.build_namespace_tree(types=composite_types,
                                           root_namespace_dir=root_namespace_directory,
                                           output_dir=str(output_directory),
                                           language_context=language_context)
    generator = nunavut.jinja.Generator(namespace=root_ns,
                                        generate_namespace_types=nunavut.YesNoDefault.YES,
                                        templates_dir=_TEMPLATE_DIRECTORY,
                                        followlinks=True,
                                        additional_filters=filters,
                                        additional_tests=tests,
                                        post_processors=[
                                            nunavut.postprocessors.SetFileMode(_OUTPUT_FILE_PERMISSIONS),
                                            nunavut.postprocessors.LimitEmptyLines(2),
                                            nunavut.postprocessors.TrimTrailingWhitespace(),
                                        ])
    generator.generate_all()

    return GeneratedPackageInfo(path=pathlib.Path(output_directory) / pathlib.Path(root_namespace_name),
                                models=composite_types,
                                name=root_namespace_name)

nunavut

Generate code from DSDL using Jinja2 templates.

MIT
Latest version published 1 year ago

Package Health Score

53 / 100
Full package analysis