mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-02-18 04:20:51 +03:00
trying to fix confusing colon error
This commit is contained in:
parent
ebbe28d93d
commit
1775bf0e1a
|
@ -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")
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user