Changeset View
Changeset View
Standalone View
Standalone View
doc/config_update_tool/extract_config.py
- This file was added.
Property | Old Value | New Value |
---|---|---|
File Mode | null | 100755 |
1 | #!/bin/env python3 | ||||
---|---|---|---|---|---|
2 | | ||||
3 | import os | ||||
4 | import sys | ||||
5 | import xml.dom.minidom | ||||
6 | from xml.dom.minidom import parse | ||||
7 | | ||||
8 | ######## | ||||
9 | # This application loops through installed applets and extracts the config XML file | ||||
10 | # Output is then presented in mediawiki format for copying and pasting to https://userbase.kde.org/KDE_System_Administration/PlasmaDesktopScripting#Configuration_Keys | ||||
11 | | ||||
12 | # app should be kept flexible enough to port to a different format in future | ||||
13 | | ||||
14 | | ||||
15 | #set plasmoid installation path manually if applicable | ||||
16 | xdg_data_dir = "" | ||||
17 | | ||||
18 | if not xdg_data_dir: | ||||
19 | xdg_data_dirs = os.getenv("XDG_DATA_DIRS").split(":") | ||||
20 | xdg_data_dirs.append("/usr/share") | ||||
21 | xdg_data_dir = xdg_data_dirs[0] | ||||
22 | | ||||
23 | | ||||
24 | | ||||
25 | root = xdg_data_dir + "/plasma/plasmoids" | ||||
26 | | ||||
27 | for plasmoid in os.listdir(root): | ||||
28 | configPath = "/contents/config/main.xml" | ||||
29 | path = root + "/" + plasmoid + configPath | ||||
30 | try: | ||||
31 | dom = xml.dom.minidom.parse(path).documentElement | ||||
32 | | ||||
33 | print ("===" + plasmoid + "===") | ||||
34 | for group in dom.getElementsByTagName("group"): | ||||
35 | groupName = group.getAttribute("name") | ||||
36 | print ("======" + groupName + "======") | ||||
37 | for entry in group.getElementsByTagName("entry"): | ||||
38 | name = entry.getAttribute("name") | ||||
39 | type = entry.getAttribute("type") | ||||
40 | default = "" | ||||
41 | description = "" | ||||
42 | hidden = True | ||||
43 | | ||||
44 | if entry.hasAttribute("hidden") and entry.getAttribute("hidden") == True: | ||||
45 | hidden = False | ||||
46 | | ||||
47 | defaultTags = entry.getElementsByTagName("default") | ||||
48 | if (defaultTags.length > 0 and defaultTags[0].childNodes.length > 0): | ||||
49 | default = defaultTags[0].childNodes[0].data | ||||
50 | | ||||
51 | labelTags = entry.getElementsByTagName("label") | ||||
52 | if (labelTags.length > 0 and labelTags[0].childNodes.length > 0): | ||||
53 | description = labelTags[0].childNodes[0].data | ||||
54 | | ||||
55 | | ||||
56 | print ("* '''%s''' (''%s'') %s" % (name , type, description)) | ||||
57 | except IOError: | ||||
58 | sys.stderr.write("No config in " + plasmoid +"\n") | ||||
59 | #abort on other errors so we can find them |