dmClasses.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:CRDataManager 作者: NobahdiAtoll 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号