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
|
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
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"]
|
|
|
|
|
2021-05-13 12:15:51 +02:00
|
|
|
# work around issue with latest black
|
2021-05-18 22:19:09 +02:00
|
|
|
if sys.platform == "win32" and "HOME" in os.environ:
|
2021-05-13 12:15:51 +02:00
|
|
|
os.environ["USERPROFILE"] = os.environ["HOME"]
|
|
|
|
|
2020-11-01 05:26:58 +01:00
|
|
|
retcode = subprocess.run(
|
|
|
|
[
|
|
|
|
sys.executable,
|
|
|
|
"-m",
|
|
|
|
"black",
|
|
|
|
"-t",
|
2021-10-04 07:05:15 +02:00
|
|
|
"py39",
|
2021-01-09 01:01:48 +01:00
|
|
|
"--exclude=aqt/forms|colors|_gen",
|
2020-11-01 05:26:58 +01:00
|
|
|
"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)
|