From a46ce79f0ab4ee5744142eecc6f1c2e20dc17a20 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Thu, 6 Jan 2022 00:58:14 +0100 Subject: [PATCH] Added guard against null variable names --- platypush/plugins/rss/__init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/platypush/plugins/rss/__init__.py b/platypush/plugins/rss/__init__.py index 9e3ef5a31d..dad6b147bf 100644 --- a/platypush/plugins/rss/__init__.py +++ b/platypush/plugins/rss/__init__.py @@ -53,14 +53,18 @@ class RssPlugin(RunnablePlugin): def _get_feed_latest_timestamp_varname(url: str) -> str: return f'LATEST_FEED_TIMESTAMP[{url}]' + @classmethod + def _get_feed_latest_timestamp(cls, url: str) -> Optional[datetime.datetime]: + t = get_plugin('variable').get( + cls._get_feed_latest_timestamp_varname(url) + ).output.get(cls._get_feed_latest_timestamp_varname(url)) + + if t: + return dateutil.parser.isoparse(t) + def _get_latest_timestamps(self) -> dict: - variable = get_plugin('variable') return { - url: dateutil.parser.isoparse( - variable.get( - self._get_feed_latest_timestamp_varname(url) - ).output.get(self._get_feed_latest_timestamp_varname(url)) - ) + url: self._get_feed_latest_timestamp(url) for url in self.subscriptions }