[790] | 1 | #!/usr/bin/env python
|
---|
| 2 | # -*- coding: utf-8 -*-
|
---|
| 3 |
|
---|
[791] | 4 | """
|
---|
| 5 | kreadconfig.py dumps KDE configuration files.
|
---|
| 6 | It is usefull for debugging KDE Kiosks settings,
|
---|
| 7 | where multiple config files are merged into the final configuration.
|
---|
| 8 |
|
---|
| 9 | The directory hierarchie for config files
|
---|
| 10 | is based on the KDEDIRS environment variable
|
---|
| 11 | and can be made visible by the command
|
---|
| 12 | kde4-config --path config
|
---|
| 13 |
|
---|
| 14 | kreadconfig has a similiar purpose,
|
---|
| 15 | but is limited to a single value
|
---|
| 16 | """
|
---|
| 17 |
|
---|
| 18 | # $Id: kreadconfig.py 792 2009-09-02 13:48:54Z joergs $
|
---|
| 19 |
|
---|
[790] | 20 | import sys
|
---|
| 21 | from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs, KConfig
|
---|
| 22 | from PyKDE4.kdeui import KApplication
|
---|
| 23 |
|
---|
| 24 | #import pprint
|
---|
| 25 | #pp = pprint.PrettyPrinter(indent=4)
|
---|
| 26 |
|
---|
| 27 | def getFullName( config ):
|
---|
[792] | 28 | """get the full name of a config group"""
|
---|
[790] | 29 | if config.name() == "<default>":
|
---|
| 30 | return ""
|
---|
| 31 | else:
|
---|
| 32 | if config.parent():
|
---|
| 33 | parentsNames = getFullName( config.parent() )
|
---|
| 34 | return parentsNames + "[" + config.name() + "]"
|
---|
| 35 |
|
---|
| 36 | def dumpGroup( config ):
|
---|
[792] | 37 | """print the entries of a config group"""
|
---|
[790] | 38 | print getFullName( config )
|
---|
| 39 | for i in config.entryMap():
|
---|
| 40 | print i + ": " + config.readEntry( i )
|
---|
| 41 | print
|
---|
| 42 |
|
---|
| 43 | def dumpSubGroups( config ):
|
---|
[792] | 44 | """print entries of the config group and all subgroups"""
|
---|
[790] | 45 | dumpGroup( config )
|
---|
| 46 | #print dir( config )
|
---|
| 47 | for i in config.groupList():
|
---|
| 48 | configGroup=config.group(str(i))
|
---|
| 49 | dumpSubGroups( configGroup )
|
---|
| 50 |
|
---|
| 51 |
|
---|
[792] | 52 | appName = "kreadconfig.py"
|
---|
[790] | 53 | catalog = ""
|
---|
[792] | 54 | programName = ki18n ("kreadconfig.py")
|
---|
| 55 | version = "$Rev: 792 $"
|
---|
| 56 | description = ki18n ("show KDE configuration files")
|
---|
[790] | 57 | license = KAboutData.License_GPL
|
---|
| 58 | copyright = ki18n ("(c) 2009 Jörg Steffens")
|
---|
| 59 | text = ki18n ("none")
|
---|
| 60 | homePage = "www.dass-it.de"
|
---|
| 61 | bugEmail = "rt@dass-it.de"
|
---|
| 62 |
|
---|
| 63 | aboutData = KAboutData (appName, catalog, programName, version, description,
|
---|
| 64 | license, copyright, text, homePage, bugEmail)
|
---|
| 65 |
|
---|
| 66 | KCmdLineArgs.init (sys.argv, aboutData)
|
---|
| 67 | app = KApplication ()
|
---|
| 68 |
|
---|
| 69 | config = KConfig("plasma-desktoprc")
|
---|
| 70 |
|
---|
| 71 | for i in config.groupList():
|
---|
| 72 | configGroup=config.groupImpl(str(i))
|
---|
| 73 | dumpSubGroups( configGroup )
|
---|