anki/scripts/copyright_headers.py
Damien Elmes 46b80ca773 move node_modules into root folder [action required]
Recommend removing ts/node_modules folder before attempting to
build after this update.

This moves ts/node_modules into the root of the project to work around
https://github.com/ankitects/anki/pull/1405#issuecomment-936213861

Also fixes the sass errors shown when running scripts/svelte-check
2021-10-07 11:42:27 +10:00

58 lines
1.5 KiB
Python

# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os
import sys
from pathlib import Path
nonstandard_header = {
"pip/pyqt5/install_pyqt5.py",
"pylib/anki/importing/pauker.py",
"pylib/anki/importing/supermemo_xml.py",
"pylib/anki/statsbg.py",
"pylib/tools/protoc-gen-mypy.py",
"qt/aqt/mpv.py",
"qt/aqt/winpaths.py",
}
ignored_folders = [
"bazel-",
"qt/forms",
"node_modules",
]
if not os.path.exists("WORKSPACE"):
print("run from workspace root")
sys.exit(1)
found = False
for dirpath, dirnames, fnames in os.walk("."):
dir = Path(dirpath)
ignore = False
for folder in ignored_folders:
if folder in dirpath:
ignore = True
break
if ignore:
continue
for fname in fnames:
for ext in ".py", ".ts", ".rs", ".svelte":
if fname.endswith(ext):
path = dir / fname
with open(path) as f:
top = f.read(256)
if not top.strip():
continue
if str(path) in nonstandard_header:
continue
if fname.endswith(".d.ts"):
continue
if "Ankitects Pty Ltd and contributors" not in top:
print("missing standard copyright header:", path)
found = True
if found:
sys.exit(1)