# HG changeset patch # User sirebral # Date 1250755239 18000 # Node ID 449a8900f9ace67a6637ab63830fb53ae5d6d8b2 # Parent 52a5fa913008ac8b21392f5ee932206349668302 Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy. diff -r 52a5fa913008 -r 449a8900f9ac orpg/chat/chat_msg.py --- a/orpg/chat/chat_msg.py Tue Aug 18 20:48:36 2009 -0500 +++ b/orpg/chat/chat_msg.py Thu Aug 20 03:00:39 2009 -0500 @@ -29,9 +29,10 @@ __version__ = "$Id: chat_msg.py,v 1.15 2006/11/04 21:24:19 digitalxero Exp $" -#import orpg.orpg_xml from orpg.orpgCore import * -from chat_version import CHAT_VERSION +from chat_version import CHAT_VERSION +from orpg.tools.orpg_log import logger +from orpg.tools.decorators import debugging CHAT_MESSAGE = 1 WHISPER_MESSAGE = 2 @@ -40,22 +41,24 @@ SYSTEM_MESSAGE = 5 WHISPER_EMOTE_MESSAGE = 6 -class chat_msg: +class chat_msg: + @debugging def __init__(self,xml_text=""): - self.xml = component.get('xml') self.chat_dom = None self.takexml(xml_text) - + + @debugging def __del__(self): if self.chat_dom: self.chat_dom.unlink() - + + @debugging def toxml(self): - return self.xml.toxml(self.chat_dom) - + return component.get('xml').toxml(self.chat_dom) + + @debugging def takexml(self,xml_text): - #self.xml = component.get('xml') - xml_dom = self.xml.parseXml(xml_text) + xml_dom = component.get('xml').parseXml(xml_text) node_list = xml_dom.getElementsByTagName("chat") if len(node_list) < 1: print "Warning: no elements found in DOM." @@ -63,32 +66,40 @@ if len(node_list) > 1: print "Found more than one instance of <" + self.tagname + "/>. Taking first one" self.takedom(node_list[0]) - + + @debugging def takedom(self,xml_dom): if self.chat_dom: self.text_node = None self.chat_dom.unlink() self.chat_dom = xml_dom - self.text_node = self.xml.safe_get_text_node(self.chat_dom) - + self.text_node = component.get('xml').safe_get_text_node(self.chat_dom) + + @debugging def set_text(self,text): - text = self.xml.strip_text(text) + text = component.get('xml').strip_text(text) self.text_node._set_nodeValue(text) - + + @debugging def set_type(self,type): self.chat_dom.setAttribute("type",str(type)) - + + @debugging def get_type(self): return int(self.chat_dom.getAttribute("type")) - + + @debugging def set_alias(self,alias): self.chat_dom.setAttribute("alias",alias) - + + @debugging def get_alias(self): return self.chat_dom.getAttribute("alias") - + + @debugging def get_text(self): return self.text_node._get_nodeValue() - + + @debugging def get_version(self): return self.chat_dom.getAttribute("version") diff -r 52a5fa913008 -r 449a8900f9ac orpg/chat/chat_util.py --- a/orpg/chat/chat_util.py Tue Aug 18 20:48:36 2009 -0500 +++ b/orpg/chat/chat_util.py Thu Aug 20 03:00:39 2009 -0500 @@ -1,7 +1,10 @@ # utility function; see Post() in chatwnd.py import re -import string +import string +from orpg.orpgCore import * +from orpg.tools.orpg_log import logger +from orpg.tools.decorators import debugging #============================================ # simple_html_repair(string) @@ -15,8 +18,9 @@ # to cause issues with the chat display # # Created 04-25-2005 by Snowdog -#============================================= -def simple_html_repair(string): +#============================================= +@debugging +def simple_html_repair(string): "Returns string with extra > symbols to isolate badly formated HTML" #walk though string checking positions of < and > tags. first_instance = string.find('<') @@ -67,24 +71,26 @@ if diff > 0: for d in range(1,diff): string = string+">" + return string - return string - -def strip_unicode(txt): +""" Depricated! Might as well use the already made component.get('xml') +def strip_unicode(txt): for i in xrange(len(txt)): if txt[i] not in string.printable: try: txt = txt.replace(txt[i], '&#' + str(ord(txt[i])) + ';') except: txt = txt.replace(txt[i], '{?}') - return txt + return txt +""" #================================================ # strip_script_tags(string) # # removes all script tags (start and end) # 04-26-2005 Snowdog -#================================================ +#================================================ +@debugging def strip_script_tags(string): #kill the