def screentofile(screen,path): f = open(path+'.emu','w') g = open(path+'.brp','w') f.write(utf_8.encode(screen.emubuffer)[0]) g.write(utf_8.encode(screen.colorbuffer)[0]) f.close() g.close()
def onRoomCreateContinue(self, roomVO): if messenger.g_xmppChatHandler: from messenger.XmppChat import ChannelType chatJid, chatPass = messenger.g_xmppChatHandler.createChannel( ChannelType.TRAINING) roomDescription = self._filterChain.chainIn( convertToLocal(roomVO.roomDescription), 0, BigWorld.time()) roomDescription = utf_8.encode(roomDescription)[0] roomData = { 'mapID': roomVO.mapID, 'roomDescription': roomDescription[:consts.TRAINING_ROOM_CREATE_DESCRIPTION_LIMIT], 'durationBattle': roomVO.durationBattle, 'planeLevelFrom': roomVO.planeLevelFrom, 'planeLevelTo': roomVO.planeLevelTo, 'chatJid': chatJid, 'chatPass': chatPass, 'planeHidden': roomVO.planeHidden } LOG_DEBUG('onRoomCreateContinue', roomData) self.__getAccountCmd().getTrainingCreateRoomCreated(roomData) self.positionInUI = self.TrainingRoomUI.IN_CREATE_ROOM self.__roomSettings['chatJid'] = chatJid self.__roomSettings['chatPass'] = chatPass
def __filterMessage(self, text, userUid): owner = BigWorld.player() if owner and owner.id != userUid: if Settings.g_instance.getXmppChatSettings( )['messageFilterEnabled']: result = self._filterChain.chainIn(convertToLocal(text), userUid, BigWorld.time()) return utf_8.encode(result)[0] return text
def signature(params, http_method, secret): ''' Calulate signature for params and http_method according to https://help.aliyun.com/document_detail/25492.html Args: params(dict[string]string): the params to signature http_method(string): HTTP or HTTPS secret(string): the signature secret Returns: (string) the signature for the given input ''' qry = "" for k, v in sorted(params.items()): ek = Pop.percent_encode(k) ev = Pop.percent_encode(v) qry += '&{}={}'.format(ek, ev) to_sign = '{}&%2F&{}'.format(http_method, Pop.percent_encode(qry[1:])) bf = bytearray(utf_8.encode(to_sign)[0]) dig = hmac.digest(utf_8.encode(secret + "&")[0], bf, hashlib.sha1) return utf_8.decode(base64.standard_b64encode(dig))[0]
def write_string(conn, s): if s is None: write_bytes(conn, NONE_PREFIX) elif isinstance(s, unicode): b = utf_8.encode(s)[0] b_len = len(b) write_bytes(conn, UNICODE_PREFIX) write_int(conn, b_len) if b_len > 0: write_bytes(conn, b) else: s_len = len(s) write_bytes(conn, ASCII_PREFIX) write_int(conn, s_len) if s_len > 0: write_bytes(conn, s)
def write_string(conn, s): if s is None: write_bytes(conn, NONE_PREFIX) elif isinstance(s, str): b = utf_8.encode(s)[0] b_len = len(b) write_bytes(conn, UNICODE_PREFIX) write_int(conn, b_len) if b_len > 0: write_bytes(conn, b) else: s_len = len(s) write_bytes(conn, ASCII_PREFIX) write_int(conn, s_len) if s_len > 0: write_bytes(conn, s)
def get_alias(self, string: str) -> int: try: alias = self.aliases_by_string[string] except KeyError: encoded_string, consumed = utf8codec.encode(string) assert consumed == len(string) alias = fnv1a_32(encoded_string) try: conflicting_string = self.strings_by_alias[alias] except KeyError: self.strings_by_alias[alias] = string self.aliases_by_string[string] = alias self.is_dirty = True else: raise StringTable.HashCollisionError( "The fnv1a hash {} of the new string '{}' " "collides with that of the existing string " "{}".format(alias, string, conflicting_string)) return alias
def filterInMessage(self, text, userUid, msgTime, filteringType): if filteringType == FilteringType.FULL: if self.__lastFilteringType is not None and self.__lastFilteringType != filteringType: filters.ObsceneLanguageFilter.applyReplacementFunction() result = self._filterChain.chainIn(i18n.convert(text), userUid, msgTime) elif filteringType == FilteringType.ADMIN and GameEnvironment.getHUD( ) is None: if not self._filterChainAdmin: self.__initFilterChainAdmin() if self.__lastFilteringType is not None and self.__lastFilteringType != filteringType: filters.ColoringObsceneLanguageFilter.applyReplacementFunction( ) result = self._filterChainAdmin.chainIn(i18n.convert(text), userUid, msgTime) elif filteringType == FilteringType.SHORT: result = html.escape(i18n.convert(text)) else: result = text LOG_TRACE('Xmpp chat: unknown message filtering type ', filteringType) self.__lastFilteringType = filteringType return utf_8.encode(result)[0]
def __str__(self): return "{0} - {1}, {2}".format(encode(self.first_name), encode(self.last_name), self.type)
def __str__(self): return "{0} - {1} Guests".format(encode(self.family_name), len(self.attendees.all()))
def __str__(self): return "{0} - {1}, {2}".format(self.type, encode(self.name), encode(self.town))
def writeLineToMorfeusz(self, x): self.morfeuszProcess.stdin.write(utf_8.encode(x + "\n")[0]) self.morfeuszProcess.stdin.flush()
def rot13encode(input, errors='strict'): """ Convert unicode to rot13-ed raw bytes. """ return utf_8.encode(rot13(input), errors)
# 关键字实参 say(mes="ddd") print(list(set([1,2,3]+[2,3,4]))) # json.dumps() a=None print(study1.dog1.dog().getDog()) class Mydog(study1.dog1.dog): def __init__(self): super().__init__() self.age="12" def getDog(self): return self.name+","+self.age def getDog1(self,*location): return self.name+","+self.age+"|".join(location.__str__()) print(Mydog().getDog1(2,231,212,12)) dict=OrderedDict() print(utf_8.encode("我们")) doctest.testmod()
def onChangeDescription(self, txtDescription): roomDescription = self._filterChain.chainIn( convertToLocal(txtDescription), 0, BigWorld.time()) roomDescription = utf_8.encode(roomDescription)[0] self.__getAccountCmd().changeDescription( roomDescription[:consts.TRAINING_ROOM_CREATE_DESCRIPTION_LIMIT])