Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# 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()
'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)
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()
# 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)
# 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)
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)
}
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)