From 61ddb4d1216048f443283cfd8d19b27f614cdee1 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 28 Nov 2022 17:55:01 -0500 Subject: [PATCH 01/21] changed placeholder unit test to a script --- tests/test_licenses.py => scripts/check_licenses.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) rename tests/test_licenses.py => scripts/check_licenses.py (92%) diff --git a/tests/test_licenses.py b/scripts/check_licenses.py similarity index 92% rename from tests/test_licenses.py rename to scripts/check_licenses.py index a501de208..eb1e0819e 100644 --- a/tests/test_licenses.py +++ b/scripts/check_licenses.py @@ -1,14 +1,12 @@ -"""Unit tests for licenses""" + import os import re from pprint import pprint from pathlib import Path -import pytest - # script to check if licenses generated have placeholders not replaced with cookiecutter rendering -def test_scripts_for_placeholders(): +def check_scripts_for_placeholders(): brackets = [] for filename in os.listdir('../{{cookiecutter.project_slug}}/licenses'): file = open('../{{cookiecutter.project_slug}}/licenses/' + filename, 'r', encoding="utf8") @@ -35,3 +33,6 @@ def test_scripts_for_placeholders(): print() pprint(brackets) assert(len(brackets) == 0) + +if __name__ == "__main__": + check_scripts_for_placeholders() From 3045e4fb774d309504d705bae65789aa697b5588 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 28 Nov 2022 22:08:28 -0500 Subject: [PATCH 02/21] added temporary placeholder file --- .../licenses/-temporary-placeholder.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 {{cookiecutter.project_slug}}/licenses/-temporary-placeholder.txt diff --git a/{{cookiecutter.project_slug}}/licenses/-temporary-placeholder.txt b/{{cookiecutter.project_slug}}/licenses/-temporary-placeholder.txt new file mode 100644 index 000000000..f5be03a8c --- /dev/null +++ b/{{cookiecutter.project_slug}}/licenses/-temporary-placeholder.txt @@ -0,0 +1 @@ +{{ cookiecutter.open_source_license }} From 2923cc84c28c9f357db52899dff1e7548bb371c5 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 28 Nov 2022 22:30:05 -0500 Subject: [PATCH 03/21] fiddling with licenses.json file pathing --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 90f9f7fba..70b127a38 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - with open('../licenses.json', 'r') as f: + with open('/licenses.json', 'r') as f: titles_dict = json.load(f) # access the title to filename dictionary to find the correct file # using a dictionary instead of looping reduces time complexity From de9a6b656d3b8b393c2f939178399dbe31442015 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 28 Nov 2022 22:36:39 -0500 Subject: [PATCH 04/21] fiddling with licenses.json file pathing --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 70b127a38..99af7b92b 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - with open('/licenses.json', 'r') as f: + with open('licenses.json', 'r') as f: titles_dict = json.load(f) # access the title to filename dictionary to find the correct file # using a dictionary instead of looping reduces time complexity From c4ec9cd1640635e65504ef02ca0e3a190713a2b7 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 28 Nov 2022 22:58:10 -0500 Subject: [PATCH 05/21] fiddling with licenses.json file pathing --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 99af7b92b..594cbb12e 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - with open('licenses.json', 'r') as f: + with open(os.path.join("cookiecutter-django", "licenses.json")) as f: titles_dict = json.load(f) # access the title to filename dictionary to find the correct file # using a dictionary instead of looping reduces time complexity From 6f7b3e34e4ee91bd0c4a2e3b1278706b4c00c72f Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 28 Nov 2022 23:04:26 -0500 Subject: [PATCH 06/21] fiddling with licenses.json file pathing --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 594cbb12e..4bb90dd07 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - with open(os.path.join("cookiecutter-django", "licenses.json")) as f: + with open(os.path.join("..", "licenses.json")) as f: titles_dict = json.load(f) # access the title to filename dictionary to find the correct file # using a dictionary instead of looping reduces time complexity From 5c37807754b1ef04c59ef536a7c0d678397d3a7c Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 28 Nov 2022 23:13:40 -0500 Subject: [PATCH 07/21] fiddling with licenses.json file pathing --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 4bb90dd07..4526c16ba 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - with open(os.path.join("..", "licenses.json")) as f: + with open(os.path.join(os.pardir, "licenses.json")) as f: titles_dict = json.load(f) # access the title to filename dictionary to find the correct file # using a dictionary instead of looping reduces time complexity From cda8b5bc46c06936e9500a77a609740aec778071 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 28 Nov 2022 23:19:22 -0500 Subject: [PATCH 08/21] fiddling with licenses.json file pathing --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 4526c16ba..5533301af 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - with open(os.path.join(os.pardir, "licenses.json")) as f: + with open(os.getcwd(), 'r') as f: titles_dict = json.load(f) # access the title to filename dictionary to find the correct file # using a dictionary instead of looping reduces time complexity From 699272c601dc7074faf315bd077c197cf239acdc Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 28 Nov 2022 23:25:20 -0500 Subject: [PATCH 09/21] fiddling with licenses.json file pathing --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 5533301af..b154fc412 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - with open(os.getcwd(), 'r') as f: + with open(os.path.join("", "licenses.json")) as f: titles_dict = json.load(f) # access the title to filename dictionary to find the correct file # using a dictionary instead of looping reduces time complexity From 15109ab31eee97ad5de5df98a0584967adb72af5 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Tue, 29 Nov 2022 16:19:11 -0500 Subject: [PATCH 10/21] still fiddling with licenses file pathing --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index b154fc412..3a908a52d 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - with open(os.path.join("", "licenses.json")) as f: + with open(os.path.join("/", "licenses.json")) as f: titles_dict = json.load(f) # access the title to filename dictionary to find the correct file # using a dictionary instead of looping reduces time complexity From b0699ce289f60406c950204fe0a14c2c0468afc9 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Tue, 29 Nov 2022 16:28:37 -0500 Subject: [PATCH 11/21] moved licenses.json to avoid filepathing issues hopefully? --- hooks/post_gen_project.py | 2 +- scripts/update_licenses.py | 2 +- .../licenses/licenses.json | 0 3 files changed, 2 insertions(+), 2 deletions(-) rename licenses.json => {{cookiecutter.project_slug}}/licenses/licenses.json (100%) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 3a908a52d..996f57611 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - with open(os.path.join("/", "licenses.json")) as f: + with open(os.path.join("licenses", "licenses.json")) as f: titles_dict = json.load(f) # access the title to filename dictionary to find the correct file # using a dictionary instead of looping reduces time complexity diff --git a/scripts/update_licenses.py b/scripts/update_licenses.py index 66146e110..0cc680b35 100644 --- a/scripts/update_licenses.py +++ b/scripts/update_licenses.py @@ -28,7 +28,7 @@ def main() -> None: (license_dir / file.name).write_text(replace_content_options(content)) # write the titles dictionary to a json file and put it in workflows so it can be accessed by other files - with open('licenses.json', 'w') as licenses_dict: + with open('{{cookiecutter.project_slug}}/licenses/licenses.json', 'w') as licenses_dict: json.dump(titles_dict, licenses_dict, indent=2) # Put "Not open source" at front so people know it's an option front_options = [ diff --git a/licenses.json b/{{cookiecutter.project_slug}}/licenses/licenses.json similarity index 100% rename from licenses.json rename to {{cookiecutter.project_slug}}/licenses/licenses.json From b869dc4dd9eff5c5b9b0677d6834fb5027c70559 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Tue, 29 Nov 2022 16:45:26 -0500 Subject: [PATCH 12/21] fixes bug for when a not open source license is selected --- hooks/post_gen_project.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 996f57611..37cb53cac 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,6 +331,11 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() + if selected_title == "Not open source": + os.remove("CONTRIBUTORS.txt") + shutil.rmtree("licenses") + return + with open(os.path.join("licenses", "licenses.json")) as f: titles_dict = json.load(f) # access the title to filename dictionary to find the correct file @@ -342,8 +347,6 @@ def handle_licenses(): # +2 to get rid of the --- and and an extra new line f.writelines(contents[contents.index("---\n", 1) + 2:]) - if selected_title == "Not open source": - os.remove("CONTRIBUTORS.txt") shutil.rmtree("licenses") From 5f9d74ae7c8fc1800edee30296b4d7790f05a2f1 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Tue, 29 Nov 2022 16:46:38 -0500 Subject: [PATCH 13/21] forgot newline character to fix previous bug --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 37cb53cac..3ecc97638 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - if selected_title == "Not open source": + if selected_title == "Not open source\n": os.remove("CONTRIBUTORS.txt") shutil.rmtree("licenses") return From ebbe28d93d82968f0cd09dba28a7e14b86a151bb Mon Sep 17 00:00:00 2001 From: alexzvk Date: Tue, 29 Nov 2022 17:09:45 -0500 Subject: [PATCH 14/21] style changes --- hooks/post_gen_project.py | 8 +++++--- scripts/check_licenses.py | 11 ++++++----- scripts/update_licenses.py | 3 +-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 3ecc97638..2e2d10a49 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -10,11 +10,11 @@ TODO: restrict Cookiecutter Django project initialization to """ from __future__ import print_function +import json import os import random import shutil import string -import json try: # Inspired by @@ -343,9 +343,11 @@ def handle_licenses(): with open(os.path.join("licenses", titles_dict[selected_title])) as f: contents = f.readlines() - with open(special_license_files.get(titles_dict[selected_title], "LICENSE"), "w") as f: + with open( + special_license_files.get(titles_dict[selected_title], "LICENSE"), "w" + ) as f: # +2 to get rid of the --- and and an extra new line - f.writelines(contents[contents.index("---\n", 1) + 2:]) + f.writelines(contents[contents.index("---\n", 1) + 2 :]) shutil.rmtree("licenses") diff --git a/scripts/check_licenses.py b/scripts/check_licenses.py index eb1e0819e..6795cd177 100644 --- a/scripts/check_licenses.py +++ b/scripts/check_licenses.py @@ -2,10 +2,9 @@ import os import re from pprint import pprint -from pathlib import Path -# script to check if licenses generated have placeholders not replaced with cookiecutter rendering +# script to check if licenses generated have placeholders not replaced def check_scripts_for_placeholders(): brackets = [] for filename in os.listdir('../{{cookiecutter.project_slug}}/licenses'): @@ -13,8 +12,9 @@ def check_scripts_for_placeholders(): # 'found' stores all found bracket instances found = [] - # dashes counts the '---\n' lines in the licenses. it skips instances of brackets until after the first 2 as to - # skip the jekyll header + + # dashes counts the '---\n' lines in the licenses. + # it skips instances of brackets until after 2 as to skip the jekyll header dashes = 0 for i, line in enumerate(file.readlines()): if line == '---\n': @@ -26,7 +26,8 @@ def check_scripts_for_placeholders(): if line != []: found += (i, line) - # add any found instaces of bracket placeholders to the brackets array, and print it after the loop is executed + # add any found instances of placeholders to the brackets array + # print it after the loop is executed if found != []: brackets += (filename, found) if len(brackets) > 0: diff --git a/scripts/update_licenses.py b/scripts/update_licenses.py index 0cc680b35..5b4d6f55f 100644 --- a/scripts/update_licenses.py +++ b/scripts/update_licenses.py @@ -21,13 +21,12 @@ def main() -> None: content = codecs.decode(file.decoded_content) # make below line into a dictionary mapping to filename titles_dict[content.split("\n", maxsplit=2)[1].replace("title: ", "")] = file.name - #titles.append(content.split("\n", maxsplit=2)[1].replace("title: ", "")) path = license_dir / file.name if not path.is_file(): path.touch() (license_dir / file.name).write_text(replace_content_options(content)) - # write the titles dictionary to a json file and put it in workflows so it can be accessed by other files + # write the titles dictionary to a json file so it can be accessed by other files with open('{{cookiecutter.project_slug}}/licenses/licenses.json', 'w') as licenses_dict: json.dump(titles_dict, licenses_dict, indent=2) # Put "Not open source" at front so people know it's an option From 1775bf0e1ab436a5a4f6a928f46846a70ac4de33 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Tue, 29 Nov 2022 17:19:06 -0500 Subject: [PATCH 15/21] trying to fix confusing colon error --- hooks/post_gen_project.py | 2 +- scripts/check_licenses.py | 14 ++++++++------ scripts/update_licenses.py | 12 +++++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 2e2d10a49..8111b2b7d 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -347,7 +347,7 @@ def handle_licenses(): special_license_files.get(titles_dict[selected_title], "LICENSE"), "w" ) as f: # +2 to get rid of the --- and and an extra new line - f.writelines(contents[contents.index("---\n", 1) + 2 :]) + f.writelines(contents[contents.index("---\n", 1) + 2:]) shutil.rmtree("licenses") diff --git a/scripts/check_licenses.py b/scripts/check_licenses.py index 6795cd177..d14b84e4e 100644 --- a/scripts/check_licenses.py +++ b/scripts/check_licenses.py @@ -1,4 +1,3 @@ - import os import re from pprint import pprint @@ -7,8 +6,10 @@ from pprint import pprint # script to check if licenses generated have placeholders not replaced def check_scripts_for_placeholders(): brackets = [] - for filename in os.listdir('../{{cookiecutter.project_slug}}/licenses'): - file = open('../{{cookiecutter.project_slug}}/licenses/' + filename, 'r', encoding="utf8") + for filename in os.listdir("../{{cookiecutter.project_slug}}/licenses"): + file = open( + "../{{cookiecutter.project_slug}}/licenses/" + filename, encoding="utf8" + ) # 'found' stores all found bracket instances found = [] @@ -17,12 +18,12 @@ def check_scripts_for_placeholders(): # it skips instances of brackets until after 2 as to skip the jekyll header dashes = 0 for i, line in enumerate(file.readlines()): - if line == '---\n': + if line == "---\n": dashes += 1 # skips any possible brackets until the jekyll header is skipped if dashes < 2: continue - line = re.findall(r'\[.*\]', line) + line = re.findall(r"\[.*\]", line) if line != []: found += (i, line) @@ -33,7 +34,8 @@ def check_scripts_for_placeholders(): if len(brackets) > 0: print() pprint(brackets) - assert(len(brackets) == 0) + assert len(brackets) == 0 + if __name__ == "__main__": check_scripts_for_placeholders() diff --git a/scripts/update_licenses.py b/scripts/update_licenses.py index 5b4d6f55f..562c31300 100644 --- a/scripts/update_licenses.py +++ b/scripts/update_licenses.py @@ -3,12 +3,14 @@ import json import os import re from pathlib import Path + from github import Github CURRENT_FILE = Path(__file__) ROOT = CURRENT_FILE.parents[1] GITHUB_TOKEN = os.getenv("GITHUB_TOKEN", None) + def main() -> None: """ Script entry point. @@ -20,14 +22,18 @@ def main() -> None: for file in repo.get_contents("_licenses", "gh-pages"): content = codecs.decode(file.decoded_content) # make below line into a dictionary mapping to filename - titles_dict[content.split("\n", maxsplit=2)[1].replace("title: ", "")] = file.name + titles_dict[ + content.split("\n", maxsplit=2)[1].replace("title: ", "") + ] = file.name path = license_dir / file.name if not path.is_file(): path.touch() (license_dir / file.name).write_text(replace_content_options(content)) # write the titles dictionary to a json file so it can be accessed by other files - with open('{{cookiecutter.project_slug}}/licenses/licenses.json', 'w') as licenses_dict: + with open( + "{{cookiecutter.project_slug}}/licenses/licenses.json", "w" + ) as licenses_dict: json.dump(titles_dict, licenses_dict, indent=2) # Put "Not open source" at front so people know it's an option front_options = [ @@ -59,7 +65,7 @@ def update_cookiecutter(titles: list): with open("cookiecutter.json") as f: data = json.load(f) data["open_source_license"] = titles - with open("cookiecutter.json", "wt") as f: + with open("cookiecutter.json", "w") as f: json.dump(data, f, indent=2) From b0e361daf78d989340046186b81be54bee691238 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Tue, 29 Nov 2022 17:21:16 -0500 Subject: [PATCH 16/21] now passing all pre-commit checks --- hooks/post_gen_project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 8111b2b7d..8a2b22c75 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -347,7 +347,8 @@ def handle_licenses(): special_license_files.get(titles_dict[selected_title], "LICENSE"), "w" ) as f: # +2 to get rid of the --- and and an extra new line - f.writelines(contents[contents.index("---\n", 1) + 2:]) + i = contents.index("---\n", 1) + 2 + f.writelines(contents[i:]) shutil.rmtree("licenses") From 73a7ed491d845b017891c2c8e1bd505428bbac01 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Tue, 29 Nov 2022 18:10:13 -0500 Subject: [PATCH 17/21] fixed dictionary error where key queries had newlines --- hooks/post_gen_project.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 8a2b22c75..a8898e8e7 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -330,7 +330,8 @@ def handle_licenses(): } with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline() - + selected_title.rstrip() + if selected_title == "Not open source\n": os.remove("CONTRIBUTORS.txt") shutil.rmtree("licenses") From a05722fc929184719cca93c971b256c1f0c5b09c Mon Sep 17 00:00:00 2001 From: alexzvk Date: Tue, 29 Nov 2022 18:19:02 -0500 Subject: [PATCH 18/21] forgot variable assignment for previous commit --- hooks/post_gen_project.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index a8898e8e7..f74e74aec 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -329,9 +329,8 @@ def handle_licenses(): "The Unlicense": "UNLICENSE", } with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: - selected_title = f.readline() - selected_title.rstrip() - + selected_title = f.readline().rstrip() + if selected_title == "Not open source\n": os.remove("CONTRIBUTORS.txt") shutil.rmtree("licenses") From 96e5f8565ca8a077f2edb1f7199f93928edb7410 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 5 Dec 2022 17:00:39 -0500 Subject: [PATCH 19/21] fixed bug with not open source option --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index f74e74aec..ce47568b1 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -331,7 +331,7 @@ def handle_licenses(): with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: selected_title = f.readline().rstrip() - if selected_title == "Not open source\n": + if selected_title == "Not open source": os.remove("CONTRIBUTORS.txt") shutil.rmtree("licenses") return From d03cc15f41b4f460dad091a16a525a90e8b12697 Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 5 Dec 2022 17:25:01 -0500 Subject: [PATCH 20/21] attempt at workaround using temporary placeholder --- hooks/post_gen_project.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index ce47568b1..045fa8d0b 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -328,8 +328,8 @@ def handle_licenses(): "GNU Lesser General Public License v3.0": "COPYING.LESSER", "The Unlicense": "UNLICENSE", } - with open(os.path.join("licenses", "-temporary-placeholder.txt")) as f: - selected_title = f.readline().rstrip() + + selected_title = "{{ cookiecutter.open_source_license }}" if selected_title == "Not open source": os.remove("CONTRIBUTORS.txt") From b6e5d495b5064943dfb4281508d4096912a7014f Mon Sep 17 00:00:00 2001 From: alexzvk Date: Mon, 5 Dec 2022 17:32:59 -0500 Subject: [PATCH 21/21] fixed temporary workaround quotes error --- hooks/post_gen_project.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hooks/post_gen_project.py b/hooks/post_gen_project.py index 045fa8d0b..6927f3804 100644 --- a/hooks/post_gen_project.py +++ b/hooks/post_gen_project.py @@ -329,7 +329,7 @@ def handle_licenses(): "The Unlicense": "UNLICENSE", } - selected_title = "{{ cookiecutter.open_source_license }}" + selected_title = """{{ cookiecutter.open_source_license }}""" if selected_title == "Not open source": os.remove("CONTRIBUTORS.txt")