diff orpg/chat/chat_util.py @ 18:97265586402b ornery-orc

Traipse 'OpenRPG' {090827-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc''s main goal is to offer more advanced features and enhance the productivity of the user. Update Summary: Update Manager is now in version 0.8. While not every button works, users can now browse the different revisions and their different changesets. The code has been refined some with feature from Core added to it. A Crash report is now created if the users software crashes. Update Manager has been moved to the Traipse Suite menu item, and a Debug Console as been added as well.
author sirebral
date Thu, 27 Aug 2009 01:04:43 -0500
parents 4385a7d0efd1
children ff154cf3350c
line wrap: on
line diff
--- a/orpg/chat/chat_util.py	Thu Aug 13 13:14:10 2009 -0500
+++ b/orpg/chat/chat_util.py	Thu Aug 27 01:04:43 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)