PEATDB/TableModels.py
def importDict(self, newdata, namefield=None):
        """Try to create a table model from some arbitrary dict"""
        import types
        if namefield == None:
            namefield = 'name'
        #get cols from sub data keys
        colnames = []
        colnames.append(namefield)
        
        for k in newdata:
            fields = newdata[k].keys()
            for f in fields:
                if not f in colnames:
                    colnames.append(f)

        for c in colnames:
            self.addColumn(c)

        #add the data
        #print colnames
        for k in newdata:
            self.addRow(k)
            for c in colnames:
                if c == namefield:
                    self.data[k][namefield] = str(k)
                else:
                    self.data[k][c] = str(newdata[k][c])

        return
Try to create a table model from some arbitrary dict
Try to create a table model from some arbitrary dict
Try to create a table model from some arbitrary dict
def importDict(self, newdata, namefield=None):
        import types
        if namefield == None:
            namefield = 'name'
        colnames = []
        colnames.append(namefield)
        for k in newdata:
            fields = newdata[k].keys()
            for f in fields:
                if not f in colnames:
                    colnames.append(f)
        for c in colnames:
            self.addColumn(c)
        for k in newdata:
            self.addRow(k)
            for c in colnames:
                if c == namefield:
                    self.data[k][namefield] = str(k)
                else:
                    self.data[k][c] = str(newdata[k][c])
        return
def importDict ( self , newdata , namefield = None ) : import types if namefield == None : namefield = 'name' colnames = [ ] colnames . append ( namefield ) for k in newdata : fields = newdata [ k ] . keys ( ) for f in fields : if not f in colnames : colnames . append ( f ) for c in colnames : self . addColumn ( c ) for k in newdata : self . addRow ( k ) for c in colnames : if c == namefield : self . data [ k ] [ namefield ] = str ( k ) else : self . data [ k ] [ c ] = str ( newdata [ k ] [ c ] ) return
Try to create a table model from some arbitrary dict
Try to create a table model from some arbitrary dict
"""Try to create a table model from some arbitrary dict""" #get cols from sub data keys #add the data #print colnames
self
newdata
namefield