anki/qt/tests/run_format.py

55 lines
1.2 KiB
Python
Raw Normal View History

2021-04-13 10:45:05 +02:00
# Copyright: Ankitects Pty Ltd and contributors
# License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
import os
import subprocess
import sys
if __name__ == "__main__":
isort_ini = sys.argv[1]
isort_ini = os.path.abspath(isort_ini)
fix = len(sys.argv) > 2
if fix:
os.chdir(os.path.join(os.environ["BUILD_WORKSPACE_DIRECTORY"], "qt"))
args = []
else:
folder = os.path.join(os.path.dirname(__file__), "..")
os.chdir(folder)
args = ["--diff", "--check"]
retcode = subprocess.run(
[
sys.executable,
"-m",
"black",
"-t",
2020-11-11 12:37:36 +01:00
"py38",
"--exclude=aqt/forms|colors|_gen",
"aqt",
"tests",
"tools",
]
+ args,
check=False,
).returncode
if retcode != 0:
sys.exit(retcode)
retcode = subprocess.run(
[
sys.executable,
"-m",
"isort",
"--settings-path",
isort_ini,
"aqt",
"tests",
"tools",
]
+ args,
check=False,
).returncode
if retcode != 0:
sys.exit(retcode)