mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-22 01:26:57 +03:00
Reformat files using pre-commit
This commit is contained in:
parent
910697980f
commit
05264405ae
|
@ -444,9 +444,7 @@ 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
|
||||
i = contents.index("---\n", 1) + 2
|
||||
f.writelines(contents[i:])
|
||||
|
|
|
@ -7,9 +7,7 @@ from pprint import pprint
|
|||
def check_scripts_for_placeholders():
|
||||
brackets = []
|
||||
for filename in os.listdir("../{{cookiecutter.project_slug}}/licenses"):
|
||||
file = open(
|
||||
"../{{cookiecutter.project_slug}}/licenses/" + filename, encoding="utf8"
|
||||
)
|
||||
file = open("../{{cookiecutter.project_slug}}/licenses/" + filename, encoding="utf8")
|
||||
|
||||
# 'found' stores all found bracket instances
|
||||
found = []
|
||||
|
|
|
@ -22,18 +22,14 @@ 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 = [
|
||||
|
|
Loading…
Reference in New Issue
Block a user