From b9441f4c62aae76fd0b4555cab735d1159e2c50c Mon Sep 17 00:00:00 2001 From: thomas-bc Date: Tue, 30 Jan 2024 16:26:53 -0800 Subject: [PATCH] Verify cookiecutter input for invalid characters --- .../hooks/pre_gen_project.py | 8 ++++++++ .../cookiecutter-fprime-module/hooks/pre_gen_project.py | 8 ++++++++ .../cookiecutter-fprime-project/hooks/pre_gen_project.py | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/hooks/pre_gen_project.py create mode 100644 src/fprime/cookiecutter_templates/cookiecutter-fprime-module/hooks/pre_gen_project.py create mode 100644 src/fprime/cookiecutter_templates/cookiecutter-fprime-project/hooks/pre_gen_project.py diff --git a/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/hooks/pre_gen_project.py b/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/hooks/pre_gen_project.py new file mode 100644 index 00000000..71095098 --- /dev/null +++ b/src/fprime/cookiecutter_templates/cookiecutter-fprime-deployment/hooks/pre_gen_project.py @@ -0,0 +1,8 @@ +from fprime.util.cookiecutter_wrapper import is_valid_name + +name = "{{ cookiecutter.deployment_name }}" + +if is_valid_name(name) != "valid": + raise ValueError( + f"Unacceptable deployment name: {name}. Do not use spaces or special characters" + ) diff --git a/src/fprime/cookiecutter_templates/cookiecutter-fprime-module/hooks/pre_gen_project.py b/src/fprime/cookiecutter_templates/cookiecutter-fprime-module/hooks/pre_gen_project.py new file mode 100644 index 00000000..d57ba4d5 --- /dev/null +++ b/src/fprime/cookiecutter_templates/cookiecutter-fprime-module/hooks/pre_gen_project.py @@ -0,0 +1,8 @@ +from fprime.util.cookiecutter_wrapper import is_valid_name + +name = "{{ cookiecutter.module_name }}" + +if is_valid_name(name) != "valid": + raise ValueError( + f"Unacceptable module name: {name}. Do not use spaces or special characters" + ) diff --git a/src/fprime/cookiecutter_templates/cookiecutter-fprime-project/hooks/pre_gen_project.py b/src/fprime/cookiecutter_templates/cookiecutter-fprime-project/hooks/pre_gen_project.py new file mode 100644 index 00000000..9eb92453 --- /dev/null +++ b/src/fprime/cookiecutter_templates/cookiecutter-fprime-project/hooks/pre_gen_project.py @@ -0,0 +1,8 @@ +from fprime.util.cookiecutter_wrapper import is_valid_name + +name = "{{ cookiecutter.project_name }}" + +if is_valid_name(name) != "valid": + raise ValueError( + f"Unacceptable project name: {name}. Do not use spaces or special characters" + )