class Player(object):
def nick_html_colors(self):
- return html_colors(self.nick)
+ if self.nick is None:
+ return "Anonymous Player"
+ else:
+ return html_colors(self.nick)
def nick_strip_colors(self):
- return strip_colors(self.nick)
+ if self.nick is None:
+ return "Anonymous Player"
+ else:
+ return strip_colors(self.nick)
def __repr__(self):
return "<Player(%s, %s, %s, %s)>" % (self.player_id, self.nick,
import re
from datetime import datetime
-def strip_colors(str=None):
+def strip_colors(str=''):
+ if str is None:
+ str = ''
+
str = re.sub(r'\^x\w\w\w', '', str)
str = re.sub(r'\^\d', '', str)
return str
-def html_colors(str=None):
+def html_colors(str=''):
+ if str is None:
+ str = ''
+
orig = str
str = re.sub(r'\^x(\w)(\w)(\w)',
"<span style='color:#\g<1>\g<1>\g<2>\g<2>\g<3>\g<3>'>", str)