add missing copyright headers to *.py

This commit is contained in:
Damien Elmes 2021-04-13 18:45:05 +10:00
parent dac990e4c2
commit 948fc5f777
47 changed files with 175 additions and 11 deletions

View file

@ -1,4 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# #
# See README.md # See README.md

View file

@ -1,5 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: UTF-8 -*- # Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import json import json
import re import re

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: UTF-8 -*- # Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
""" """
Tool to extract core strings and keys from .ftl files. Tool to extract core strings and keys from .ftl files.

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: UTF-8 -*- # Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
""" """
Parse and re-serialize ftl files to get them in a consistent form. Parse and re-serialize ftl files to get them in a consistent form.

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import format import format
import sys import sys

View file

@ -1,3 +1,5 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# #
# A helper script to update commit references to the latest translations, # A helper script to update commit references to the latest translations,
# and copy source files to the translation repos. Requires access to the # and copy source files to the translation repos. Requires access to the

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: UTF-8 -*- # Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
""" """
Tool to apply transform to an ftl string and its translations. Tool to apply transform to an ftl string and its translations.

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import sys import sys
import os import os
import click import click

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from typing import NoReturn from typing import NoReturn

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import subprocess import subprocess
import sys import sys

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import subprocess import subprocess
import sys import sys

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import subprocess import subprocess
import sys import sys

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import sys import sys

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import shutil import shutil
import tempfile import tempfile

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# coding: utf-8 # coding: utf-8
from tests.shared import getEmptyCol from tests.shared import getEmptyCol

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# coding: utf-8 # coding: utf-8
import os import os

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# coding: utf-8 # coding: utf-8
from anki.errors import DeckRenameError from anki.errors import DeckRenameError

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# coding: utf-8 # coding: utf-8
import os import os

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# coding: utf-8 # coding: utf-8
import pytest import pytest

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from tests.shared import getEmptyCol from tests.shared import getEmptyCol

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# coding: utf-8 # coding: utf-8
import os import os

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# coding: utf-8 # coding: utf-8
import os import os

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# coding: utf-8 # coding: utf-8
import os import os

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# coding: utf-8 # coding: utf-8
import time import time

View file

@ -1,4 +1,5 @@
# coding: utf-8 # Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import copy import copy
import time import time

View file

@ -1,4 +1,5 @@
# coding: utf-8 # Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import copy import copy
import os import os

View file

@ -1,5 +1,5 @@
#!/usr/bin/env python3 # Copyright: Ankitects Pty Ltd and contributors
# -*- coding: UTF-8 -*- # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import tempfile import tempfile

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from tests.shared import getEmptyCol from tests.shared import getEmptyCol

View file

@ -1,4 +1,5 @@
# coding: utf-8 # Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import time import time

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# a quick script to compare methods in the two schedulers # a quick script to compare methods in the two schedulers
import inspect import inspect

View file

@ -112,6 +112,9 @@ hooks = [
] ]
prefix = """\ prefix = """\
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# This file is automatically generated; edit tools/genhooks.py instead. # This file is automatically generated; edit tools/genhooks.py instead.
# Please import from anki.hooks instead of this file. # Please import from anki.hooks instead of this file.

View file

@ -1,4 +1,6 @@
#!/usr/bin/env #!/usr/bin/env
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# #
# Wrapper for protoc that strips the dirname from the output files, # Wrapper for protoc that strips the dirname from the output files,
# and generates mypy typechecking info. # and generates mypy typechecking info.

View file

@ -1,5 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors # Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html # License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
from __future__ import annotations from __future__ import annotations
import difflib import difflib

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
""" """
Basic text to speech support. Basic text to speech support.

View file

@ -1,6 +1,10 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import sys import sys
def fix_pywin32_in_bazel(force=False): def fix_pywin32_in_bazel(force=False):
if sys.platform != "win32": if sys.platform != "win32":
return return
@ -15,6 +19,7 @@ def fix_pywin32_in_bazel(force=False):
# trigger pywin32 bootstrap # trigger pywin32 bootstrap
import site import site
site.addsitedir(path) site.addsitedir(path)
# sys.path has been extended; use final # sys.path has been extended; use final

View file

@ -1,7 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import sys import sys
try: try:
import bazelfixes import bazelfixes

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import subprocess import subprocess
import sys import sys

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import subprocess import subprocess
import sys import sys

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import multiprocessing import multiprocessing
import os import os
import subprocess import subprocess

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import sys import sys

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os.path import os.path
from tempfile import TemporaryDirectory from tempfile import TemporaryDirectory
from zipfile import ZipFile from zipfile import ZipFile

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import anki.lang import anki.lang

View file

@ -1,5 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# -*- coding: UTF-8 -*- # Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import json import json
import re import re
@ -31,7 +32,11 @@ for line in open(input_scss):
colors.setdefault(var, []).append(val) colors.setdefault(var, []).append(val)
with open(output_py, "w") as buf: with open(output_py, "w") as buf:
buf.write("""\
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
""")
buf.write("# this file is auto-generated from _vars.scss\n") buf.write("# this file is auto-generated from _vars.scss\n")
for color, (day, night) in colors.items(): for color, (day, night) in colors.items():
color = color.replace("-", "_").upper() color = color.replace("-", "_").upper()
buf.write(f"{color} = (\"{day}\", \"{night}\")\n") buf.write(f'{color} = ("{day}", "{night}")\n')

View file

@ -11,6 +11,9 @@ import sys
from hookslib import Hook, write_file from hookslib import Hook, write_file
prefix = """\ prefix = """\
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
# This file is automatically generated; edit tools/genhooks_gui.py instead. # This file is automatically generated; edit tools/genhooks_gui.py instead.
# Please import from anki.hooks instead of this file. # Please import from anki.hooks instead of this file.

View file

@ -1,3 +1,6 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os import os
import sys import sys

View file

@ -1,4 +1,6 @@
#!/usr/bin/env python #!/usr/bin/env python
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import re import re
import sys import sys
@ -9,10 +11,12 @@ release_mode = sys.argv[3] == "release"
version_re = re.compile('anki_version = "(.*)"') version_re = re.compile('anki_version = "(.*)"')
def output(text: str) -> None: def output(text: str) -> None:
"Add text with a '\n' to stdout; avoiding a '\r' on Windows" "Add text with a '\n' to stdout; avoiding a '\r' on Windows"
sys.stdout.buffer.write(text.encode("utf8") + b"\n") sys.stdout.buffer.write(text.encode("utf8") + b"\n")
# extract version number from defs.bzl # extract version number from defs.bzl
for line in open(defs_file).readlines(): for line in open(defs_file).readlines():
if ver := version_re.match(line): if ver := version_re.match(line):

View file

@ -0,0 +1,42 @@
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os, 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",
}
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)
if "bazel-" in dirpath:
continue
if "qt/forms" in dirpath:
continue
for fname in fnames:
if fname.endswith(".py"):
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 "Ankitects Pty Ltd and contributors" not in top:
print("missing standard copyright header:", path)
found = True
if found:
sys.exit(1)