PEATDB/TableModels.py
def filterBy(self, filtercol, value, op='contains', userecnames=False,
                     progresscallback=None):
        """Filter recs according to one column"""
        
        from Filtering import Operators        
        funcs = {'contains':Operators.contains,'=':Operators.equals,
                   '>':Operators.greaterthan,'<':Operators.lessthan,
                   'starts with':Operators.startswith,
                   'ends with':Operators.endswith,
                   'has length':Operators.haslength}
        floatops = ['=','>','<']                   
        func = funcs[op]
        data = self.data
        #coltype = self.columntypes[filtercol]
        names=[]
        for rec in self.reclist:
            if data[rec].has_key(filtercol):  
                #try to do float comparisons if required
                if op in floatops:
                    try:
                        item = float(data[rec][filtercol])
                        v=float(value)
                        if func(v, item) == True:                    
                            names.append(rec)
                        continue 
                    except:
                        pass
                if filtercol == 'name' and userecnames == True:
                    item = rec
                else:
                    item = str(data[rec][filtercol])                
                if func(value, item):                    
                    names.append(rec)               
            
        return names
Filter recs according to one column
Filter recs according to one column
Filter recs according to one column
def filterBy(self, filtercol, value, op='contains', userecnames=False,
                     progresscallback=None):
        from Filtering import Operators        
        funcs = {'contains':Operators.contains,'=':Operators.equals,
                   '>':Operators.greaterthan,'<':Operators.lessthan,
                   'starts with':Operators.startswith,
                   'ends with':Operators.endswith,
                   'has length':Operators.haslength}
        floatops = ['=','>','<']                   
        func = funcs[op]
        data = self.data
        names=[]
        for rec in self.reclist:
            if data[rec].has_key(filtercol):  
                if op in floatops:
                    try:
                        item = float(data[rec][filtercol])
                        v=float(value)
                        if func(v, item) == True:                    
                            names.append(rec)
                        continue 
                    except:
                        pass
                if filtercol == 'name' and userecnames == True:
                    item = rec
                else:
                    item = str(data[rec][filtercol])                
                if func(value, item):                    
                    names.append(rec)               
        return names
def filterBy ( self , filtercol , value , op = 'contains' , userecnames = False , progresscallback = None ) : from Filtering import Operators funcs = { 'contains' : Operators . contains , '=' : Operators . equals , '>' : Operators . greaterthan , '<' : Operators . lessthan , 'starts with' : Operators . startswith , 'ends with' : Operators . endswith , 'has length' : Operators . haslength } floatops = [ '=' , '>' , '<' ] func = funcs [ op ] data = self . data names = [ ] for rec in self . reclist : if data [ rec ] . has_key ( filtercol ) : if op in floatops : try : item = float ( data [ rec ] [ filtercol ] ) v = float ( value ) if func ( v , item ) == True : names . append ( rec ) continue except : pass if filtercol == 'name' and userecnames == True : item = rec else : item = str ( data [ rec ] [ filtercol ] ) if func ( value , item ) : names . append ( rec ) return names
Filter recs according to one column
Filter recs according to one column
"""Filter recs according to one column""" #coltype = self.columntypes[filtercol] #try to do float comparisons if required
self
filtercol
value
op
userecnames
progresscallback