From 5dfad191a1285c965c2647344f2d12a6790e5142 Mon Sep 17 00:00:00 2001 From: beastmatser <79206232+beastmatser@users.noreply.github.com> Date: Tue, 11 Jan 2022 20:05:31 +0100 Subject: [PATCH 1/4] :construction_worker: Add a license generator --- .github/scripts/license_generator.py | 16 +++++++++++++++ .../{sort_alls.yaml => run_scripts.yml} | 20 ++++++++++--------- 2 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 .github/scripts/license_generator.py rename .github/workflows/{sort_alls.yaml => run_scripts.yml} (52%) diff --git a/.github/scripts/license_generator.py b/.github/scripts/license_generator.py new file mode 100644 index 00000000..fb514ed9 --- /dev/null +++ b/.github/scripts/license_generator.py @@ -0,0 +1,16 @@ +from glob import glob +from inspect import cleandoc + +pincer_license = """# Copyright Pincer 2021-Present +# Full MIT License can be found in `LICENSE` at the project root. + +""" + + +for file in glob("./pincer/**/*.py"): + with open(file, "r+") as f: + lines = f.readlines() + if not lines[0].startswith("# Copyright Pincer 2021-Present\n"): + lines.insert(0, pincer_license) + f.seek(0) + f.writelines(lines) \ No newline at end of file diff --git a/.github/workflows/sort_alls.yaml b/.github/workflows/run_scripts.yml similarity index 52% rename from .github/workflows/sort_alls.yaml rename to .github/workflows/run_scripts.yml index 404edaae..6491d91f 100644 --- a/.github/workflows/sort_alls.yaml +++ b/.github/workflows/run_scripts.yml @@ -1,4 +1,4 @@ -name: Sort Alls +name: Run Scripts on: push @@ -16,17 +16,19 @@ jobs: python-version: '3.8' architecture: 'x64' - - name: running script - run: python ./.github/scripts/all_sorter.py - - name: setup git run: | git config user.name "GitHub Actions" git config user.email "actions@pincer.dev" + git pull - - name: add to git + - name: running all sorter run: | - git pull - git add . - git diff-index --quiet HEAD || git commit -m ":art: Automatic `__all__` sorting" - git push + python ./.github/scripts/all_sorter.py + git diff-index --quiet HEAD || git commit -am ":art: Automatic `__all__` sorting" + + + - name: running license generator + run: | + python ./.github/scripts/license_generator.py + git diff-index --quiet HEAD || git commit -am ":page_facing_up: Automatic license generator" From 9a251171a6ff733687f5c22385bc4290eed371a0 Mon Sep 17 00:00:00 2001 From: beastmatser <79206232+beastmatser@users.noreply.github.com> Date: Tue, 11 Jan 2022 20:13:55 +0100 Subject: [PATCH 2/4] :recycle: Look at every file --- .github/scripts/license_generator.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/scripts/license_generator.py b/.github/scripts/license_generator.py index fb514ed9..42f31dd3 100644 --- a/.github/scripts/license_generator.py +++ b/.github/scripts/license_generator.py @@ -7,7 +7,10 @@ """ -for file in glob("./pincer/**/*.py"): +for file in glob("./pincer/**/*.py", recursive=True): + if file == "./pincer/__init__.py": + continue + with open(file, "r+") as f: lines = f.readlines() if not lines[0].startswith("# Copyright Pincer 2021-Present\n"): From 93f6f2118cc430269d367efa019c31adfec6c63e Mon Sep 17 00:00:00 2001 From: beastmatser <79206232+beastmatser@users.noreply.github.com> Date: Tue, 11 Jan 2022 20:15:38 +0100 Subject: [PATCH 3/4] :art: Remove trailing whitespace --- .github/scripts/license_generator.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/license_generator.py b/.github/scripts/license_generator.py index 42f31dd3..cf5881ef 100644 --- a/.github/scripts/license_generator.py +++ b/.github/scripts/license_generator.py @@ -10,10 +10,10 @@ for file in glob("./pincer/**/*.py", recursive=True): if file == "./pincer/__init__.py": continue - + with open(file, "r+") as f: lines = f.readlines() if not lines[0].startswith("# Copyright Pincer 2021-Present\n"): lines.insert(0, pincer_license) f.seek(0) - f.writelines(lines) \ No newline at end of file + f.writelines(lines) From 4ffe416b1acb7ee8777cc0844389f56a7976af7a Mon Sep 17 00:00:00 2001 From: beastmatser <79206232+beastmatser@users.noreply.github.com> Date: Tue, 11 Jan 2022 20:19:22 +0100 Subject: [PATCH 4/4] :coffin: Remove unused import --- .github/scripts/license_generator.py | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/scripts/license_generator.py b/.github/scripts/license_generator.py index cf5881ef..703be84f 100644 --- a/.github/scripts/license_generator.py +++ b/.github/scripts/license_generator.py @@ -1,5 +1,4 @@ from glob import glob -from inspect import cleandoc pincer_license = """# Copyright Pincer 2021-Present # Full MIT License can be found in `LICENSE` at the project root.