From 05bfd8b825f39332e8ffde285c2dc587525e824e Mon Sep 17 00:00:00 2001 From: Allen Winter Date: Tue, 9 Apr 2024 16:04:13 -0400 Subject: [PATCH] sync KDPySide2ModuleBuild.py and KDFixupShiboken2.py to upstream --- cmake/KDAB/modules/KDFixupShiboken2.py | 36 +++++++++++++++++++ cmake/KDAB/modules/KDPySide2ModuleBuild.cmake | 1 + 2 files changed, 37 insertions(+) create mode 100755 cmake/KDAB/modules/KDFixupShiboken2.py diff --git a/cmake/KDAB/modules/KDFixupShiboken2.py b/cmake/KDAB/modules/KDFixupShiboken2.py new file mode 100755 index 00000000..39444d48 --- /dev/null +++ b/cmake/KDAB/modules/KDFixupShiboken2.py @@ -0,0 +1,36 @@ +# +# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company +# Author: Renato Araujo Oliveira Filho +# +# SPDX-License-Identifier: BSD-3-Clause +# + +""" +Script to fix bugs in code generated by shiboken-generator vr2 +""" + +import sys +import re + + +def removeExtraNamespaceForDefaultEnumValue(filename): + """ + Remove namespace from default flag value + this is a shiboken2 bug fixed on shiboken6 + """ + regex = re.compile(r"\s=\s[^\s]+::{}") + newContent = "" + with open(filename, encoding='utf-8') as f: + for line in f: + newContent += re.sub(regex, ' = {}', line) + + with open(filename, "w", encoding='utf-8') as f: + f.write(newContent) + + +# Usage: