- Timestamp:
- Sep 2, 2009, 5:25:59 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kde/kreadconfig/kreadconfig.py
r792 r793 19 19 20 20 import sys 21 from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs, KC onfig21 from PyKDE4.kdecore import ki18n, KAboutData, KCmdLineArgs, KCmdLineOptions, KConfig 22 22 from PyKDE4.kdeui import KApplication 23 23 … … 29 29 if config.name() == "<default>": 30 30 return "" 31 32 # check, if function config.parent is defined 33 try: config.parent 34 except AttributeError: 35 # x doesn't exist, do something 36 return "[" + config.name() + "]" 31 37 else: 32 if config.parent():33 38 # x exists, do something else 39 parentsNames = getFullName( config.parent() ) 34 40 return parentsNames + "[" + config.name() + "]" 41 42 35 43 36 44 def dumpGroup( config ): 37 45 """print the entries of a config group""" 38 print getFullName( config ) 39 for i in config.entryMap(): 40 print i + ": " + config.readEntry( i ) 46 47 # print secton name only if entries exists 48 if config.entryMap(): 49 print getFullName( config ) 50 #print dir(config) 51 for i in config.entryMap(): 52 #for i in config.keys(): 53 try: 54 print i + ": " + config.readEntry( i ) 55 except AttributeError: 56 # ignore when readEntry does not exist 57 print i + " => readEntry not defined" 58 #, i.count(), dir(i) 59 pass 41 60 print 61 62 42 63 43 64 def dumpSubGroups( config ): … … 63 84 aboutData = KAboutData (appName, catalog, programName, version, description, 64 85 license, copyright, text, homePage, bugEmail) 86 87 # command line argument handling 88 options = KCmdLineOptions() 89 options.add("+configfile", ki18n("KDE config file name")) 65 90 66 KCmdLineArgs.init (sys.argv, aboutData) 91 KCmdLineArgs.init(sys.argv, aboutData) 92 # Register the supported options 93 KCmdLineArgs.addCmdLineOptions( options ) 94 67 95 app = KApplication () 68 96 69 config = KConfig("plasma-desktoprc") 97 args = KCmdLineArgs.parsedArgs(); 70 98 99 # TODO: why is this not detected automatically? 100 if args.count() != 1: 101 args.usage() 102 103 configfilename = args.arg(0) 104 #print configfilename 105 106 config = KConfig(configfilename, KConfig.NoGlobals) 107 108 109 # only show the sub-groups. 110 # top-level entries will be in the section [MainWindow] 111 #dumpSubGroups( config ) 71 112 for i in config.groupList(): 72 configGroup=config.group Impl(str(i))113 configGroup=config.group(str(i)) 73 114 dumpSubGroups( configGroup )
Note:
See TracChangeset
for help on using the changeset viewer.