diff orpg/chat/chat_util.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 4385a7d0efd1
children 1ed2feab0db9
line wrap: on
line diff
--- 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 <script> issue
     p = re.compile( '<(\s*)(/*)[Ss][Cc][Rr][Ii][Pp][Tt](.*?)>')
@@ -97,6 +103,7 @@
 # removes all li tags (start and end)
 # 05-13-2005
 #================================================
+@debugging
 def strip_li_tags(string):
     #kill the <li> issue
     string = re.sub( r'<(\s*)[Ll][Ii](.*?)>', r'<b><font color="#000000" size=+1>*</font></b>    ', string)
@@ -111,6 +118,7 @@
 #   through legitimate means such as the OpenRPG settings.
 # 07-27-2005 by mDuo13
 #================================================
+@debugging
 def strip_body_tags(string):
     bodytag_regex = re.compile(r"""<\/?body.*?>""", re.I)
     string = re.sub(bodytag_regex, "", string)
@@ -128,7 +136,8 @@
 # algorithm simply closes them, allowing them to be
 # used legitimately without causing much annoyance.
 # 07-27-2005 mDuo13
-#================================================
+#================================================
+@debugging
 def strip_misalignment_tags(string):
     alignment_regex = re.compile(r"""<p([^>]*?)align\s*=\s*('.*?'|".*?"|[^\s>]*)(.*?)>""", re.I)
     string = re.sub(alignment_regex, "<p\\1\\3>", string)
@@ -148,7 +157,8 @@
 # removes all img tags (start and end)
 # 05-13-2005
 # redone 07-11-2005 by mDuo13
-#================================================
+#================================================
+@debugging
 def strip_img_tags(string):
     #This is a Settings definable feature, Allowing users to enable or disable image display to fix the client crash due to large img posted to chat.
     #p = re.sub( r'<(\s*)(/*)[Ii][Mm][Gg][ ][Ss][Rr][Cc][=](.*?)>', r'<!-- img tag removed //--> <a href=\3>\3</a>', string)