mirror of
https://gitlab.com/kelteseth/ScreenPlay.git
synced 2024-11-06 19:12:30 +01:00
Refactor qml format script
Lets not add the changes now, but later, because this was a flyby work.
This commit is contained in:
parent
d06f5b04c1
commit
97b05c5ff9
@ -6,11 +6,6 @@ from sys import stdout
|
|||||||
|
|
||||||
stdout.reconfigure(encoding='utf-8')
|
stdout.reconfigure(encoding='utf-8')
|
||||||
|
|
||||||
VCPKG_VERSION = "2871ddd" # Master 11.11.2022
|
|
||||||
QT_VERSION = "6.4.2" if sys.platform != "darwin" else "6.3.2"
|
|
||||||
QT_IFW_VERSION = "4.5"
|
|
||||||
SCREENPLAY_VERSION = "0.15.0-RC4"
|
|
||||||
QT_PATH = Path.cwd().parent.parent.joinpath("aqt")
|
|
||||||
# Defined by Qt
|
# Defined by Qt
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
OS = "windows"
|
OS = "windows"
|
||||||
@ -22,5 +17,16 @@ elif sys.platform == "linux":
|
|||||||
OS = "linux"
|
OS = "linux"
|
||||||
QT_PLATFORM = "gcc_64"
|
QT_PLATFORM = "gcc_64"
|
||||||
|
|
||||||
|
SCREENPLAY_VERSION = "0.15.0-RC4"
|
||||||
|
|
||||||
|
|
||||||
|
QT_PATH = Path.cwd().parent.parent.joinpath("aqt")
|
||||||
|
QT_VERSION = "6.4.2" if sys.platform != "darwin" else "6.3.2"
|
||||||
|
QT_BIN_PATH = QT_PATH.joinpath(f"{QT_VERSION}/{QT_PLATFORM}/bin")
|
||||||
|
QT_TOOLS_PATH = QT_PATH.joinpath("Tools/")
|
||||||
|
QT_IFW_VERSION = "4.5"
|
||||||
|
|
||||||
|
VCPKG_VERSION = "2871ddd" # Master 11.11.2022
|
||||||
|
|
||||||
PYTHON_EXECUTABLE = "python" if sys.platform == "win32" else "python3"
|
PYTHON_EXECUTABLE = "python" if sys.platform == "win32" else "python3"
|
||||||
FFMPEG_VERSION = "5.0.1"
|
FFMPEG_VERSION = "5.0.1"
|
@ -12,7 +12,7 @@ from sys import stdout
|
|||||||
stdout.reconfigure(encoding='utf-8')
|
stdout.reconfigure(encoding='utf-8')
|
||||||
|
|
||||||
|
|
||||||
def find_all_files(path) -> []:
|
def find_all_files(path):
|
||||||
file_list = []
|
file_list = []
|
||||||
for root, dirnames, files in os.walk(path):
|
for root, dirnames, files in os.walk(path):
|
||||||
for filename in files:
|
for filename in files:
|
||||||
@ -20,7 +20,7 @@ def find_all_files(path) -> []:
|
|||||||
return file_list
|
return file_list
|
||||||
|
|
||||||
|
|
||||||
def find_all_git_staged_files() -> []:
|
def find_all_git_staged_files():
|
||||||
process = subprocess.run("git diff --name-only --staged",
|
process = subprocess.run("git diff --name-only --staged",
|
||||||
capture_output=True, shell=True)
|
capture_output=True, shell=True)
|
||||||
out = process.stdout.decode("utf-8")
|
out = process.stdout.decode("utf-8")
|
||||||
@ -28,7 +28,7 @@ def find_all_git_staged_files() -> []:
|
|||||||
return out
|
return out
|
||||||
|
|
||||||
|
|
||||||
def find_files(file_endings_tuple, path="", git_staged_only=False) -> []:
|
def find_files(file_endings_tuple, path="", git_staged_only=False):
|
||||||
file_list = []
|
file_list = []
|
||||||
# Get the root folder by moving one up
|
# Get the root folder by moving one up
|
||||||
root = Path(__file__).parent.absolute()
|
root = Path(__file__).parent.absolute()
|
||||||
@ -71,25 +71,3 @@ def check_git_exit(caller_name):
|
|||||||
# print(out)
|
# print(out)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def find_absolute_qt_path(qt_version) -> os.path:
|
|
||||||
compiler = ""
|
|
||||||
if os.name != 'nt':
|
|
||||||
print("find_absolute_qt_path is only implemented for Windows!")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
compiler = "msvc2019_64"
|
|
||||||
|
|
||||||
qt_base_path = "C:\\Qt"
|
|
||||||
if not os.path.exists(qt_base_path):
|
|
||||||
print("No suitable Qt version found! Searching for version %s" % qt_version)
|
|
||||||
print("Path searches the root Qt version folder like: C:/Qt/6.0.0/msvc2019_64")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
absolute_qt_path = os.path.join(qt_base_path, qt_version)
|
|
||||||
if os.path.exists(absolute_qt_path):
|
|
||||||
return os.path.join(absolute_qt_path, compiler)
|
|
||||||
else:
|
|
||||||
print("No suitable Qt version found! Searching for version %s" % qt_version)
|
|
||||||
print("Path searches the root Qt version folder like: C:/Qt/6.0.0/msvc2019_64")
|
|
||||||
sys.exit(1)
|
|
||||||
|
@ -4,10 +4,10 @@ import os
|
|||||||
import subprocess
|
import subprocess
|
||||||
import argparse
|
import argparse
|
||||||
import sys
|
import sys
|
||||||
|
import defines
|
||||||
from format_util import find_files
|
from format_util import find_files
|
||||||
from format_util import check_git_exit
|
from format_util import check_git_exit
|
||||||
from format_util import execute_threaded
|
from format_util import execute_threaded
|
||||||
from format_util import find_absolute_qt_path
|
|
||||||
from sys import stdout
|
from sys import stdout
|
||||||
|
|
||||||
stdout.reconfigure(encoding='utf-8')
|
stdout.reconfigure(encoding='utf-8')
|
||||||
@ -17,8 +17,8 @@ def format_file_function(file):
|
|||||||
executable = "qmlformat"
|
executable = "qmlformat"
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
executable = "qmlformat.exe"
|
executable = "qmlformat.exe"
|
||||||
qt_bin_path = os.path.join(find_absolute_qt_path("6.1.0"), "bin")
|
qt_bin_path = defines.QT_BIN_PATH
|
||||||
executable = os.path.join(qt_bin_path, executable)
|
executable = qt_bin_path.joinpath(executable)
|
||||||
|
|
||||||
process = subprocess.run(
|
process = subprocess.run(
|
||||||
"%s -i %s" % (executable, file), capture_output=True, shell=True)
|
"%s -i %s" % (executable, file), capture_output=True, shell=True)
|
||||||
@ -26,10 +26,6 @@ def format_file_function(file):
|
|||||||
|
|
||||||
|
|
||||||
def main(git_staged_only=False):
|
def main(git_staged_only=False):
|
||||||
if "" == find_absolute_qt_path("6.1.0"):
|
|
||||||
print("No suitable qt version found!")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
file_list = find_files(('.qml'), os.path.abspath(os.path.join(os.getcwd(), "../")), git_staged_only)
|
file_list = find_files(('.qml'), os.path.abspath(os.path.join(os.getcwd(), "../")), git_staged_only)
|
||||||
execute_threaded(file_list, format_file_function)
|
execute_threaded(file_list, format_file_function)
|
||||||
if not git_staged_only:
|
if not git_staged_only:
|
||||||
|
Loading…
Reference in New Issue
Block a user