mirror of
https://github.com/oddluck/limnoria-plugins.git
synced 2025-04-29 06:51:12 -05:00
Corona: remove pendulum requirement
This commit is contained in:
parent
2ca46df854
commit
7e5a4dd0d0
@ -29,7 +29,7 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import pendulum
|
import datetime
|
||||||
import re
|
import re
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from supybot import utils, plugins, ircutils, callbacks, log
|
from supybot import utils, plugins, ircutils, callbacks, log
|
||||||
@ -364,13 +364,14 @@ class Corona(callbacks.Plugin):
|
|||||||
self.__parent = super(Corona, self)
|
self.__parent = super(Corona, self)
|
||||||
self.__parent.__init__(irc)
|
self.__parent.__init__(irc)
|
||||||
self.data = requests.structures.CaseInsensitiveDict()
|
self.data = requests.structures.CaseInsensitiveDict()
|
||||||
self.updated = pendulum.yesterday()
|
today = datetime.datetime.utcnow()
|
||||||
|
self.updated = today - datetime.timedelta(days=1)
|
||||||
|
|
||||||
def time_created(self, time):
|
def time_created(self, time):
|
||||||
"""
|
"""
|
||||||
Return relative time delta between now and s (dt string).
|
Return relative time delta between now and s (dt string).
|
||||||
"""
|
"""
|
||||||
d = pendulum.now() - time
|
d = datetime.datetime.utcnow() - time
|
||||||
if d.days:
|
if d.days:
|
||||||
rel_time = "{:1d}d ago".format(abs(d.days))
|
rel_time = "{:1d}d ago".format(abs(d.days))
|
||||||
elif d.seconds > 3600:
|
elif d.seconds > 3600:
|
||||||
@ -400,7 +401,7 @@ class Corona(callbacks.Plugin):
|
|||||||
soup = BeautifulSoup(r.content)
|
soup = BeautifulSoup(r.content)
|
||||||
updated = soup.find("div", text = re.compile('Last updated:'))
|
updated = soup.find("div", text = re.compile('Last updated:'))
|
||||||
updated = updated.text.split(':', 1)[1].replace('GMT', '').strip()
|
updated = updated.text.split(':', 1)[1].replace('GMT', '').strip()
|
||||||
updated = pendulum.from_format(updated, "MMMM DD, YYYY, HH:mm")
|
updated = datetime.datetime.strptime(updated, "%B %d, %Y, %H:%M")
|
||||||
if OK and updated > self.updated:
|
if OK and updated > self.updated:
|
||||||
self.updated = updated
|
self.updated = updated
|
||||||
table = soup.find("table", { "id" : "main_table_countries_today" })
|
table = soup.find("table", { "id" : "main_table_countries_today" })
|
||||||
|
@ -1,3 +1,2 @@
|
|||||||
requests
|
requests
|
||||||
pendulum
|
|
||||||
beautifulsoup4
|
beautifulsoup4
|
||||||
|
Loading…
x
Reference in New Issue
Block a user