Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
url, title))
lines.extend([
'', # /footer
'', # /entry
'',
'',
''])
content['type'] = 'text/html'
content['value'] = '\n'.join(lines)
return content
else: # not self.html_mail
if content['type'] in ('text/html', 'application/xhtml+xml'):
try:
lines = [self._html2text(content['value'])]
except _html_parser.HTMLParseError as e:
raise _error.ProcessingError(parsed=None, feed=self)
else:
lines = [content['value']]
lines.append('')
lines.append('URL: {}'.format(link))
for enclosure in getattr(entry, 'enclosures', []):
if getattr(enclosure, 'url', None):
lines.append('Enclosure: {}'.format(enclosure.url))
if getattr(enclosure, 'src', None):
lines.append('Enclosure: {}'.format(enclosure.src))
for elink in getattr(entry, 'links', []):
if elink.get('rel', None) == 'via':
url = elink['href']
title = elink.get('title', url)
lines.append('Via: {} {}'.format(title, url))
content['type'] = 'text/plain'
content['value'] = '\n'.join(lines)
def log(self):
super(ProcessingError, self).log()
if type(self) == ProcessingError: # not a more specific subclass
_LOG.warning(
'=== rss2email encountered a problem with this feed ===')
_LOG.warning(
'=== See the rss2email FAQ at {} for assistance ==='.format(
__url__))
_LOG.warning(
'=== If this occurs repeatedly, send this to {} ==='.format(
__email__))
_LOG.warning(
'error: {} {}'.format(
self.parsed.get('bozo_exception', "can't process"),
self.feed.url))
_LOG.warning(_pprint.pformat(self.parsed))
_LOG.warning('rss2email {}'.format(__version__))
_LOG.warning('feedparser {}'.format(_feedparser.__version__))
_LOG.warning('html2text {}'.format(_html2text.__version__))
'incorrectly declared encoding: {}: {}'.format(exc, self))
warned = True
elif (parsed.bozo and isinstance(exc, _feedparser.NonXMLContentType)):
_LOG.warning('non XML Content-Type: {}: {}'.format(exc, self))
warned = True
elif parsed.bozo or exc:
if exc is None:
exc = "can't process"
_LOG.error('processing error: {}: {}'.format(exc, self))
warned = True
if (not warned and
status in [200, 302] and
not parsed.entries and
not version):
raise _error.ProcessingError(parsed=parsed, feed=self)
def __init__(self, parsed, feed, message=None, **kwargs):
if message is None:
message = 'error processing feed {}'.format(feed)
super(ProcessingError, self).__init__(feed=feed, message=message)
self.parsed = parsed