Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
start = start and int(start) or 0
feed = event.session.query(Feed).filter_by(name=name).first()
if not feed:
event.addresponse(u"I don't know about the %s feed", name)
return
feed.update()
if not feed.entries:
event.addresponse(u"I can't access that feed")
return
articles = feed.entries[start:number+start]
articles = [u'%s: "%s"' % (feed.entries.index(entry) + 1,
html2text_file(entry.title, None).strip())
for entry in articles]
event.addresponse(u', '.join(articles))
return
article = feed.entries[int(number) - 1]
else:
pattern = re.compile(pattern, re.I)
for entry in feed.entries:
if pattern.search(entry.title):
article = entry
break
if not article:
event.addresponse(u'Are you making up news again?')
return
if 'summary' in article:
summary = html2text_file(article.summary, None)
else:
if article.content[0].type in \
('application/xhtml+xml', 'text/html'):
summary = html2text_file(article.content[0].value, None)
else:
summary = article.content[0].value
event.addresponse(u'"%(title)s" %(link)s : %(summary)s', {
'title': html2text_file(article.title, None).strip(),
'link': article.link,
'summary': summary,
})
pattern = re.compile(pattern, re.I)
for entry in feed.entries:
if pattern.search(entry.title):
article = entry
break
if not article:
event.addresponse(u'Are you making up news again?')
return
if 'summary' in article:
summary = html2text_file(article.summary, None)
else:
if article.content[0].type in \
('application/xhtml+xml', 'text/html'):
summary = html2text_file(article.content[0].value, None)
else:
summary = article.content[0].value
event.addresponse(u'"%(title)s" %(link)s : %(summary)s', {
'title': html2text_file(article.title, None).strip(),
'link': article.link,
'summary': summary,
})
def html2fmt(html, target_format):
# html = html.replace("\n\n", '<br><br>')
# html = html.replace('<pre lang="xml">', '<pre lang="xml">', ']]></pre>')
if target_format == 'html':
return html
else:
return html2text_file(html, None)
</pre>
if not article:
event.addresponse(u'Are you making up news again?')
return
if 'summary' in article:
summary = html2text_file(article.summary, None)
else:
if article.content[0].type in \
('application/xhtml+xml', 'text/html'):
summary = html2text_file(article.content[0].value, None)
else:
summary = article.content[0].value
event.addresponse(u'"%(title)s" %(link)s : %(summary)s', {
'title': html2text_file(article.title, None).strip(),
'link': article.link,
'summary': summary,
})