-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sync KDPySide2ModuleBuild.py and KDFixupShiboken2.py to upstream
- Loading branch information
Allen Winter
committed
Apr 9, 2024
1 parent
99e70c7
commit 7d2cfa6
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com> | ||
# Author: Renato Araujo Oliveira Filho <renato.araujo@kdab.com> | ||
# | ||
# 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: <script> <list-of-files> | ||
# It will fix the file inplace | ||
if __name__ == '__main__': | ||
for fileToFix in sys.argv[1:]: | ||
print("Fixup: {}".format(fileToFix)) | ||
removeExtraNamespaceForDefaultEnumValue(fileToFix) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters