comply with new feedparser deprecation warning

Somewhere after 5.1.3, feedparser started warning about updated_parsed
usage, without any possibility of compliance:

https://github.com/kurtmckee/feedparser/issues/151

We properly added defaults but feedparser kept on warning, so warnings
were disabled for those sections.
parent 360e800b
......@@ -10,6 +10,7 @@ from email.mime.multipart import MIMEMultipart
import logging
import socket
import time
import warnings
import feed2exec
import feed2exec.utils as utils
......@@ -97,7 +98,9 @@ def make_message(feed, item, to_addr=None, cls=email.message.Message):
#
# also, default on the feed updated date
orig = timestamp = datetime.datetime.utcnow().timestamp()
timestamp = item.get('updated_parsed') or orig
with warnings.catch_warnings():
warnings.simplefilter("ignore")
timestamp = item.get('updated_parsed', item.get('published_parsed', orig))
if isinstance(timestamp, (datetime.datetime,
datetime.date,
datetime.time)):
......
......@@ -41,6 +41,7 @@ try:
except ImportError: # pragma: nocover
# py2
import urlparse
import warnings
import feed2exec
......@@ -316,8 +317,10 @@ class Feed(feedparser.FeedParserDict):
unreported for now.
"""
# 1. add more defaults (issue #113)
item['updated_parsed'] = item.get('updated_parsed', item.get('created_parsed', self.get('updated_parsed', False))) # noqa
assert item.get('updated_parsed') is not None
with warnings.catch_warnings():
warnings.simplefilter("ignore")
item['updated_parsed'] = item.get('updated_parsed', item.get('published_parsed', item.get('created_parsed', self.get('updated_parsed', self.get('published_parsed', False))))) # noqa
assert item.get('updated_parsed') is not None
# 2. add UID if missing (issue #112)
if not item.get('id'):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment