Esempio n. 1
0
 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
Esempio n. 2
0
 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
Esempio n. 3
0
 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
Esempio n. 4
0
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)
Esempio n. 5
0
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
Esempio n. 7
0
 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
Esempio n. 8
0
 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)
Esempio n. 9
0
def getPrebattleLocalizedString(string, led=None, escapeHtml=False):
    result = ''
    if led:
        result = i18n.encodeUtf8(led.get(string, ''))
        if escapeHtml:
            html.escape(result)
    return result
Esempio n. 10
0
    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)
Esempio n. 11
0
def getPrebattleLocalizedString(string, led = None, escapeHtml = False):
    result = ''
    if led:
        result = i18n.encodeUtf8(led.get(string, ''))
        if escapeHtml:
            html.escape(result)
    return result
Esempio n. 12
0
 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())
Esempio n. 14
0
    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)}
Esempio n. 15
0
    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)}
Esempio n. 16
0
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)
Esempio n. 17
0
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)
Esempio n. 18
0
    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)
Esempio n. 19
0
 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())
Esempio n. 20
0
 def getUserShortDescription(self):
     return i18n.encodeUtf8(self._clubDescr.shortDescription or '')
Esempio n. 21
0
 def getUserName(self):
     return i18n.encodeUtf8(self._clubDescr.name)
Esempio n. 22
0
 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
Esempio n. 23
0
 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
Esempio n. 24
0
 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
Esempio n. 25
0
 def getStringFormat(cls, value):
     return i18n.encodeUtf8(value)
Esempio n. 26
0
 def _populate(self):
     super(ConnectToSecureChannelWindow, self)._populate()
     self.as_infoMessageS(
         i18n.makeString(
             MESSENGER.DIALOGS_CONNECTINGTOSECURECHANNEL_LABELS_INFO,
             i18n.encodeUtf8(self._channel.getFullName())))
Esempio n. 27
0
 def __handleScreenShotMade(self, event):
     if "path" not in event.ctx:
         return
     self.showMessage("SCREENSHOT_CREATED", {"path": i18n.encodeUtf8(event.ctx["path"])})
Esempio n. 28
0
 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
Esempio n. 29
0
 def getStringFormat(cls, value):
     return i18n.encodeUtf8(value)
Esempio n. 30
0
 def getUserName(self):
     return i18n.encodeUtf8(self._clubDescr.name)
Esempio n. 31
0
 def __handleScreenShotMade(self, event):
     if 'path' not in event.ctx:
         return
     self.showMessage('SCREENSHOT_CREATED', {'path': i18n.encodeUtf8(event.ctx['path'])})
Esempio n. 32
0
 def getUserShortDescription(self):
     return i18n.encodeUtf8(self._clubDescr.shortDescription or '')
Esempio n. 33
0
 def __handleScreenShotMade(self, event):
     if 'path' not in event.ctx:
         return
     self.showMessage('SCREENSHOT_CREATED', {'path': i18n.encodeUtf8(event.ctx['path'])})
Esempio n. 34
0
 def _populate(self):
     super(ConnectToSecureChannelWindow, self)._populate()
     self.as_infoMessageS(i18n.makeString(MESSENGER.DIALOGS_CONNECTINGTOSECURECHANNEL_LABELS_INFO, i18n.encodeUtf8(self._channel.getFullName())))
Esempio n. 35
0
 def getUserDescription(self):
     return i18n.encodeUtf8(self.__clubDescr.description or '')