Added guard against null variable names

This commit is contained in:
Fabio Manganiello 2022-01-06 00:58:14 +01:00
parent e9f6d9a8bc
commit a46ce79f0a
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -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
}