コード例 #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
コード例 #2
0
ファイル: decorators.py プロジェクト: webiumsk/WOT-0.9.12
 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
コード例 #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
コード例 #4
0
ファイル: __init__.py プロジェクト: webiumsk/WOT-0.9.14-CT
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)
コード例 #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)
コード例 #6
0
 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
コード例 #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
コード例 #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)
コード例 #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
コード例 #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)
コード例 #11
0
ファイル: __init__.py プロジェクト: webiumsk/WOT-0.9.14-CT
def getPrebattleLocalizedString(string, led = None, escapeHtml = False):
    result = ''
    if led:
        result = i18n.encodeUtf8(led.get(string, ''))
        if escapeHtml:
            html.escape(result)
    return result
コード例 #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
コード例 #13
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())
コード例 #14
0
ファイル: rssnewsfeed.py プロジェクト: webiumsk/WOT-0.9.15-CT
    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)}
コード例 #15
0
ファイル: rssnewsfeed.py プロジェクト: jamesxia4/wot_client
    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)}
コード例 #16
0
ファイル: __init__.py プロジェクト: webiumsk/WOT-0.9.12-CT
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)
コード例 #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)
コード例 #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)
コード例 #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())
コード例 #20
0
ファイル: items.py プロジェクト: webiumsk/WOT0.9.10
 def getUserShortDescription(self):
     return i18n.encodeUtf8(self._clubDescr.shortDescription or '')
コード例 #21
0
ファイル: items.py プロジェクト: webiumsk/WOT0.9.10
 def getUserName(self):
     return i18n.encodeUtf8(self._clubDescr.name)
コード例 #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
コード例 #23
0
ファイル: chat_message.py プロジェクト: webiumsk/WOT-0.9.15.1
 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
コード例 #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
コード例 #25
0
 def getStringFormat(cls, value):
     return i18n.encodeUtf8(value)
コード例 #26
0
 def _populate(self):
     super(ConnectToSecureChannelWindow, self)._populate()
     self.as_infoMessageS(
         i18n.makeString(
             MESSENGER.DIALOGS_CONNECTINGTOSECURECHANNEL_LABELS_INFO,
             i18n.encodeUtf8(self._channel.getFullName())))
コード例 #27
0
 def __handleScreenShotMade(self, event):
     if "path" not in event.ctx:
         return
     self.showMessage("SCREENSHOT_CREATED", {"path": i18n.encodeUtf8(event.ctx["path"])})
コード例 #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
コード例 #29
0
ファイル: __init__.py プロジェクト: wotmods/WOTDecompiled
 def getStringFormat(cls, value):
     return i18n.encodeUtf8(value)
コード例 #30
0
ファイル: items.py プロジェクト: webiumsk/WOT-0.9.15.1
 def getUserName(self):
     return i18n.encodeUtf8(self._clubDescr.name)
コード例 #31
0
 def __handleScreenShotMade(self, event):
     if 'path' not in event.ctx:
         return
     self.showMessage('SCREENSHOT_CREATED', {'path': i18n.encodeUtf8(event.ctx['path'])})
コード例 #32
0
ファイル: items.py プロジェクト: webiumsk/WOT-0.9.15.1
 def getUserShortDescription(self):
     return i18n.encodeUtf8(self._clubDescr.shortDescription or '')
コード例 #33
0
 def __handleScreenShotMade(self, event):
     if 'path' not in event.ctx:
         return
     self.showMessage('SCREENSHOT_CREATED', {'path': i18n.encodeUtf8(event.ctx['path'])})
コード例 #34
0
 def _populate(self):
     super(ConnectToSecureChannelWindow, self)._populate()
     self.as_infoMessageS(i18n.makeString(MESSENGER.DIALOGS_CONNECTINGTOSECURECHANNEL_LABELS_INFO, i18n.encodeUtf8(self._channel.getFullName())))
コード例 #35
0
ファイル: items.py プロジェクト: krzcho/WOTDecompiled
 def getUserDescription(self):
     return i18n.encodeUtf8(self.__clubDescr.description or '')