Skip to content

Commit

Permalink
Merge pull request #3 from alexdewar/autoadd_licence
Browse files Browse the repository at this point in the history
Add option to add BSD 3-clause licence
  • Loading branch information
alexdewar authored May 28, 2024
2 parents 7e0f2f4 + 27a5882 commit 0d7c951
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"project_description": "",
"author": "Jane Doe",
"author_email": "jane_doe@imperial.ac.uk",
"use_bsd3_licence": false,
"_copy_without_render": [".github"],
"__prompts__": {
"project_name": "Enter a human-readable name for the project",
"project_slug": "Enter a name for the Python package",
"project_description": "Enter a brief description of the project",
"author": "Enter your full name",
"author_email": "Enter your email address"
"author_email": "Enter your email address",
"use_bsd3_licence": "Whether to use Imperial's default open-source licence (BSD 3-clause)"
}
}
10 changes: 10 additions & 0 deletions hooks/post_gen_project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os

REMOVE_PATHS = [
"{% if not cookiecutter.use_bsd3_licence %}LICENSE{% endif %}"
]

for path in REMOVE_PATHS:
path = path.strip()
if path and os.path.exists(path):
os.unlink(path) if os.path.isfile(path) else os.rmdir(path)
28 changes: 28 additions & 0 deletions {{ cookiecutter.project_slug }}/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
BSD 3-Clause License

Copyright (c) 2024, Alex Dewar

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0 comments on commit 0d7c951

Please sign in to comment.