def formatVariablesList(self, keylist, dict, filter = [], classdict = 0, prefix = ''): """ Private method to produce a formated variables list out of the dictionary passed in to it. If classdict is false, it builds a list of all class instances in dict. If it is true, we are formatting a class dictionary. In this case we prepend prefix to the variable names. Variables are only added to the list, if their type is not contained in the filter list. The formated variables list (a list of tuples of 3 values) and the list of class instances is returned. """ varlist = [] classes = [] for key in keylist: # filter hidden attributes (filter #0) if 0 in filter and str(key)[:2] == '__': continue # special handling for '__builtins__' (it's way too big) if key == '__builtins__': rvalue = '<module __builtin__ (built-in)>' valtype = 'module' else: value = dict[key] valtypestr = str(type(value))[1:-1] if string.split(valtypestr,' ',1)[0] == 'class': # handle new class type of python 2.2+ if ConfigVarTypeStrings.index('instance') in filter: continue valtype = valtypestr[7:-1] classes.append(key) else: valtype = valtypestr[6:-1] try: if ConfigVarTypeStrings.index(valtype) in filter: continue if valtype == 'instance': classes.append(key) except ValueError: if ConfigVarTypeStrings.index('other') in filter: continue try: rvalue = repr(value) except: rvalue = '' if classdict: key = prefix + '.' + key varlist.append((key, valtype, rvalue)) return (varlist, classes)
def __getDispType(self, vtype): """ Private method used to get the display string for type vtype. @param vtype the type, the display string should be looked up for (string) @return displaystring (string or QString) """ try: i = ConfigVarTypeStrings.index(vtype) dvtype = self.trUtf8(ConfigVarTypeDispStrings[i]) except ValueError: if vtype == 'classobj': dvtype = self.trUtf8(\ ConfigVarTypeDispStrings[ConfigVarTypeStrings.index('instance')]\ ) else: dvtype = vtype return dvtype