comparison sat_frontends/quick_frontend/quick_chat.py @ 2847:c055a3a4ecb0

quick frontend(chat): display a useful message with __unicode__ and __str__
author Goffi <goffi@goffi.org>
date Sun, 10 Mar 2019 18:02:54 +0100
parents 76f714b12d21
children c2858e63cd82
comparison
equal deleted inserted replaced
2846:58ea675d0f05 2847:c055a3a4ecb0
83 self._mention = True 83 self._mention = True
84 break 84 break
85 self.handleMe() 85 self.handleMe()
86 self.widgets = set() # widgets linked to this message 86 self.widgets = set() # widgets linked to this message
87 87
88 def __unicode__(self):
89 return u"Message<{mess_type}> [{time}]{nick}> {message}".format(
90 mess_type=self.type,
91 time=self.time_text,
92 nick=self.nick,
93 message=self.main_message)
94
95 def __str__(self):
96 return self.__unicode__().encode('utf-8', 'ignore')
97
88 @property 98 @property
89 def host(self): 99 def host(self):
90 return self.parent.host 100 return self.parent.host
91 101
92 @property 102 @property
326 def contact_list(self): 336 def contact_list(self):
327 return self.host.contact_lists[self.profile] 337 return self.host.contact_lists[self.profile]
328 338
329 ## Widget management ## 339 ## Widget management ##
330 340
331 def __str__(self): 341 def __unicode__(self):
332 return u"Chat Widget [target: {}, type: {}, profile: {}]".format( 342 return u"Chat Widget [target: {}, type: {}, profile: {}]".format(
333 self.target, self.type, self.profile 343 self.target, self.type, self.profile
334 ) 344 )
335 345
336 @staticmethod 346 @staticmethod