mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-02-18 04:20:51 +03:00
style changes
This commit is contained in:
parent
5f9d74ae7c
commit
ebbe28d93d
|
@ -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")
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user