def _make(self, item=None, settings=None): if not item: raise AssertionError("Item is not defined") self._itemName = item.getName() if settings: self._settings = settings layout, states = self._makeButtonsLayout(item) topic = i18n.encodeUtf8(item.getTopic()) if len(topic): topic = g_settings.htmlTemplates.format("notificationsCenterTopic", ctx={"topic": topic}) body = i18n.encodeUtf8(item.getBody()) note = item.getNote() len(note) and body += g_settings.htmlTemplates.format("notificationsCenterNote", ctx={"note": note}) bgSource, (_, bgHeight) = item.getLocalBG() message = g_settings.msgTemplates.format( "wgncNotification_v2", ctx={"topic": topic, "body": body}, data={ "icon": makePathToIcon(item.getLocalIcon()), "defaultIcon": makePathToIcon(WGNC_DEFAULT_ICON), "bgIcon": {None: makePathToIcon(bgSource)}, "bgIconHeight": bgHeight, "buttonsLayout": layout, "buttonsStates": states, }, ) self._vo = { "typeID": self.getType(), "entityID": self.getID(), "message": message, "notify": self.isNotify(), "auxData": [], } return
def _make(self, item = None, settings = None): if not item: raise AssertionError('Item is not defined') self._itemName = item.getName() if settings: self._settings = settings layout, states = self._makeButtonsLayout(item) topic = i18n.encodeUtf8(item.getTopic()) if len(topic): topic = g_settings.htmlTemplates.format('notificationsCenterTopic', ctx={'topic': topic}) body = i18n.encodeUtf8(item.getBody()) note = item.getNote() len(note) and body += g_settings.htmlTemplates.format('notificationsCenterNote', ctx={'note': note}) bgSource, (_, bgHeight) = item.getLocalBG() message = g_settings.msgTemplates.format('wgncNotification_v2', ctx={'topic': topic, 'body': body}, data={'icon': makePathToIcon(item.getLocalIcon()), 'defaultIcon': makePathToIcon(WGNC_DEFAULT_ICON), 'bgIcon': {None: makePathToIcon(bgSource)}, 'bgIconHeight': bgHeight, 'buttonsLayout': layout, 'buttonsStates': states}) self._vo = {'typeID': self.getType(), 'entityID': self.getID(), 'message': message, 'notify': self.isNotify(), 'auxData': []} return
def getPrebattleOpponents(extraData, escapeHtml = False): first = '' second = '' if 'opponents' in extraData: opponents = extraData['opponents'] first = i18n.encodeUtf8(opponents.get('1', {}).get('name', '')) second = i18n.encodeUtf8(opponents.get('2', {}).get('name', '')) if escapeHtml: first = html.escape(first) second = html.escape(second) return (first, second)
def getPrebattleOpponents(extraData, escapeHtml=False): first = '' second = '' if 'opponents' in extraData: opponents = extraData['opponents'] first = i18n.encodeUtf8(opponents.get('1', {}).get('name', '')) second = i18n.encodeUtf8(opponents.get('2', {}).get('name', '')) if escapeHtml: first = html.escape(first) second = html.escape(second) return (first, second)
def setName(self, avatarSessionID, pName=None, suffix=''): if pName is not None: pName = i18n.encodeUtf8(pName) name = self.sessionProvider.getCtx().getPlayerFullName( avatarSessionID=avatarSessionID, pName=pName) self._ctx['playerName'] = unicode(name + suffix, 'utf-8') return self
def setName(self, dbID, pName=None): if pName is not None: pName = i18n.encodeUtf8(pName) name = g_sessionProvider.getCtx().getPlayerFullName(accID=dbID, pName=pName) self._ctx['playerName'] = unicode(name, 'utf-8') return self
def getFullPlayerName(self, chatAction): pName = None try: pName = i18n.encodeUtf8(chatAction.originatorNickName) except UnicodeError: LOG_ERROR('Can not encode nick name', chatAction) return g_sessionProvider.getCtx().getFullPlayerName(accID=chatAction.originator, pName=pName)
def getPrebattleLocalizedString(string, led=None, escapeHtml=False): result = '' if led: result = i18n.encodeUtf8(led.get(string, '')) if escapeHtml: html.escape(result) return result
def handleLoginRejectedBan(self, status, message): try: LOG_DEBUG('handleLoginRejectedBan', message) msg_dict = json.loads(message) if not isinstance(msg_dict, dict): self.handleLoginCustomDefinedError(status, message) return self.__loginDataLoader.token2 = msg_dict.get('token2', '') self.__loginDataLoader.saveUserToken(self.__loginDataLoader.passLength, self.__loginDataLoader.token2) json_dict = msg_dict.get('bans') msg_dict = json.loads(json_dict) except Exception: LOG_CURRENT_EXCEPTION() self.handleLoginCustomDefinedError(status, message) return expiryTime = 0 reason = '' if isinstance(msg_dict, dict): expiryTime = int(msg_dict.get('expiryTime', 0)) reason = i18n.encodeUtf8(msg_dict.get('reason', '')) if reason == BAN_REASON.CHINA_MIGRATION: self.__handleMigrationNeeded() if reason.startswith('#'): reason = i18n.makeString(reason) if expiryTime > 0: expiryTime = makeLocalServerTime(expiryTime) expiryTime = BigWorld.wg_getLongDateFormat(expiryTime) + ' ' + BigWorld.wg_getLongTimeFormat(expiryTime) errorMessage = i18n.makeString(MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN, time=expiryTime, reason=reason) else: errorMessage = i18n.makeString(MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN_UNLIMITED, reason=reason) self.onSetStatus(errorMessage, self.ALL_VALID)
def getPrebattleLocalizedString(string, led = None, escapeHtml = False): result = '' if led: result = i18n.encodeUtf8(led.get(string, '')) if escapeHtml: html.escape(result) return result
def __exitFromLazyChannel(self): self.__exitCallbackID = None if self._channel and self._channel.isJoined(): LOG_DEBUG('Send request to exit from lazy channel', i18n.encodeUtf8(self._channel.getName())) self.exit() return
def exitFromLazyChannels(self): channels = self.channelsStorage.getChannelsByCriteria( find_criteria.BWLazyChannelFindCriteria(LAZY_CHANNEL.ALL)) for channel in channels: if channel.isJoined(): LOG_DEBUG('Send request to exit from lazy channel', i18n.encodeUtf8(channel.getName())) self.exitFromChannel(channel.getID())
def __prepareData(self, entryData): description = entryData.get('description') if description is not None: try: section = ResMgr.DataSection() section.createSectionFromString(encodeUtf8(description)) _, section = findFirst(lambda (name, _): name == 'div', section.items()) description, _ = unicode_from_utf8(section.asString) if len(description) > self.DESCRIPTION_MAX_LENGTH: description = description[:self.DESCRIPTION_CUT_LENGTH] + self.DESCRIPTION_TAIL except Exception: LOG_ERROR('Invalid RSS entry description', entryData, description) LOG_CURRENT_EXCEPTION() return return {'id': entryData.get('id', str(uuid.uuid4())), 'link': entryData.get('link'), 'description': encodeUtf8(description)}
def changeStringCasing(string, isUpper): langID = getLanguageCode() try: string = string.decode('utf-8') if langID is not None: langID = str(langID).lower() if langID in _STR_CASING_OPTIONS: plID, slID, sortOrder = _STR_CASING_OPTIONS[langID] string = BigWorld.wg_changeStringCasing(string, plID, slID, sortOrder, isUpper) else: string = string.upper() if isUpper else string.lower() if langID in _REPLACEMENTS: for wrong, right in zip(*_REPLACEMENTS[langID]): string = string.replace(wrong, right) except: LOG_CURRENT_EXCEPTION() return i18n.encodeUtf8(string)
def handleLoginRejectedBan(self, status, message): try: LOG_DEBUG('handleLoginRejectedBan', message) msg_dict = json.loads(message) if not isinstance(msg_dict, dict): self.handleLoginCustomDefinedError(status, message) return self.__loginDataLoader.token2 = msg_dict.get('token2', '') self.__loginDataLoader.saveUserToken( self.__loginDataLoader.passLength, self.__loginDataLoader.token2) json_dict = msg_dict.get('bans') msg_dict = json.loads(json_dict) except Exception: LOG_CURRENT_EXCEPTION() self.handleLoginCustomDefinedError(status, message) return expiryTime = 0 reason = '' if isinstance(msg_dict, dict): expiryTime = int(msg_dict.get('expiryTime', 0)) reason = i18n.encodeUtf8(msg_dict.get('reason', '')) if reason == BAN_REASON.CHINA_MIGRATION: self.__handleMigrationNeeded() if reason.startswith('#'): reason = i18n.makeString(reason) if expiryTime > 0: expiryTime = makeLocalServerTime(expiryTime) expiryTime = BigWorld.wg_getLongDateFormat( expiryTime) + ' ' + BigWorld.wg_getLongTimeFormat(expiryTime) errorMessage = i18n.makeString( MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN, time=expiryTime, reason=reason) else: errorMessage = i18n.makeString( MENU.LOGIN_STATUS_LOGIN_REJECTED_BAN_UNLIMITED, reason=reason) self.onSetStatus(errorMessage, self.ALL_VALID)
def exitFromLazyChannels(self): channels = self.channelsStorage.getChannelsByCriteria(find_criteria.BWLazyChannelFindCriteria(LAZY_CHANNEL.ALL)) for channel in channels: if channel.isJoined(): LOG_DEBUG('Send request to exit from lazy channel', i18n.encodeUtf8(channel.getName())) self.exitFromChannel(channel.getID())
def getUserShortDescription(self): return i18n.encodeUtf8(self._clubDescr.shortDescription or '')
def getUserName(self): return i18n.encodeUtf8(self._clubDescr.name)
def setName(self, dbID, pName = None): if pName: pName = i18n.encodeUtf8(pName) self._ctx['playerName'] = g_sessionProvider.getCtx().getFullPlayerName(accID=dbID, pName=pName) return self
def setName(self, dbID, pName = None): if pName is not None: pName = i18n.encodeUtf8(pName) name = g_sessionProvider.getCtx().getPlayerFullName(accID=dbID, pName=pName) self._ctx['playerName'] = unicode(name, 'utf-8') return self
def setName(self, dbID, pName=None): if pName: pName = i18n.encodeUtf8(pName) self._ctx['playerName'] = g_sessionProvider.getCtx().getFullPlayerName( accID=dbID, pName=pName) return self
def getStringFormat(cls, value): return i18n.encodeUtf8(value)
def _populate(self): super(ConnectToSecureChannelWindow, self)._populate() self.as_infoMessageS( i18n.makeString( MESSENGER.DIALOGS_CONNECTINGTOSECURECHANNEL_LABELS_INFO, i18n.encodeUtf8(self._channel.getFullName())))
def __handleScreenShotMade(self, event): if "path" not in event.ctx: return self.showMessage("SCREENSHOT_CREATED", {"path": i18n.encodeUtf8(event.ctx["path"])})
def __handleScreenShotMade(self, event): if 'path' not in event.ctx: return self.showMessage('SCREENSHOT_CREATED', {'path': i18n.encodeUtf8(event.ctx['path'])})
def _populate(self): super(ConnectToSecureChannelWindow, self)._populate() self.as_infoMessageS(i18n.makeString(MESSENGER.DIALOGS_CONNECTINGTOSECURECHANNEL_LABELS_INFO, i18n.encodeUtf8(self._channel.getFullName())))
def getUserDescription(self): return i18n.encodeUtf8(self.__clubDescr.description or '')