Update of /cvsroot/pybot/pybot/pybot
In directory sc8-pr-cvs1:/tmp/cvs-serv20387/pybot
Modified Files:
misc.py refrag.py
Log Message:
* pybot/misc.py: Introduced striphtml().
* pybot/rss.py: Allow all news to be colapsed in one line.
Strip html from fields. Other minor changes and fixes.
Index: misc.py
===================================================================
RCS file: /cvsroot/pybot/pybot/pybot/misc.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** misc.py 24 Aug 2003 19:30:53 -0000 1.5
--- misc.py 26 Aug 2003 19:56:22 -0000 1.6
***************
*** 22,26 ****
import re
! __all__ = ["buildanswer", "breakline"]
MAXLINESIZE = 400
--- 22,26 ----
import re
! __all__ = ["buildanswer", "breakline", "regexp", "striphtml"]
MAXLINESIZE = 400
***************
*** 109,112 ****
--- 109,124 ----
expr += "\s*$"
return re.compile(expr, re.I)
+
+ STRIPHTML = re.compile("<.*?>")
+ def striphtml(s):
+ s = STRIPHTML.sub("", s)
+ if '&' not in s:
+ return s
+ s = s.replace("<", "<")
+ s = s.replace(">", ">")
+ s = s.replace("'", "'")
+ s = s.replace(""", '"')
+ s = s.replace("&", "&") # Must be last
+ return s
# vim:ts=4:sw=4:et
Index: refrag.py
===================================================================
RCS file: /cvsroot/pybot/pybot/pybot/refrag.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** refrag.py 25 Aug 2003 18:54:54 -0000 1.1
--- refrag.py 26 Aug 2003 19:56:23 -0000 1.2
***************
*** 76,81 ****
def __init__(self):
Fragment.__init__(self)
! self._expr = r"(?:\s+(?:to|for|on|at|in)\s+(?:(?P<_thischannel>this\s+channel)|(?P<_me>me)|(?:user|channel)\s+(?P<_target>\S+))(?:\s+(?:for|on|at|in)\s+(?:(?P<_thisserver>this\s+server)|server\s+(?P<_server>\S+)))?)"
! self._expr_onlyserverallowed = r"((?:\s+(?:to|for|on|at|in)\s+(?:(?P<_thischannel>this\s+channel)|(?P<_me>me)|(?:user|channel)\s+(?P<_target>\S+)))?(?:\s+(?:for|on|at|in)\s+(?:(?P<_thisserver>this\s+server)|server\s+(?P<_server>\S+)))?)"
def expr(self, optional=0, onlyserverallowed=0):
--- 76,81 ----
def __init__(self):
Fragment.__init__(self)
! self._expr = r"(?:\s+(?:to|for|on|at|in)?\s+(?:(?P<_thischannel>this\s+channel)|(?P<_me>me)|(?:user|channel)\s+(?P<_target>\S+))(?:\s+(?:for|on|at|in|of)?\s+(?:(?P<_thisserver>this\s+server)|server\s+(?P<_server>\S+)))?)"
! self._expr_onlyserverallowed = r"((?:\s+(?:to|for|on|at|in)?\s+(?:(?P<_thischannel>this\s+channel)|(?P<_me>me)|(?:user|channel)\s+(?P<_target>\S+)))?(?:\s+(?:for|on|at|in|of)?\s+(?:(?P<_thisserver>this\s+server)|server\s+(?P<_server>\S+)))?)"
def expr(self, optional=0, onlyserverallowed=0):
|