def html_escape(text):
"""Produce entities within text."""
- return "".join(html_escape_table.get(c, c) for c in text)
+ return ''.join(html_escape_table.get(c, c) for c in text)
def strtm_to_dtm(struc_time):
self.thread_killed = False
def send(self, message):
- """simple wrapper around JabberBot().send()"""
- self.bot.log.debug(self.bot.room)
+ """simple wrapper around bot send_message method"""
self.bot.send_message(mto=self.bot.room,
mbody=message[1],
mhtml=message[0],
# Cannot resolve address
if 'status' not in parsed_feed:
- self.bot.log.error(u'Error from "%s": %s.' %
+ self.bot.log.error('Error from "%s": %s.' %
(feed, parsed_feed.bozo_exception.__repr__()))
return
# unusual return http code
if parsed_feed.status != 200:
self.bot.log.error(
- u'Got code %(status)d from "%(href)s" (please update).' %
+ 'Got code %(status)d from "%(href)s" (please update).' %
parsed_feed)
return
self.bot.log.debug('last check: %s' % self.last_check)
return
- title = u'"%s":' % parsed_feed.feed.get('title', 'n/a')
- xtitle = u'<strong>%s</strong>:' % html_escape(
+ title = '"%s":' % parsed_feed.feed.get('title', 'n/a')
+ xtitle = '<strong>%s</strong>:' % html_escape(
parsed_feed.feed.get('title', 'n/a'))
text = [title]
xhtml = [xtitle]
self.seen[feed_id].append(post.id)
self.bot.log.info(post.title)
- body = u'%(title)s %(link)s' % post
+ body = '%(title)s %(link)s' % post
text.append(body)
xpost = dict(**post)
xpost['title'] = html_escape(xpost.get('title', 'n/a'))
- xbody = u'<a href="%(link)s">%(title)s</a>' % xpost
+ xbody = '<a href="%(link)s">%(title)s</a>' % xpost
xhtml.append(xbody)
if len(text) > 1:
def run(self):
while not self.thread_killed:
- self.bot.log.info(u'feeds check')
+ self.bot.log.debug('feeds check')
for feed in self.feeds_list:
try:
self.new_posts(feed)
except Exception as err:
- self.bot.log.error(u'feeds thread crashed')
+ self.bot.log.error('feeds thread crashed')
self.bot.log.error(err)
self.thread_killed = True
self.last_check = datetime.datetime.utcnow()
!feeds : registred feeds list
!feeds last : last check time"""
if 'last' in args:
- return u'Last feeds check: %s' % self.th_mon.last_check
- return u'\n'.join(Feeds.FEEDS)
+ return 'Last feeds check: %s' % self.th_mon.last_check
+ return '\n'.join(Feeds.FEEDS)