2022-11-29 01:55:01 +03:00
|
|
|
|
2022-11-27 01:42:58 +03:00
|
|
|
import os
|
|
|
|
import re
|
|
|
|
from pprint import pprint
|
|
|
|
|
|
|
|
|
2022-11-30 01:09:45 +03:00
|
|
|
# script to check if licenses generated have placeholders not replaced
|
2022-11-29 01:55:01 +03:00
|
|
|
def check_scripts_for_placeholders():
|
2022-11-27 01:42:58 +03:00
|
|
|
brackets = []
|
|
|
|
for filename in os.listdir('../{{cookiecutter.project_slug}}/licenses'):
|
|
|
|
file = open('../{{cookiecutter.project_slug}}/licenses/' + filename, 'r', encoding="utf8")
|
|
|
|
|
|
|
|
# 'found' stores all found bracket instances
|
|
|
|
found = []
|
2022-11-30 01:09:45 +03:00
|
|
|
|
|
|
|
# dashes counts the '---\n' lines in the licenses.
|
|
|
|
# it skips instances of brackets until after 2 as to skip the jekyll header
|
2022-11-27 01:42:58 +03:00
|
|
|
dashes = 0
|
|
|
|
for i, line in enumerate(file.readlines()):
|
|
|
|
if line == '---\n':
|
|
|
|
dashes += 1
|
|
|
|
# skips any possible brackets until the jekyll header is skipped
|
|
|
|
if dashes < 2:
|
|
|
|
continue
|
|
|
|
line = re.findall(r'\[.*\]', line)
|
|
|
|
if line != []:
|
|
|
|
found += (i, line)
|
|
|
|
|
2022-11-30 01:09:45 +03:00
|
|
|
# add any found instances of placeholders to the brackets array
|
|
|
|
# print it after the loop is executed
|
2022-11-27 01:42:58 +03:00
|
|
|
if found != []:
|
|
|
|
brackets += (filename, found)
|
|
|
|
if len(brackets) > 0:
|
|
|
|
print()
|
|
|
|
pprint(brackets)
|
|
|
|
assert(len(brackets) == 0)
|
2022-11-29 01:55:01 +03:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
check_scripts_for_placeholders()
|