File: kf5-lib-prefix-rename

package info (click to toggle)
plasma-framework 5.28.0-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 11,168 kB
  • ctags: 3,945
  • sloc: cpp: 28,840; sh: 534; python: 477; ruby: 117; xml: 110; php: 27; makefile: 5
file content (105 lines) | stat: -rwxr-xr-x 3,727 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/env python
import os
import re
import sys

def replace_one(txt, dst, src=None):
    if src is None:
        src = "K" + dst
    word_src = r"%s\b" % src

    txt = re.sub(r"find_dependency *\(" + word_src, "find_dependency(KF5" + dst, txt)
    txt = re.sub(r"find_package *\(" + word_src, "find_package(KF5" + dst, txt)
    txt = re.sub(r"(find_package *\( *KF5 [A-Za-z0-9\n ]*\s*)" + word_src, r"\1" + dst, txt, re.M)
    txt = re.sub(r"include *\(" + src + r"Macros", "include(KF5" + dst + "Macros", txt)
    txt = re.sub(r"KF5::" + src + r"\b", "KF5::" + dst, txt)
    return txt


def replace_all(path):
    with open(path) as f:
        txt = f.read()
    # tier1
    txt = replace_one(txt, "Archive")
    txt = replace_one(txt, "Codecs")
    txt = replace_one(txt, "ConfigCore")
    txt = replace_one(txt, "ConfigGui")
    txt = replace_one(txt, "Config")
    txt = replace_one(txt, "CoreAddons")
    txt = replace_one(txt, "DBusAddons")
    txt = replace_one(txt, "GuiAddons")
    txt = replace_one(txt, "IdleTime")
    txt = replace_one(txt, "ItemModels", "ItemModels")
    txt = replace_one(txt, "ItemViews", "ItemViews")
    txt = replace_one(txt, "JS")
    txt = replace_one(txt, "JobWidgets")
    txt = replace_one(txt, "Plotting")
    txt = replace_one(txt, "Solid", "Solid")
    txt = replace_one(txt, "Sonnet", "Sonnet")
    txt = replace_one(txt, "ThreadWeaver", "ThreadWeaver")
    txt = replace_one(txt, "WidgetsAddons")
    txt = replace_one(txt, "WindowSystem")
    txt = replace_one(txt, "GlobalAccel", "KF5GlobalAccel")
    # tier2
    txt = replace_one(txt, "DNSSD")
    txt = replace_one(txt, "Auth")
    txt = replace_one(txt, "Completion")
    txt = replace_one(txt, "Crash")
    txt = replace_one(txt, "DocTools")
    txt = replace_one(txt, "XsltKde")
    txt = replace_one(txt, "I18n")
    txt = replace_one(txt, "JobWidgets")
    txt = replace_one(txt, "Notifications")
    txt = replace_one(txt, "Wallet")
    # tier3
    txt = replace_one(txt, "Bookmarks")
    txt = replace_one(txt, "ConfigWidgets")
    txt = replace_one(txt, "Declarative")
    txt = replace_one(txt, "KCMUtils", "KCMUtils")
    txt = replace_one(txt, "KIOCore", "KIOCore")
    txt = replace_one(txt, "KIOFileWidgets", "KIOFileWidgets")
    txt = replace_one(txt, "KIOWidgets", "KIOWidgets")
    txt = replace_one(txt, "KIO", "KIO")
    txt = replace_one(txt, "Kross", "Kross")
    txt = replace_one(txt, "Su", "KDESu")
    txt = replace_one(txt, "WebKit")
    txt = replace_one(txt, "Emoticons")
    txt = replace_one(txt, "IconThemes")
    txt = replace_one(txt, "Init")
    txt = replace_one(txt, "JsEmbed")
    txt = replace_one(txt, "MediaPlayer")
    txt = replace_one(txt, "NewStuff")
    txt = replace_one(txt, "NotifyConfig")
    txt = replace_one(txt, "Parts")
    txt = replace_one(txt, "PrintUtils")
    txt = replace_one(txt, "Pty")
    txt = replace_one(txt, "Service")
    txt = replace_one(txt, "TextWidgets")
    txt = replace_one(txt, "UnitConversion")
    txt = replace_one(txt, "XmlGui", "XmlGui")
    # tier4
    txt = replace_one(txt, "Style")
    txt = replace_one(txt, "KDE4Support", "KDE4Support")
    # plasma
    txt = replace_one(txt, "Plasma", "Plasma")
    txt = replace_one(txt, "PlasmaQuick", "PlasmaQuick")

    with open(path, "w") as f:
        f.write(txt)


def main():
    if len(sys.argv) == 2:
        return replace_all(sys.argv[1])

    for root, dirs, names in os.walk('.'):
        for name in names:
            if name == "CMakeLists.txt" or name.endswith("Config.cmake.in") or name.endswith("Config.cmake"):
                path = os.path.join(root, name)
                print(path)
                replace_all(path)


if __name__ == "__main__":
    sys.exit(main())