本文整理汇总了Python中filter.Filter.check方法的典型用法代码示例。如果您正苦于以下问题:Python Filter.check方法的具体用法?Python Filter.check怎么用?Python Filter.check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类filter.Filter
的用法示例。
在下文中一共展示了Filter.check方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Carousel
# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import check [as 别名]
class Carousel(object):
def __init__(self, aggregatedData):
self.__aData = aggregatedData
self.__currentType = CUSTOMIZATION_TYPE.CAMOUFLAGE
self.__currentSlotIdx = 0
self.__currentDuration = 0
self.__carouselItems = []
self.filter = Filter(self.__aData.availableGroupNames)
self.filter.changed += self.__updateCarouselData
self.slots = Slots(self.__aData)
self.slots.selected += self.__onSlotSelected
self.slots.updated += self.__onSlotUpdated
self.updated = Event()
def fini(self):
self.slots.selected -= self.__onSlotSelected
self.slots.updated -= self.__onSlotUpdated
self.filter.changed -= self.__updateCarouselData
self.__carouselItems = None
self.__aData = None
self.slots.fini()
self.filter.fini()
return
@property
def items(self):
return self.__carouselItems
@property
def currentType(self):
return self.__currentType
@property
def currentSlotIdx(self):
return self.__currentSlotIdx
def applyItem(self, carouselItemIdx):
self.slots.updateSlot(self.__carouselItems[carouselItemIdx], duration=self.__currentDuration)
def previewItem(self, carouselItemIdx):
previewItemID = self.__carouselItems[carouselItemIdx]['id']
if self.__currentType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
g_hangarSpace.space.updateVehicleCamouflage(camouflageID=previewItemID)
else:
self.__updateItemOnTank3DModel(previewItemID)
def changeDuration(self, duration):
self.__currentDuration = duration
self.__updateCarouselData()
def __updateItemOnTank3DModel(self, previewItemID):
cType = self.__currentType
slotIdx = self.__currentSlotIdx
slotItem = self.slots.getData()['data'][cType]['data'][slotIdx]
changedPreviewModel = copy.deepcopy(self.__aData.viewModel[1:3])
rawInstalledItem = [previewItemID, time.time(), 0]
if cType == CUSTOMIZATION_TYPE.INSCRIPTION:
rawInstalledItem.append(0)
changedPreviewModel[cType - 1][slotItem['spot'] + self.slots.calculateVehicleIndex(slotIdx, cType)] = rawInstalledItem
g_hangarSpace.space.updateVehicleSticker(changedPreviewModel)
def __onSlotSelected(self, newType, newSlotIdx):
self.__currentType = newType
self.__currentSlotIdx = newSlotIdx
self.filter.setTypeAndIdx(newType, newSlotIdx)
if newType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
self.filter.set(FILTER_TYPE.GROUP, CAMOUFLAGE_GROUP_MAPPING[newSlotIdx])
self.filter.apply()
def __getBtnTooltip(self, installedInSlot):
if installedInSlot:
params = (TOOLTIPS.CUSTOMIZATION_CAROUSEL_SLOT_REMOVE_HEADER, TOOLTIPS.CUSTOMIZATION_CAROUSEL_SLOT_REMOVE_BODY)
else:
params = (TOOLTIPS.CUSTOMIZATION_CAROUSEL_SLOT_SELECT_HEADER, TOOLTIPS.CUSTOMIZATION_CAROUSEL_SLOT_SELECT_BODY)
return makeTooltip(*params)
def __onSlotUpdated(self, newSlotData):
self.__updateCarouselData()
def __updateCarouselData(self):
oldItemsCount = len(self.__carouselItems)
del self.__carouselItems[:]
appliedItems = []
purchasedItems = []
otherItems = []
currentSlotItem = None
installedItemID = self.slots.getInstalledItem(self.__currentSlotIdx, self.__currentType).getID()
if self.__currentType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
displayedItems = {}
for itemID, item in self.__aData.displayed[self.__currentType].iteritems():
if item.getGroup() == CAMOUFLAGE_GROUP_MAPPING[self.__currentSlotIdx]:
displayedItems[itemID] = item
else:
displayedItems = self.__aData.displayed[self.__currentType]
for itemID, item in displayedItems.iteritems():
if not self.filter.check(item):
continue
appliedToCurrentSlot = itemID == self.slots.getSelectedSlotItemID()
#.........这里部分代码省略.........
示例2: max
# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import check [as 别名]
for index, dic in wordlists.items():
t = comparetext.comp(wordlist, dic)
maxcmplvl = max(maxcmplvl, t)
if t > settings.cmp_threshold:
feed.add_crosslink(index, link, title)
logging.warn(_("removing news entry: %(duplicate)s\n\tas duplicate of: %(news)s") %
{'duplicate': title, 'news': feed.get_title(index)})
continue
if maxcmplvl > settings.cmp_threshold:
feed.remove_item(child)
continue
else:
wordlists[gid] = wordlist
# Check against blackwords
lvl = wordfilter.check(title, settings.title_scale)
if content != "":
lvl += wordfilter.check(content, 1)
elif summary != "":
lvl += wordfilter.check(summary, 1)
if lvl > settings.threshold:
logging.warn(_("removing item %(title)s with score %(score)i") %
{'title': title, 'score': lvl})
feed.remove_item(child)
del wordlists[gid]
elif settings.appendlvl:
appendstr = "<br><small><small>lvl: %.2g " % lvl + \
"maxcmplvl: %.2f</small></small>" % maxcmplvl
feed.append_description(child, appendstr)
if content != "":
feed.append_content(child, appendstr)
示例3: Carousel
# 需要导入模块: from filter import Filter [as 别名]
# 或者: from filter.Filter import check [as 别名]
class Carousel(object):
def __init__(self, aggregatedData):
self.__aData = aggregatedData
self.__currentType = CUSTOMIZATION_TYPE.CAMOUFLAGE
self.__currentSlotIdx = 0
self.__currentDuration = 0
self.__carouselItems = []
self.filter = Filter(self.__aData.availableGroupNames)
self.filter.changed += self.__updateCarouselData
self.slots = Slots(self.__aData)
self.slots.selected += self.__onSlotSelected
self.slots.updated += self.__onSlotUpdated
self.updated = Event()
def fini(self):
self.slots.selected -= self.__onSlotSelected
self.slots.updated -= self.__onSlotUpdated
self.filter.changed -= self.__updateCarouselData
self.__carouselItems = None
self.__aData = None
self.slots.fini()
self.filter.fini()
return
@property
def items(self):
return self.__carouselItems
@property
def currentType(self):
return self.__currentType
@property
def currentSlotIdx(self):
return self.__currentSlotIdx
def applyItem(self, carouselItemIdx):
carouselItem = self.__carouselItems[carouselItemIdx]
self.slots.applyItem(carouselItem, duration=self.__currentDuration)
def changeDuration(self, duration):
self.__currentDuration = duration
self.__updateCarouselData()
def __onSlotSelected(self, newType, newSlotIdx):
self.__currentType = newType
self.__currentSlotIdx = newSlotIdx
self.filter.setTypeAndIdx(newType, newSlotIdx)
if newType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
self.filter.set(FILTER_TYPE.GROUP, CAMOUFLAGE_GROUP_MAPPING[newSlotIdx])
self.filter.apply()
def __onSlotUpdated(self, newSlotData):
if self.__currentType == newSlotData['type'] and self.__currentSlotIdx == newSlotData['idx']:
self.filter.setTypeAndIdx(newSlotData['type'], newSlotData['idx'])
self.__updateCarouselData()
def __updateCarouselData(self):
oldItemsCount = len(self.__carouselItems)
del self.__carouselItems[:]
appliedItems = defaultdict(list)
purchasedItems = defaultdict(list)
otherItems = defaultdict(list)
allItems = [appliedItems, purchasedItems, otherItems]
currentSlotItem = None
installedItemID = self.slots.getInstalledItem(self.__currentSlotIdx, self.__currentType).getID()
if self.__currentType == CUSTOMIZATION_TYPE.CAMOUFLAGE:
displayedItems = {}
for itemID, item in self.__aData.displayed[self.__currentType].iteritems():
if item.getGroup() == CAMOUFLAGE_GROUP_MAPPING[self.__currentSlotIdx]:
displayedItems[itemID] = item
else:
displayedItems = self.__aData.displayed[self.__currentType]
filterExceptions = {FILTER_TYPE.SHOW_IN_DOSSIER: self.__aData.installed[self.__currentType]}
for itemID, item in displayedItems.iteritems():
if self.filter.check(item, filterExceptions):
appliedToCurrentSlot = itemID == self.slots.getSelectedSlotItemID()
installedInSlot = itemID == installedItemID
isInQuests = item.isInQuests and not item.isInDossier and self.filter.purchaseType == PURCHASE_TYPE.QUEST
carouselItem = {'id': itemID,
'object': item,
'appliedToCurrentSlot': appliedToCurrentSlot,
'price': item.getPrice(self.__currentDuration),
'priceIsGold': item.priceIsGold(self.__currentDuration),
'isInDossier': item.isInDossier,
'isInQuests': isInQuests,
'duration': self.__currentDuration,
'installedInSlot': installedInSlot}
if appliedToCurrentSlot:
currentSlotItem = carouselItem
if installedInSlot:
group = appliedItems[item.getGroup()]
elif item.isInDossier:
group = purchasedItems[item.getGroup()]
else:
group = otherItems[item.getGroup()]
if item.isFeatured:
group.insert(0, carouselItem)
#.........这里部分代码省略.........