Exemplo n.º 1
0
 def synchronize(self, isFullSync, diff):
     dataResetKey = (self.__DATA_KEY, '_r')
     if dataResetKey in diff:
         self.__cache[self.__DATA_KEY] = diff[dataResetKey]
     if self.__DATA_KEY in diff:
         synchronizeDicts(diff[self.__DATA_KEY],
                          self.__cache.setdefault(self.__DATA_KEY, {}))
Exemplo n.º 2
0
    def synchronize(self, isFullSync, diff):
        if isFullSync:
            self.__cache.clear()
        cache = self.__cache
        statsDiff = diff.get('stats', None)
        if statsDiff is not None:
            for stat in _SIMPLE_VALUE_STATS:
                if stat in statsDiff:
                    cache[stat] = statsDiff[stat]

            for stat in _DICT_STATS:
                stat_r = (stat, '_r')
                if stat_r in statsDiff:
                    cache[stat] = statsDiff[stat_r]
                if stat in statsDiff:
                    synchronizeDicts(statsDiff[stat], cache.setdefault(stat, dict()))

            for stat in _GROWING_SET_STATS:
                stat_r = (stat, '_r')
                if stat_r in statsDiff:
                    cache[stat] = statsDiff[stat_r]
                if stat in statsDiff:
                    cache.setdefault(stat, set()).update(statsDiff[stat])

        accountDiff = diff.get('account', None)
        if accountDiff is not None:
            for stat in _ACCOUNT_STATS:
                if stat in accountDiff:
                    cache[stat] = accountDiff[stat]

            if _ADDITIONAL_XP_CACHE_KEY in accountDiff:
                synchronizeDicts(accountDiff[_ADDITIONAL_XP_CACHE_KEY], cache.setdefault(_ADDITIONAL_XP_CACHE_KEY, {}))
        if cache.get('premiumInfo') is None:
            cache['premiumInfo'] = PremiumInfo()
        premiumDiff = diff.get('premium')
        if premiumDiff is not None:
            cache['premiumInfo'].update(premiumDiff)
        economicsDiff = diff.get('economics', None)
        if economicsDiff is not None:
            for stat in ('unlocks', 'eliteVehicles'):
                if stat in economicsDiff:
                    cache.setdefault(stat, set()).update(economicsDiff[stat])
                    cache.setdefault(('initial', stat), set()).update(economicsDiff[stat])

        cacheDiff = diff.get('cache', None)
        if cacheDiff is not None:
            for stat in _CACHE_STATS:
                if stat in cacheDiff:
                    LOG_DEBUG_DEV('CACHE stat change', stat, cacheDiff[stat])
                    cache[stat] = cacheDiff[stat]

            spaDiff = cacheDiff.get('SPA', None)
            if spaDiff:
                synchronizeDicts(spaDiff, cache.setdefault('SPA', dict()))
        piggyBankDiff = diff.get('piggyBank', None)
        if piggyBankDiff is not None:
            synchronizeDicts(piggyBankDiff, cache.setdefault('piggyBank', dict()))
        if _PREFERRED_MAPS_KEY in diff:
            synchronizeDicts(diff[_PREFERRED_MAPS_KEY], cache.setdefault(_PREFERRED_MAPS_KEY, {}))
        return
Exemplo n.º 3
0
    def synchronize(self, isFullSync, diff):
        for item in ('ranked', ):
            itemDiff = diff.get(item, None)
            if itemDiff is not None:
                synchronizeDicts(itemDiff, self.__cache.setdefault(item, {}))

        return
Exemplo n.º 4
0
 def updatePersistentCache(self, ext, isFullSync):
     if ext.pop('__cache', None) is not None:
         if not self.__persistentCache.data:
             desc, cacheData = self.__persistentCache.data = self.__persistentCache.get()
             if accountDataPersistentHash(cacheData) != desc:
                 LOG_ERROR('Local account data cache is corrupted: resync')
                 self._resynchronize()
                 return False
             self.__persistentCache.data = cacheData
             self.__persistentCache.isDirty = False
         else:
             cacheData = self.__persistentCache.data
         if cacheData is None:
             LOG_ERROR("Incorrect cache state while syncing data: server said to use cache but I don't have any")
             self._resynchronize()
             return False
         accountDataMergePersistent(ext, cacheData)
         if synchronizeDicts(accountDataGetDiffForPersistent(ext), self.__persistentCache.data)[1]:
             self.__persistentCache.isDirty = True
     else:
         if self.__persistentCache.data is None:
             self.__persistentCache.data = {}
         synchronizeDicts(accountDataGetDiffForPersistent(ext), self.__persistentCache.data)
         self.__persistentCache.isDirty = True
     return True
 def synchronize(self, isFullSync, diff):
     _logger.debug('Synchronize information about account blueprints')
     if isFullSync:
         self.__cache.clear()
     if _BLUEPRINT_KEY in diff:
         synchronizeDicts(diff[_BLUEPRINT_KEY], self.__cache)
     _logger.debug('User blueprints: %s', self.__cache)
Exemplo n.º 6
0
 def synchronize(self, isFullSync, diff):
     if isFullSync:
         self.__cache.clear()
     changeList = {}
     changeList[''] = diff
     synchronizeDicts(diff, self.__cache, '', changeList, AttributeDict)
     self.__processChangeList(changeList)
Exemplo n.º 7
0
 def synchronize(self, isFullSync, diff):
     if isFullSync:
         self.__cache.clear()
     itemDiff = diff.get('epicMetaGame', None)
     LOG_DEBUG('epicMetaGameCache ', itemDiff)
     if itemDiff is not None:
         synchronizeDicts(itemDiff, self.__cache.setdefault('epicMetaGame', {}))
     return
 def synchronize(self, isFullSync, diff):
     if isFullSync:
         self.__cache.clear()
     itemDiff = diff.get(self.__festivityKey, None)
     _logger.debug('Syncing cache for key %s: %s', self.__festivityKey, itemDiff)
     if itemDiff is not None:
         synchronizeDicts(itemDiff, self.__cache.setdefault(self.__festivityKey, {}))
     return
Exemplo n.º 9
0
 def synchronize(self, isFullSync, diff):
     _logger.debug('Synchronize gift system')
     if isFullSync and self.__cache:
         self.__cache.clear()
     if _CACHE_DIFF_KEY in diff and _GIFT_SYSTEM_KEY in diff[
             _CACHE_DIFF_KEY]:
         synchronizeDicts(diff[_CACHE_DIFF_KEY][_GIFT_SYSTEM_KEY],
                          self.__cache)
     _logger.debug('Gift system info: %s', self.__cache)
 def synchronize(self, isFullSync, diff):
     _logger.debug('Synchronize game restrictions')
     if isFullSync and self.__cache:
         self.__cache.clear()
     if _CACHE_DIFF_KEY in diff and _GAME_RESTRICTIONS_KEY in diff[
             _CACHE_DIFF_KEY]:
         synchronizeDicts(diff[_CACHE_DIFF_KEY][_GAME_RESTRICTIONS_KEY],
                          self.__cache)
     _logger.debug('Game restrictions info: %s', self.__cache)
Exemplo n.º 11
0
    def synchronize(self, isFullSync, diff):
        if isFullSync:
            self.__cache.clear()
        for item in ('tokens', ):
            itemDiff = diff.get(item, None)
            if itemDiff is not None:
                synchronizeDicts(itemDiff, self.__cache.setdefault(item, {}))

        return
Exemplo n.º 12
0
    def synchronize(self, isFullSync, diff):
        if isFullSync:
            self.__cache.clear()
        for item in ('quests', 'potapovQuests', 'questsRewards',
                     'pm2_progress'):
            itemDiff = diff.get(item, None)
            if itemDiff is not None:
                synchronizeDicts(itemDiff, self.__cache.setdefault(item, {}))

        return
Exemplo n.º 13
0
 def synchronize(self, isFullSync, diff):
     if isFullSync:
         self.__cache.clear()
     dataResetKey = (MT_PDATA_KEY, '_r')
     if dataResetKey in diff:
         self.__cache[MT_PDATA_KEY] = diff[dataResetKey]
         self.onMapsTrainingDataChanged(diff)
     if MT_PDATA_KEY in diff:
         synchronizeDicts(diff[MT_PDATA_KEY], self.__cache.setdefault(MT_PDATA_KEY, {}))
         self.onMapsTrainingDataChanged(diff)
 def synchronize(self, isFullSync, diff):
     if isFullSync:
         self.__cache.clear()
     dataResetKey = (BATTLE_PASS_PDATA_KEY, '_r')
     if dataResetKey in diff:
         self.__cache[BATTLE_PASS_PDATA_KEY] = diff[dataResetKey]
     if BATTLE_PASS_PDATA_KEY in diff:
         synchronizeDicts(
             diff[BATTLE_PASS_PDATA_KEY],
             self.__cache.setdefault(BATTLE_PASS_PDATA_KEY, {}))
Exemplo n.º 15
0
 def synchronize(self, isFullSync, diff):
     if isFullSync:
         self._cache.clear()
     itemDiff = diff.get(RS_PDATA_KEY, {})
     if IDLE_CREW_XP_PDATA_KEY in diff:
         itemDiff[IDLE_CREW_XP_PDATA_KEY] = diff[IDLE_CREW_XP_PDATA_KEY]
     if PIGGY_BANK_PDATA_KEY in diff:
         itemDiff[PIGGY_BANK_PDATA_KEY] = diff[PIGGY_BANK_PDATA_KEY]
     if itemDiff:
         synchronizeDicts(itemDiff, self._cache)
         self.onRenewableSubscriptionDataChanged(itemDiff)
    def synchronize(self, isFullSync, diff):
        if isFullSync:
            self.__cache.clear()
        fullMapping = diff.get(('vehiclesGroupMapping', '_r'), {})
        if fullMapping:
            self.__cache['vehiclesGroupMapping'] = dict(fullMapping)
        for item in ('groupLocks', 'vehiclesGroupMapping'):
            itemDiff = diff.get(item, None)
            if itemDiff is not None:
                synchronizeDicts(itemDiff, self.__cache.setdefault(item, {}))

        return
Exemplo n.º 17
0
    def synchronize(self, isFullSync, diff):
        if isFullSync:
            self.__cache.clear()
        recycleBinFull = diff.get(('recycleBin', '_r'), {})
        if recycleBinFull:
            self.__cache = dict(recycleBinFull)
        for item in ('recycleBin', ):
            itemDiff = diff.get(item, None)
            if itemDiff is not None:
                synchronizeDicts(itemDiff, self.__cache.setdefault(item, {}))

        return
    def synchronize(self, isFullSync, diff):
        if isFullSync:
            self.__cache.clear()
        sessionStatsFull = diff.get(('sessionStats', '_r'), {})
        if sessionStatsFull:
            self.__cache['sessionStats'] = dict(sessionStatsFull)
        for item in ('sessionStats', 'wtr'):
            itemDiff = diff.get(item, None)
            if itemDiff is not None:
                synchronizeDicts(itemDiff, self.__cache.setdefault(item, {}))

        return
Exemplo n.º 19
0
    def synchronize(self, isFullSync, diff):
        if isFullSync:
            self.__cache.clear()
        cache = self.__cache
        statsDiff = diff.get('stats', None)
        if statsDiff is not None:
            for stat in _SIMPLE_VALUE_STATS:
                if stat in statsDiff:
                    cache[stat] = statsDiff[stat]

            for stat in _DICT_STATS:
                stat_r = (stat, '_r')
                if stat_r in statsDiff:
                    cache[stat] = statsDiff[stat_r]
                if stat in statsDiff:
                    synchronizeDicts(statsDiff[stat],
                                     cache.setdefault(stat, dict()))

            for stat in _GROWING_SET_STATS:
                stat_r = (stat, '_r')
                if stat_r in statsDiff:
                    cache[stat] = statsDiff[stat_r]
                if stat in statsDiff:
                    cache.setdefault(stat, set()).update(statsDiff[stat])

        accountDiff = diff.get('account', None)
        if accountDiff is not None:
            for stat in _ACCOUNT_STATS:
                if stat in accountDiff:
                    cache[stat] = accountDiff[stat]

        economicsDiff = diff.get('economics', None)
        if economicsDiff is not None:
            for stat in ('unlocks', 'eliteVehicles'):
                if stat in economicsDiff:
                    cache.setdefault(stat, set()).update(economicsDiff[stat])
                    cache.setdefault(('initial', stat),
                                     set()).update(economicsDiff[stat])

        cacheDiff = diff.get('cache', None)
        if cacheDiff is not None:
            for stat in _CACHE_STATS:
                if stat in cacheDiff:
                    LOG_DEBUG_DEV('CACHE stat change', stat, cacheDiff[stat])
                    cache[stat] = cacheDiff[stat]

            spaDiff = cacheDiff.get('SPA', None)
            if spaDiff:
                synchronizeDicts(spaDiff, cache.setdefault('SPA', dict()))
        return
Exemplo n.º 20
0
 def synchronize(self, isFullSync, diff):
     if isFullSync:
         self.__cache.clear()
     dataResetKey = (DT_PDATA_KEY, '_r')
     if dataResetKey in diff:
         itemDiff = diff[dataResetKey]
         synchronizeDicts(itemDiff, self.__cache)
         self.__handleResetNotifications(itemDiff)
         self.onDogTagDataChanged(itemDiff)
     if DT_PDATA_KEY in diff:
         itemDiff = diff[DT_PDATA_KEY]
         synchronizeDicts(itemDiff, self.__cache)
         self.__handleSynchNotifications(itemDiff)
         self.onDogTagDataChanged(itemDiff)
Exemplo n.º 21
0
 def synchronize(self, isFullSync, diff):
     if isFullSync:
         self.__cache.clear()
     goodiesFull = diff.get(('goodies', '_r'))
     if goodiesFull:
         self.__cache = dict(goodiesFull)
     goodiesDiff = diff.get('goodies', None)
     if goodiesDiff is not None:
         synchronizeDicts(goodiesDiff,
                          self.__cache.setdefault('goodies', {}))
     if 'cache' in diff:
         clanReservesDiff = diff['cache'].get('activeOrders', {})
         synchronizeDicts(clanReservesDiff,
                          self.__cache.setdefault('clanReserves', {}))
     return
Exemplo n.º 22
0
    def synchronize(self, diff):
        cacheDiff = diff.get('cache', None)
        spaCache = cacheDiff.get('SPA', None) if cacheDiff else None
        itemDiff = {}
        if spaCache:
            for key in SPA_ATTRS.toClientAttrs():
                value = spaCache.get(key, None)
                if value:
                    try:
                        itemDiff[key] = strtobool(value)
                    except InvalidStringValueException:
                        itemDiff[key] = value

        synchronizeDicts(itemDiff, self.__cache.setdefault('spaFlags', {}))
        return
Exemplo n.º 23
0
    def synchronize(self, isFullSync, diff):
        if isFullSync:
            self.__cache.clear()
        invDiff = diff.get('inventory', None)
        if invDiff is not None:
            for itemTypeIdx, itemInvDiff in invDiff.iteritems():
                synchronizeDicts(itemInvDiff, self.__cache.setdefault(itemTypeIdx, {}))

        cacheDiff = diff.get('cache', None)
        if cacheDiff is not None:
            vehsLockDiff = cacheDiff.get('vehsLock', None)
            if vehsLockDiff is not None:
                itemInvCache = self.__cache.setdefault(_VEHICLE, {})
                synchronizeDicts(vehsLockDiff, itemInvCache.setdefault('lock', {}))
        return
 def synchronize(self, isFullSync, diff):
     if isFullSync and self.__cache:
         self.__cache.clear()
     if RESOURCE_WELL_PDATA_KEY in diff:
         synchronizeDicts(diff[RESOURCE_WELL_PDATA_KEY], self.__cache.setdefault(RESOURCE_WELL_PDATA_KEY, {}))
 def synchronize(self, isFullSync, diff):
     _logger.debug('Synchronize Anonymizer')
     if isFullSync:
         self.clear()
     synchronizeDicts(diff.get(_ANONYMIZER_KEY, {}), self.__cache)
     _logger.debug('Anonymizer info: %s', self.__cache)
Exemplo n.º 26
0
 def _synchronize(self, diff):
     itemDiff = diff.get('offersData')
     if itemDiff is not None:
         synchronizeDicts(itemDiff,
                          self._cache.setdefault('offersData', {}))
     return