works even if html5lib is missing
This commit is contained in:
parent
36bc436739
commit
8a32f75c0a
3 changed files with 25 additions and 12 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -72,13 +72,16 @@ class Message:
|
|||
def is_new(self):
|
||||
return self.new
|
||||
|
||||
def __eq__(self, msg):
|
||||
return self.id == msg.id and self.thread_id == msg.thread_id
|
||||
|
||||
def __repr__(self):
|
||||
result = '<Message id="%s" title="%s" date="%s" from="%s">' % (
|
||||
self.id, self.title, self.date, self.sender)
|
||||
return result.encode('utf-8')
|
||||
|
||||
class ICapMessages:
|
||||
def iter_messages(self):
|
||||
def iter_new_messages(self):
|
||||
"""
|
||||
Iterates on new messages from last time this function has been called.
|
||||
|
||||
|
|
@ -86,6 +89,12 @@ class ICapMessages:
|
|||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
class ICapMessagesReply:
|
||||
def post_reply(self, message):
|
||||
def iter_messages(self):
|
||||
"""
|
||||
Iterates on every messages
|
||||
"""
|
||||
raise NotImplementedError()
|
||||
|
||||
class ICapMessagesReply:
|
||||
def post_reply(self, to, message):
|
||||
raise NotImplementedError()
|
||||
|
|
|
|||
|
|
@ -20,9 +20,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
import mechanize
|
||||
import urllib2
|
||||
import html5lib
|
||||
import ClientForm
|
||||
from html5lib import treebuilders
|
||||
try:
|
||||
from html5lib import treebuilders, HTMLParser
|
||||
except ImportError:
|
||||
# XXX change this to use another lib than html5lib
|
||||
class StandardParser:
|
||||
def parse(self, data):
|
||||
return None
|
||||
else:
|
||||
class StandardParser(HTMLParser):
|
||||
def __init__(self):
|
||||
HTMLParser.__init__(self, tree=treebuilders.getTreeBuilder("dom"))
|
||||
|
||||
def parse(self, data):
|
||||
return HTMLParser.parse(data, encoding='iso-8859-1')
|
||||
import re
|
||||
import time
|
||||
from logging import warning, error
|
||||
|
|
@ -60,13 +72,6 @@ class BasePage:
|
|||
def loaded(self):
|
||||
pass
|
||||
|
||||
class StandardParser(html5lib.HTMLParser):
|
||||
def __init__(self):
|
||||
html5lib.HTMLParser.__init__(self, tree=treebuilders.getTreeBuilder("dom"))
|
||||
|
||||
def parse(self, data):
|
||||
return html5lib.HTMLParser.parse(data, encoding='iso-8859-1')
|
||||
|
||||
class Browser(mechanize.Browser):
|
||||
|
||||
# ------ Class attributes --------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue