mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-25 11:04:04 +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:
|
with open(os.path.join("licenses", titles_dict[selected_title])) as f:
|
||||||
contents = f.readlines()
|
contents = f.readlines()
|
||||||
|
|
||||||
with open(
|
with open(special_license_files.get(titles_dict[selected_title], "LICENSE"), "w") as f:
|
||||||
special_license_files.get(titles_dict[selected_title], "LICENSE"), "w"
|
|
||||||
) as f:
|
|
||||||
# +2 to get rid of the --- and and an extra new line
|
# +2 to get rid of the --- and and an extra new line
|
||||||
i = contents.index("---\n", 1) + 2
|
i = contents.index("---\n", 1) + 2
|
||||||
f.writelines(contents[i:])
|
f.writelines(contents[i:])
|
||||||
|
|
|
@ -7,9 +7,7 @@ from pprint import pprint
|
||||||
def check_scripts_for_placeholders():
|
def check_scripts_for_placeholders():
|
||||||
brackets = []
|
brackets = []
|
||||||
for filename in os.listdir("../{{cookiecutter.project_slug}}/licenses"):
|
for filename in os.listdir("../{{cookiecutter.project_slug}}/licenses"):
|
||||||
file = open(
|
file = open("../{{cookiecutter.project_slug}}/licenses/" + filename, encoding="utf8")
|
||||||
"../{{cookiecutter.project_slug}}/licenses/" + filename, encoding="utf8"
|
|
||||||
)
|
|
||||||
|
|
||||||
# 'found' stores all found bracket instances
|
# 'found' stores all found bracket instances
|
||||||
found = []
|
found = []
|
||||||
|
|
|
@ -22,18 +22,14 @@ def main() -> None:
|
||||||
for file in repo.get_contents("_licenses", "gh-pages"):
|
for file in repo.get_contents("_licenses", "gh-pages"):
|
||||||
content = codecs.decode(file.decoded_content)
|
content = codecs.decode(file.decoded_content)
|
||||||
# make below line into a dictionary mapping to filename
|
# make below line into a dictionary mapping to filename
|
||||||
titles_dict[
|
titles_dict[content.split("\n", maxsplit=2)[1].replace("title: ", "")] = file.name
|
||||||
content.split("\n", maxsplit=2)[1].replace("title: ", "")
|
|
||||||
] = file.name
|
|
||||||
path = license_dir / file.name
|
path = license_dir / file.name
|
||||||
if not path.is_file():
|
if not path.is_file():
|
||||||
path.touch()
|
path.touch()
|
||||||
(license_dir / file.name).write_text(replace_content_options(content))
|
(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
|
# write the titles dictionary to a json file so it can be accessed by other files
|
||||||
with open(
|
with open("{{cookiecutter.project_slug}}/licenses/licenses.json", "w") as licenses_dict:
|
||||||
"{{cookiecutter.project_slug}}/licenses/licenses.json", "w"
|
|
||||||
) as licenses_dict:
|
|
||||||
json.dump(titles_dict, licenses_dict, indent=2)
|
json.dump(titles_dict, licenses_dict, indent=2)
|
||||||
# Put "Not open source" at front so people know it's an option
|
# Put "Not open source" at front so people know it's an option
|
||||||
front_options = [
|
front_options = [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user