def createFilter(): #this function displays all the parameters that can be added to filters #uses 2 dicts and 1 user entry to setup the filter parameters #returns the filter statement op(cat,val) opDict={0:("!=",ne),1:("==",eq),2:("<",lt),3:("<=",le),4:(">=",ge),5:(">",gt)} #the operator dict (0) is the printable symbol (1) is the object #cat: the category we filter by #print out cat options for key in Lift.memberDict.keys(): print "%s) %s"%(key,Lift.memberDict[key][0]) #user input for the category, selects the key for memberdict from the items in memTemp (_cat,cat)=Lift.memberDict[optionValidate("Choose filter category",range(key+1))] #op: The operator we use in our filtering eg: ==, > for key in opDict.keys(): print "%s) %s"%(key,opDict[key][0]) #user input for the category, selects the key for opDict from the items in opTemp (_op,op)=opDict[optionValidate("Choose filter category",range(key+1))] #val: teh value we are evaluating towards val=raw_input("%s %s "%(_cat,_op)).lower() return condition(cat,val,op)
def hideCondition(self,hideNum): #hides a specific condition, changing it to either blank, 0 or 1 depending on which has the least effect on the overall logic statement #check if condition is the only 1 #check if the condition inter-relates with anything #check if the condition is related by it's neighbor if self.numCond==0: #it's the only 1 self.condition={} elif self.condition[hideNum][1]!="": #there is an inter-relation, and=1, or=0 if self.condition[hideNum][1]==and_: self.condition[hideNum][0]=condition(0,0,eq) #always true else: self.condition[hideNum][0]=condition(0,1,eq) #always false else: #there is a neighbor with an inter-relation, and=1, or=0 if self.condition[hideNum+1][1]==and_: self.condition[hideNum][0]=condition(0,0,eq) #always true else: self.condition[hideNum][0]=condition(0,1,eq) #always false
def createFilterW(cat,op,val): #takes in values from the form, converts them into the 3 filter parameters #print 'A' opDict={"ne":ne,"eq":eq,"gt":gt,"lt":lt,'ge':ge,'le':le} _op=opDict[op] #print _op _cat=Lift.memberDictW[cat] #print _cat #print val return condition(_cat,val,_op)