Mercurial > traipse_dev
comparison orpg/chat/chat_msg.py @ 71:449a8900f9ac ornery-dev
Code refining almost completed, for this round. Some included files are still in need of some clean up, but this is test worthy.
author | sirebral |
---|---|
date | Thu, 20 Aug 2009 03:00:39 -0500 |
parents | c54768cffbd4 |
children | 37d26a98883f |
comparison
equal
deleted
inserted
replaced
70:52a5fa913008 | 71:449a8900f9ac |
---|---|
27 # | 27 # |
28 # | 28 # |
29 | 29 |
30 __version__ = "$Id: chat_msg.py,v 1.15 2006/11/04 21:24:19 digitalxero Exp $" | 30 __version__ = "$Id: chat_msg.py,v 1.15 2006/11/04 21:24:19 digitalxero Exp $" |
31 | 31 |
32 #import orpg.orpg_xml | |
33 from orpg.orpgCore import * | 32 from orpg.orpgCore import * |
34 from chat_version import CHAT_VERSION | 33 from chat_version import CHAT_VERSION |
34 from orpg.tools.orpg_log import logger | |
35 from orpg.tools.decorators import debugging | |
35 | 36 |
36 CHAT_MESSAGE = 1 | 37 CHAT_MESSAGE = 1 |
37 WHISPER_MESSAGE = 2 | 38 WHISPER_MESSAGE = 2 |
38 EMOTE_MESSAGE = 3 | 39 EMOTE_MESSAGE = 3 |
39 INFO_MESSAGE = 4 | 40 INFO_MESSAGE = 4 |
40 SYSTEM_MESSAGE = 5 | 41 SYSTEM_MESSAGE = 5 |
41 WHISPER_EMOTE_MESSAGE = 6 | 42 WHISPER_EMOTE_MESSAGE = 6 |
42 | 43 |
43 class chat_msg: | 44 class chat_msg: |
45 @debugging | |
44 def __init__(self,xml_text="<chat type=\"1\" version=\""+CHAT_VERSION+"\" alias=\"\" ></chat>"): | 46 def __init__(self,xml_text="<chat type=\"1\" version=\""+CHAT_VERSION+"\" alias=\"\" ></chat>"): |
45 self.xml = component.get('xml') | |
46 self.chat_dom = None | 47 self.chat_dom = None |
47 self.takexml(xml_text) | 48 self.takexml(xml_text) |
48 | 49 |
50 @debugging | |
49 def __del__(self): | 51 def __del__(self): |
50 if self.chat_dom: | 52 if self.chat_dom: |
51 self.chat_dom.unlink() | 53 self.chat_dom.unlink() |
52 | 54 |
55 @debugging | |
53 def toxml(self): | 56 def toxml(self): |
54 return self.xml.toxml(self.chat_dom) | 57 return component.get('xml').toxml(self.chat_dom) |
55 | 58 |
59 @debugging | |
56 def takexml(self,xml_text): | 60 def takexml(self,xml_text): |
57 #self.xml = component.get('xml') | 61 xml_dom = component.get('xml').parseXml(xml_text) |
58 xml_dom = self.xml.parseXml(xml_text) | |
59 node_list = xml_dom.getElementsByTagName("chat") | 62 node_list = xml_dom.getElementsByTagName("chat") |
60 if len(node_list) < 1: | 63 if len(node_list) < 1: |
61 print "Warning: no <chat/> elements found in DOM." | 64 print "Warning: no <chat/> elements found in DOM." |
62 else: | 65 else: |
63 if len(node_list) > 1: | 66 if len(node_list) > 1: |
64 print "Found more than one instance of <" + self.tagname + "/>. Taking first one" | 67 print "Found more than one instance of <" + self.tagname + "/>. Taking first one" |
65 self.takedom(node_list[0]) | 68 self.takedom(node_list[0]) |
66 | 69 |
70 @debugging | |
67 def takedom(self,xml_dom): | 71 def takedom(self,xml_dom): |
68 if self.chat_dom: | 72 if self.chat_dom: |
69 self.text_node = None | 73 self.text_node = None |
70 self.chat_dom.unlink() | 74 self.chat_dom.unlink() |
71 self.chat_dom = xml_dom | 75 self.chat_dom = xml_dom |
72 self.text_node = self.xml.safe_get_text_node(self.chat_dom) | 76 self.text_node = component.get('xml').safe_get_text_node(self.chat_dom) |
73 | 77 |
78 @debugging | |
74 def set_text(self,text): | 79 def set_text(self,text): |
75 text = self.xml.strip_text(text) | 80 text = component.get('xml').strip_text(text) |
76 self.text_node._set_nodeValue(text) | 81 self.text_node._set_nodeValue(text) |
77 | 82 |
83 @debugging | |
78 def set_type(self,type): | 84 def set_type(self,type): |
79 self.chat_dom.setAttribute("type",str(type)) | 85 self.chat_dom.setAttribute("type",str(type)) |
80 | 86 |
87 @debugging | |
81 def get_type(self): | 88 def get_type(self): |
82 return int(self.chat_dom.getAttribute("type")) | 89 return int(self.chat_dom.getAttribute("type")) |
83 | 90 |
91 @debugging | |
84 def set_alias(self,alias): | 92 def set_alias(self,alias): |
85 self.chat_dom.setAttribute("alias",alias) | 93 self.chat_dom.setAttribute("alias",alias) |
86 | 94 |
95 @debugging | |
87 def get_alias(self): | 96 def get_alias(self): |
88 return self.chat_dom.getAttribute("alias") | 97 return self.chat_dom.getAttribute("alias") |
89 | 98 |
99 @debugging | |
90 def get_text(self): | 100 def get_text(self): |
91 return self.text_node._get_nodeValue() | 101 return self.text_node._get_nodeValue() |
92 | 102 |
103 @debugging | |
93 def get_version(self): | 104 def get_version(self): |
94 return self.chat_dom.getAttribute("version") | 105 return self.chat_dom.getAttribute("version") |