1#!/usr/local/bin/python3.8 2 3# A small script that validates the structure of systemsettings. 4# 5# Copyright (c) 2010 Trever Fischer <tdfischer@fedoraproject.org> 6# 7# You are free to modify and distribute this script under 8# the terms of the GPLv2 or later 9from PyKDE4.kdecore import KServiceTypeTrader 10from PyQt4.QtCore import QVariant 11 12VALID_CATEGORIES = ( 13 "application-appearance-and-behavior", 14 "application-appearance", 15 "shortcuts-and-gestures", 16 "account-details", 17 "locale", 18 "application-and-system-notifications", 19 "personal-information", 20 "workspace-appearance-and-behavior", 21 "desktop-appearance", 22 "window-behaviour", 23 "hardware", 24 "display", 25 "audio-and-video", 26 "main-input-devices", 27 "other-input-devices", 28 "removable-devices", 29 "network-and-connectivity", 30 "sharing", 31 "network-settings", 32 "bluetooth", 33 "system-administration", 34 "permissions", 35 "security", 36 "startup-and-shutdown" 37 ) 38 39def printLevel(category, depth=0): 40 results = KServiceTypeTrader.self().query('KCModule', "([X-KDE-System-Settings-Parent-Category] == '%s')"%(category)) 41 for result in results: 42 print (" "*depth)+'%s [%s]' % (result.property('Name', QVariant.String).toString(), result.desktopEntryPath()) 43 if result.property('Comment', QVariant.String).toString().isEmpty(): 44 print(" "*depth)+"***No comment!***" 45 categories = KServiceTypeTrader.self().query('SystemSettingsCategory', "([X-KDE-System-Settings-Parent-Category] == '%s')"%(category)) 46 for subcategory in categories: 47 print (" "*depth)+'%s [%s]' % (subcategory.property('Name', QVariant.String).toString(), subcategory.desktopEntryPath()) 48 printLevel(subcategory.property('X-KDE-System-Settings-Category', QVariant.String).toString(), depth+1) 49 50print "*** Current organization:" 51printLevel('') 52 53print "\n" 54print "*** Searching for invalid categories:" 55print "**** KCModules:" 56results = KServiceTypeTrader.self().query('KCModule') 57for result in results: 58 if (not (result.property('X-KDE-System-Settings-Parent-Category', QVariant.String).toString() in VALID_CATEGORIES)): 59 print "%s [%s]: %s"%(result.property('Name', QVariant.String).toString(), result.desktopEntryPath(), result.property('X-KDE-System-Settings-Parent-Category', QVariant.String).toString()) 60print "**** Categories:" 61results = KServiceTypeTrader.self().query('SystemSettingsCategory') 62for result in results: 63 if (not (result.property('X-KDE-System-Settings-Parent-Category', QVariant.String).toString() in VALID_CATEGORIES)): 64 print "%s [%s]: %s"%(result.property('Name', QVariant.String).toString(), result.desktopEntryPath(), result.property('X-KDE-System-Settings-Parent-Category', QVariant.String).toString()) 65