This is an automated email from the ASF dual-hosted git repository. machristie pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/airavata-cookiecutter-django-output-view.git
commit 633348f340820179cbf1aa684198099873011166 Author: Marcus Christie <[email protected]> AuthorDate: Thu Jun 3 11:47:58 2021 -0400 Add a check for output_views.py, with mitigation instructions --- README.md | 13 +++++++++++++ hooks/pre_gen_project.py | 5 +++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index f9761f8..4b5d61a 100644 --- a/README.md +++ b/README.md @@ -27,3 +27,16 @@ Then run the following: When prompted for the name of the `custom_django_app_module_name`, give it the name of your Airavata Django app. Keeping with the example, you would supply `test_django_app`. + +## Converting output_views.py to a module directory + +If your Django app has an output_views.py file you'll get an error since this +cookiecutter assumes that `output_views` is a module directory. To convert it to +module directory: + +1. Create an `output_views/` directory in the same directory where your + output_views.py file lives. +2. Either, rename your `output_views.py` file to `output_views/__init__.py` +3. Or, create an empty `output_views/__init__.py` file and move/rename as + appropriate your `output_views.py` file to a file in the `output_views/` + directory. You'll need to update the entry_points in setup.cfg. diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index b7885d6..b4367df 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -24,3 +24,8 @@ if not os.path.isfile(os.path.join(django_app_module_dir, "apps.py")): if candidate is not None: print(f"Did you mean '{candidate}' instead of '{{cookiecutter.custom_django_app_module_name}}'?", file=sys.stderr) sys.exit(1) + +# Make sure that there isn't an output_views isn't a file +if os.path.isfile(os.path.join(django_app_module_dir, "{{cookiecutter.output_views_directory_name}}.py")): + print(f"ERROR: {os.path.join(django_app_module_dir, '{{cookiecutter.output_views_directory_name}}.py')} is a file. Convert to a module directory. See the README: https://github.com/machristie/cookiecutter-airavata-django-output-view.") + sys.exit(1)
