def Is(self, book):
if dmGlobals.TraceFunctionMessages: print 'Method: dmRule:Is(book)'
getValue = self.GetFieldValue(book, self.Field) #get Value from book
compareValue = self.FieldConvert(self.ReplaceReferenceStrings(self.Value, book) ,self.Field) #value to compare
if self.Field in dmGlobals.FIELDSLIST: #deal with list items as individual items
if len(compareValue) == len(getValue): #only continue if lists are same legnth
count = 0
for item in compareValue: #iterate through compare list items
for val in getValue: #iterate through book list items
if val.lower() == item.lower(): #compare lowercase list items from book (val) to compare list items (item)
count = count + 1 #if match increment count
if count == len(getValue): #if count ends up equal between book list items and compare list items
return True #set true
else:
if isinstance(getValue, str):
if getValue.lower() == compareValue.lower():
return True
else:
if getValue == compareValue: #if values match
return True #set true
return False #if everything else fails set false
评论列表
文章目录