Reformat files using pre-commit

This commit is contained in:
Bruno Alla 2024-05-13 18:54:34 +00:00
parent 910697980f
commit 05264405ae
5 changed files with 23 additions and 31 deletions

View File

@ -12,23 +12,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Update list
run: python scripts/update_licenses.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Update list
run: python scripts/update_licenses.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4.9.1
with:
commit_message: Update Licenses
file_pattern: cookiecutter.json {{cookiecutter.project_slug}}/licenses/*.txt
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4.9.1
with:
commit_message: Update Licenses
file_pattern: cookiecutter.json {{cookiecutter.project_slug}}/licenses/*.txt

View File

@ -83,4 +83,4 @@
"ci_tool": ["None", "Travis", "Gitlab", "Github", "Drone"],
"keep_local_envs_in_vcs": "y",
"debug": "n"
}
}

View File

@ -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:])

View File

@ -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 = []

View File

@ -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 = [