当前位置: 首页>>代码示例>>Python>>正文


Python storage.storage_getter函数代码示例

本文整理汇总了Python中messenger.storage.storage_getter函数的典型用法代码示例。如果您正苦于以下问题:Python storage_getter函数的具体用法?Python storage_getter怎么用?Python storage_getter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了storage_getter函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __updateUsersData

    def __updateUsersData(self, userDBIDs):
        diff = []
        userGetter = storage_getter('users')().getUser
        colorGetter = g_settings.getColorScheme('rosters').getColors
        for userDBID in userDBIDs:
            data = findFirst(lambda d: d['creator'].get('dbID') == userDBID, self.collection)
            if data is not None:
                clubDBID = data['cfdUnitID']
                try:
                    index = self.mapping[clubDBID]
                    item = self.collection[index]
                except (KeyError, IndexError):
                    LOG_ERROR('Item not found', clubDBID)
                    continue

                creator = userGetter(userDBID)
                creatorVO = makeUserVO(creator, colorGetter)
                creatorName = creator.getName()
                item.update({'creatorName': creatorName,
                 'rating': self.getGuiUserRating(userDBID)})
                if creator.hasValidName():
                    item['creator'] = creatorVO
                diff.append(index)

        if len(diff):
            self.updateItems(diff)
        return
开发者ID:webiumsk,项目名称:WOT-0.9.15-CT,代码行数:27,代码来源:rally_dps.py

示例2: buildList

    def buildList(self, selectedID, result):
        self.clear()
        userGetter = storage_getter('users')().getUser
        colorGetter = g_settings.getColorScheme('rosters').getColors
        pNameGetter = g_lobbyContext.getPeripheryName
        ratingFormatter = BigWorld.wg_getIntegralFormat
        self._selectedIdx = -1
        for unitItem in result:
            creator = unitItem.creator
            if creator:
                dbID = creator.dbID
                creatorVO = makePlayerVO(creator, userGetter(dbID), colorGetter)
            else:
                creatorVO = None
            cfdUnitID = unitItem.cfdUnitID
            index = len(self.collection)
            if cfdUnitID == selectedID:
                self._selectedIdx = index
            self.mapping[cfdUnitID] = index
            self.collection.append({'cfdUnitID': cfdUnitID,
             'unitMgrID': unitItem.unitMgrID,
             'creator': creatorVO,
             'creatorName': creatorVO.get('userName', ''),
             'rating': ratingFormatter(unitItem.rating),
             'playersCount': unitItem.playersCount,
             'commandSize': unitItem.commandSize,
             'inBattle': unitItem.state.isInArena(),
             'isFreezed': unitItem.state.isLocked(),
             'isRestricted': unitItem.isRosterSet,
             'description': unitItem.description,
             'peripheryID': unitItem.peripheryID,
             'server': pNameGetter(unitItem.peripheryID)})

        return self._selectedIdx
开发者ID:Infernux,项目名称:Projects,代码行数:34,代码来源:rally_dps.py

示例3: _getSlotsData

def _getSlotsData(unitIdx, unit, unitState, pInfo, slotsIter, app = None, levelsRange = None, checkForVehicles = True):
    isPlayerCreator = pInfo.isCreator()
    isPlayerInSlot = pInfo.isInSlot
    slots = []
    userGetter = storage_getter('users')().getUser
    colorGetter = g_settings.getColorScheme('rosters').getColors
    vehicleGetter = g_itemsCache.items.getItemByCD
    if app:
        isPlayerSpeaking = app.voiceChatManager.isPlayerSpeaking
    else:
        isPlayerSpeaking = lambda dbID: False
    if unitState.isFortBattle():
        makeVO = makeClanBattlePlayerVO
    elif unitState.isSortie():
        makeVO = makeSortiePlayerVO
    else:
        makeVO = makePlayerVO
    for slotInfo in slotsIter:
        index = slotInfo.index
        slotState = slotInfo.state
        player = slotInfo.player
        vehicle = slotInfo.vehicle
        canAssign, vehicles = pInfo.canAssignToSlot(index)
        vehCount = len(vehicles)
        slotLevel = 0
        vehicleVO = None
        slotPlayerUI = None
        if player is not None:
            dbID = player.dbID
            slotPlayerUI = makeVO(player, userGetter(dbID), colorGetter, isPlayerSpeaking(dbID))
            if vehicle:
                if 'vehLevel' in vehicle:
                    slotLevel = vehicle['vehLevel']
                if 'vehTypeCompDescr' in vehicle:
                    vehicleVO = makeVehicleVO(vehicleGetter(vehicle['vehTypeCompDescr']), levelsRange)
        slotLabel = makeSlotLabel(unitState, slotState, isPlayerCreator, vehCount, checkForVehicles)
        playerStatus = getPlayerStatus(slotState, player, unitState.isFortBattle())
        if unit is not None:
            restrictions = makeUnitRosterVO(unit, pInfo, index=index, isSortie=unitState.isSortie(), levelsRange=levelsRange)['conditions']
        else:
            restrictions = []
        isFreezed = unitState.isLocked() or unitState.isInSearch() or unitState.isInQueue() or unitState.isInArena()
        slot = {'rallyIdx': unitIdx,
         'isCommanderState': isPlayerCreator,
         'isCurrentUserInSlot': isPlayerInSlot,
         'playerStatus': playerStatus,
         'isClosed': slotState.isClosed,
         'isFreezed': isFreezed,
         'slotLabel': slotLabel,
         'player': slotPlayerUI,
         'canBeTaken': canAssign,
         'compatibleVehiclesCount': vehCount,
         'selectedVehicle': vehicleVO,
         'selectedVehicleLevel': 1 if slotState.isClosed else slotLevel,
         'restrictions': restrictions}
        slots.append(slot)

    return slots
开发者ID:webiumsk,项目名称:WoT,代码行数:58,代码来源:vo_converters.py

示例4: updateList

    def updateList(self, selectedID, result):
        isFullUpdate, diff = False, []
        self._selectedIdx = None
        userGetter = storage_getter("users")().getUser
        colorGetter = g_settings.getColorScheme("rosters").getColors
        ratingFormatter = BigWorld.wg_getIntegralFormat
        result = set(result)
        removed = set(filter(lambda item: item[1] is None, result))
        isFullUpdate = len(removed)
        for cfdUnitID, unitItem in removed:
            index = self.mapping.pop(cfdUnitID, None)
            if index is not None:
                self.collection.pop(index)
                if cfdUnitID == selectedID:
                    self._selectedIdx = -1
                self.rebuildIndexes()

        if isFullUpdate:
            updated = result.difference(removed)
        else:
            updated = result
        for cfdUnitID, unitItem in updated:
            try:
                index = self.mapping[cfdUnitID]
                item = self.collection[index]
            except (KeyError, IndexError):
                LOG_ERROR("Item not found", unitItem)
                continue

            creator = unitItem.creator
            if creator:
                dbID = creator.dbID
                creatorVO = makePlayerVO(creator, userGetter(dbID), colorGetter)
            else:
                creatorVO = None
            item.update(
                {
                    "creator": creatorVO,
                    "creatorName": creatorVO.get("userName", ""),
                    "rating": ratingFormatter(unitItem.rating),
                    "playersCount": unitItem.playersCount,
                    "commandSize": unitItem.commandSize,
                    "inBattle": unitItem.flags.isInArena() or unitItem.flags.isInPreArena(),
                    "isFreezed": unitItem.flags.isLocked(),
                    "isRestricted": unitItem.isRosterSet,
                    "description": unitItem.description,
                }
            )
            diff.append(index)

        if self._selectedIdx is None and selectedID in self.mapping:
            self._selectedIdx = self.mapping[selectedID]
        if isFullUpdate:
            self.refresh()
        elif len(diff):
            self.updateItems(diff)
        return self._selectedIdx
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:57,代码来源:rally_dps.py

示例5: _buildData

 def _buildData(self, candidates):
     isPlayerSpeaking = self.bwProto.voipController.isPlayerSpeaking
     userGetter = storage_getter('users')().getUser
     colorGetter = g_settings.getColorScheme('rosters').getColors
     mapping = map(lambda pInfo: (pInfo, userGetter(pInfo.dbID)), candidates.itervalues())
     sortedList = sorted(mapping, cmp=getUnitCandidatesComparator())
     for pInfo, user in sortedList:
         dbID = pInfo.dbID
         self._mapping[dbID] = len(self._list)
         self._list.append(self._makePlayerVO(pInfo, user, colorGetter, isPlayerSpeaking(dbID)))
开发者ID:webiumsk,项目名称:WOT-0.9.15.1,代码行数:10,代码来源:rally_dps.py

示例6: updateListItem

 def updateListItem(self, userDBID):
     for item in self.collection:
         creator = item.get('creator', None)
         if creator is None:
             return 
         creatorDBID = creator.get('dbID', None)
         if userDBID == creatorDBID:
             userGetter = storage_getter('users')().getUser
             colorGetter = g_settings.getColorScheme('rosters').getColors
             colors = colorGetter(userGetter(creatorDBID).getGuiType())
             creator['colors'] = colors
             self.refresh()
             return 
开发者ID:Infernux,项目名称:Projects,代码行数:13,代码来源:rally_dps.py

示例7: _buildData

 def _buildData(self, candidates):
     if self.app is not None:
         isPlayerSpeaking = self.app.voiceChatManager.isPlayerSpeaking
     else:
         isPlayerSpeaking = lambda dbID: False
     userGetter = storage_getter('users')().getUser
     colorGetter = g_settings.getColorScheme('rosters').getColors
     mapping = map(lambda pInfo: (pInfo, userGetter(pInfo.dbID)), candidates.itervalues())
     sortedList = sorted(mapping, cmp=getUnitCandidatesComparator())
     for (pInfo, user,) in sortedList:
         dbID = pInfo.dbID
         self._mapping[dbID] = len(self._list)
         self._list.append(self._makePlayerVO(pInfo, user, colorGetter, isPlayerSpeaking(dbID)))
开发者ID:Infernux,项目名称:Projects,代码行数:13,代码来源:rally_dps.py

示例8: updateList

    def updateList(self, selectedID, result):
        (isFullUpdate, diff,) = (False, [])
        self._selectedIdx = None
        userGetter = storage_getter('users')().getUser
        colorGetter = g_settings.getColorScheme('rosters').getColors
        ratingFormatter = BigWorld.wg_getIntegralFormat
        result = set(result)
        removed = set(filter(lambda item: item[1] is None, result))
        isFullUpdate = len(removed)
        for (cfdUnitID, unitItem,) in removed:
            index = self.mapping.pop(cfdUnitID, None)
            if index is not None:
                self.collection.pop(index)
                if cfdUnitID == selectedID:
                    self._selectedIdx = -1
                self.rebuildIndexes()

        if isFullUpdate:
            updated = result.difference(removed)
        else:
            updated = result
        for (cfdUnitID, unitItem,) in updated:
            try:
                index = self.mapping[cfdUnitID]
                item = self.collection[index]
            except (KeyError, IndexError):
                LOG_ERROR('Item not found', unitItem)
                continue
            creator = unitItem.creator
            if creator:
                dbID = creator.dbID
                creatorVO = makePlayerVO(creator, userGetter(dbID), colorGetter)
            else:
                creatorVO = None
            item.update({'creator': creatorVO,
             'rating': ratingFormatter(unitItem.rating),
             'playersCount': unitItem.playersCount,
             'commandSize': unitItem.commandSize,
             'inBattle': unitItem.state.isInArena(),
             'isFreezed': unitItem.state.isLocked(),
             'isRestricted': unitItem.isRosterSet,
             'description': unitItem.description})
            diff.append(index)

        if self._selectedIdx is None and selectedID in self.mapping:
            self._selectedIdx = self.mapping[selectedID]
        if isFullUpdate:
            self.refresh()
        elif len(diff):
            self.updateItems(diff)
        return self._selectedIdx
开发者ID:Infernux,项目名称:Projects,代码行数:51,代码来源:rally_dps.py

示例9: onUnitRosterChanged

 def onUnitRosterChanged(self):
     super(FortBattleRoomWindow, self).onUnitRosterChanged()
     chat = self.chat
     if chat:
         _, unit = self.unitFunctional.getUnit()
         commanderID = unit.getCommanderDBID()
         if commanderID != getPlayerDatabaseID():
             getter = storage_getter('users')
             commander = getter().getUser(commanderID)
             division = getDivisionNameByUnit(unit)
             divisionName = i18n.makeString(I18N_SYSTEM_MESSAGES.unit_notification_divisiontype(division))
             key = I18N_SYSTEM_MESSAGES.UNIT_NOTIFICATION_CHANGEDIVISION
             txt = i18n.makeString(key, name=commander.getName(), division=divisionName)
             chat.addNotification(txt)
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:14,代码来源:fortbattleroomwindow.py

示例10: updateListItem

    def updateListItem(self, userDBID):
        for item in self.collection:
            creator = item.get("creator", None)
            if creator is None:
                return
            creatorDBID = creator.get("dbID", None)
            if userDBID == creatorDBID:
                userGetter = storage_getter("users")().getUser
                colorGetter = g_settings.getColorScheme("rosters").getColors
                colors = colorGetter(userGetter(creatorDBID).getGuiType())
                creator["colors"] = colors
                self.refresh()
                return

        return
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:15,代码来源:rally_dps.py

示例11: buildList

    def buildList(self, selectedID, result, syncUserInfo=True):
        self.clear()
        userGetter = storage_getter("users")().getUser
        colorGetter = g_settings.getColorScheme("rosters").getColors
        ratingFormatter = BigWorld.wg_getIntegralFormat
        self._selectedIdx = -1
        self._lastResult = result
        data = []
        for clubItem in result:
            cfdUnitID = clubItem.getID()
            creatorID = clubItem.getCreatorID()
            rating = self.getUserRating(creatorID)
            creator = self._UserEntityAdapter(creatorID, clubItem, userGetter(creatorID), self)
            creatorName = creator.getName()
            creatorVO = makeUserVO(creator, colorGetter)
            index = len(self.collection)
            if cfdUnitID == selectedID:
                self._selectedIdx = index
            self.mapping[cfdUnitID] = index
            data.append(
                (
                    rating,
                    {
                        "cfdUnitID": cfdUnitID,
                        "unitMgrID": cfdUnitID,
                        "creator": creatorVO,
                        "creatorName": creatorName,
                        "rating": self.getGuiUserRating(creatorID),
                        "playersCount": clubItem.getMembersCount(),
                        "commandSize": clubItem.getCommandSize(),
                        "inBattle": False,
                        "isFreezed": False,
                        "isRestricted": False,
                        "description": html.escape(clubItem.getShortDescription()),
                        "peripheryID": -1,
                        "server": None,
                        "ladderIcon": getLadderChevron16x16(clubItem.getDivision()),
                        "isStatic": True,
                    },
                )
            )

        self.collection.extend(map(lambda (r, c): c, sorted(data, reverse=True, key=operator.itemgetter(0))))
        if syncUserInfo:
            self.syncUsersInfo()
        return self._selectedIdx
开发者ID:webiumsk,项目名称:WOT-0.9.12,代码行数:46,代码来源:rally_dps.py

示例12: __init__

 def __init__(self, accountsIDs, response, usersCache = None):
     if len(accountsIDs) > 1:
         errors = map(lambda (c, dbID): dbID, response.data.get('errors', []))
     else:
         errors = []
     self._successNames = []
     self._errorNames = []
     self._accountsIDs = accountsIDs
     if usersCache is None:
         usersGetter = storage_getter('users')()
     else:
         usersGetter = usersCache.get
     for dbID in accountsIDs:
         user = usersGetter(dbID)
         if not user:
             continue
         if dbID not in errors:
             self._successNames.append(user.getFullName(dbID))
         else:
             self._errorNames.append(user.getFullName(dbID))
开发者ID:kblw,项目名称:wot_client,代码行数:20,代码来源:formatters.py

示例13: buildList

    def buildList(self, selectedID, result, syncUserInfo = True):
        self.clear()
        userGetter = storage_getter('users')().getUser
        colorGetter = g_settings.getColorScheme('rosters').getColors
        ratingFormatter = BigWorld.wg_getIntegralFormat
        self._selectedIdx = -1
        self._lastResult = result
        data = []
        for clubItem in result:
            cfdUnitID = clubItem.getID()
            creatorID = clubItem.getCreatorID()
            creator = userGetter(creatorID)
            rating = self.getUserRating(creatorID)
            if creator is None:
                creator = self._UserEntityAdapter(creatorID, self)
            creatorName = creator.getName()
            creatorVO = makeUserVO(creator, colorGetter)
            index = len(self.collection)
            if cfdUnitID == selectedID:
                self._selectedIdx = index
            self.mapping[cfdUnitID] = index
            data.append((rating, {'cfdUnitID': cfdUnitID,
              'unitMgrID': cfdUnitID,
              'creator': creatorVO,
              'creatorName': creatorName,
              'rating': ratingFormatter(rating),
              'playersCount': clubItem.getMembersCount(),
              'commandSize': clubItem.getCommandSize(),
              'inBattle': False,
              'isFreezed': False,
              'isRestricted': False,
              'description': html.escape(clubItem.getShortDescription()),
              'peripheryID': -1,
              'server': None,
              'ladderIcon': getLadderChevron16x16(clubItem.getDivision()),
              'isStatic': True}))

        self.collection.extend(map(lambda (r, c): c, sorted(data, reverse=True, key=operator.itemgetter(0))))
        if syncUserInfo:
            self.syncUsersInfo()
        return self._selectedIdx
开发者ID:krzcho,项目名称:WOTDecompiled,代码行数:41,代码来源:rally_dps.py

示例14: _getSlotsData

def _getSlotsData(unitIdx, unit, unitState, pInfo, slotsIter, app = None, levelsRange = None, checkForVehicles = True):
    isPlayerCreator = pInfo.isCreator()
    isPlayerInSlot = pInfo.isInSlot
    slots = []
    userGetter = storage_getter('users')().getUser
    colorGetter = g_settings.getColorScheme('rosters').getColors
    vehicleGetter = g_itemsCache.items.getItemByCD
    canTakeSlot = not pInfo.isLegionary()
    if app:
        isPlayerSpeaking = app.voiceChatManager.isPlayerSpeaking
    else:
        isPlayerSpeaking = lambda dbID: False
    if unit.isSquad():
        falloutBattleType = unit.getExtra().eventType
        isFallout = falloutBattleType != FALLOUT_BATTLE_TYPE.UNDEFINED
        falloutCfg = g_eventsCache.getFalloutConfig(falloutBattleType)
    else:
        falloutBattleType = FALLOUT_BATTLE_TYPE.UNDEFINED
        isFallout = False
        falloutCfg = None
    if unit is None:
        makeVO = makePlayerVO
    elif unit.isFortBattle():
        makeVO = makeClanBattlePlayerVO
    elif unit.isSortie():
        makeVO = makeSortiePlayerVO
    elif unit.isClub():
        makeVO = makeStaticFormationPlayerVO
    else:
        makeVO = makePlayerVO
    for slotInfo in slotsIter:
        index = slotInfo.index
        slotState = slotInfo.state
        player = slotInfo.player
        vehicle = slotInfo.vehicle
        canAssign, vehicles = pInfo.canAssignToSlot(index)
        vehCount = len(vehicles)
        slotLevel = 0
        vehicleVO = None
        slotPlayerUI = None
        if player is not None:
            dbID = player.dbID
            slotPlayerUI = makeVO(player, userGetter(dbID), colorGetter, isPlayerSpeaking(dbID))
            isCurrentPlayer = player.isCurrentPlayer()
            if vehicle:
                if 'vehLevel' in vehicle:
                    slotLevel = vehicle['vehLevel']
                if 'vehTypeCompDescr' in vehicle:
                    vehicleVO = makeVehicleVO(vehicleGetter(vehicle['vehTypeCompDescr']), levelsRange, isCurrentPlayer=isCurrentPlayer)
        if unit is not None and unit.isClub():
            slotLabel = makeStaticSlotLabel(unitState, slotState, isPlayerCreator, vehCount, checkForVehicles, pInfo.isLegionary(), unit.isRated())
        else:
            isRequired = falloutBattleType == FALLOUT_BATTLE_TYPE.MULTITEAM
            slotLabel = makeSlotLabel(unitState, slotState, isPlayerCreator, vehCount, checkForVehicles, isRequired=isRequired)
        if unit.isSquad():
            playerStatus = getSquadPlayerStatus(slotState, player)
        else:
            playerStatus = getPlayerStatus(slotState, player)
        if unit is not None:
            restrictions = makeUnitRosterVO(unit, pInfo, index=index, isSortie=unit.isSortie(), levelsRange=levelsRange)['conditions']
        else:
            restrictions = []
        slot = {'rallyIdx': unitIdx,
         'isCommanderState': isPlayerCreator,
         'isCurrentUserInSlot': isPlayerInSlot,
         'playerStatus': playerStatus,
         'isClosed': slotState.isClosed,
         'isFreezed': unitState.isFreezed(),
         'slotLabel': slotLabel,
         'player': slotPlayerUI,
         'canBeTaken': canAssign and canTakeSlot,
         'compatibleVehiclesCount': vehCount,
         'selectedVehicle': vehicleVO,
         'selectedVehicleLevel': 1 if slotState.isClosed else slotLevel,
         'restrictions': restrictions,
         'isFallout': isFallout}
        if isFallout:
            vehiclesNotify = [None, None, None]
            selectedVehicles = [None, None, None]
            if player is not None:
                dbID = player.dbID
                isCurrentPlayer = player.isCurrentPlayer()
                if isCurrentPlayer:
                    if falloutBattleType == FALLOUT_BATTLE_TYPE.MULTITEAM:
                        vehiclesNotify[0] = [i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYMULTITEAM)]
                    else:
                        vehiclesNotify[0] = [i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFY, level=text_styles.main(int2roman(falloutCfg.vehicleLevelRequired)))]
                    if len(falloutCfg.allowedLevels) > 1:
                        statusTemplate = i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYRANGE, level=text_styles.main(toRomanRangeString(list(falloutCfg.allowedLevels), 1)))
                    else:
                        statusTemplate = i18n.makeString(MESSENGER.DIALOGS_FALLOUTSQUADCHANNEL_VEHICLENOTIFYMULTITEAM)
                    for slotIdx in range(1, falloutCfg.minVehiclesPerPlayer):
                        vehiclesNotify[slotIdx] = statusTemplate

                for idx, (vInvID, vehIntCD) in enumerate(unit.getExtra().accountVehicles.get(dbID, ())):
                    selectedVehicles[idx] = makeVehicleVO(vehicleGetter(vehIntCD), falloutCfg.allowedLevels, isCurrentPlayer=isCurrentPlayer)

            slot['vehiclesNotify'] = vehiclesNotify
            slot['selectedVehicle'] = selectedVehicles
        slots.append(slot)
#.........这里部分代码省略.........
开发者ID:kblw,项目名称:wot_client,代码行数:101,代码来源:vo_converters.py

示例15: isSender

 def isSender(self):
     user = storage_getter('users')().getUser(self.getSenderID())
     if user:
         return user.isCurrentPlayer()
     return False
开发者ID:webiumsk,项目名称:WOT-0.9.15.1,代码行数:5,代码来源:entities.py


注:本文中的messenger.storage.storage_getter函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。