Browse Source

trying to get around the pytz timezone warning The zone attribute is specific to pytz's interface; please migrate to a new time zone provider. For more details on how to do so, see https://pytz-deprecation-shim.readthedocs.io/en/latest/migration.html

master
manetta 3 years ago
parent
commit
9accbf4456
  1. 8
      feedtools.py
  2. 1
      requirements.txt

8
feedtools.py

@ -1,7 +1,8 @@
import feedparser import feedparser
from simpledatabase import SimpleDatabase from simpledatabase import SimpleDatabase
import json import json
from datetime import date, timedelta from datetime import datetime, date, timedelta
from backports.zoneinfo import ZoneInfo
def update(): def update():
""" Update all feeds """ """ Update all feeds """
@ -14,6 +15,7 @@ def update():
for x, feed in enumerate(feeds): for x, feed in enumerate(feeds):
parsed = feedparser.parse(feed) parsed = feedparser.parse(feed)
# print(parsed)
x = str(x) x = str(x)
tmp['feeds'][x] = {} tmp['feeds'][x] = {}
@ -26,7 +28,7 @@ def update():
year = post['published_parsed'][0] year = post['published_parsed'][0]
month = post['published_parsed'][1] month = post['published_parsed'][1]
day = post['published_parsed'][2] day = post['published_parsed'][2]
post_date = date(year, month, day) post_date = datetime(year, month, day, tzinfo=ZoneInfo("Europe/Amsterdam"))
if not str(post_date) in tmp['all_posts_sorted']: if not str(post_date) in tmp['all_posts_sorted']:
tmp['all_posts_sorted'][str(post_date)] = [] tmp['all_posts_sorted'][str(post_date)] = []
@ -82,7 +84,7 @@ def today():
return request return request
def past(days): def past(days):
""" Collect posts from this week """ """ Collect posts from a number of past <days> """
db = load() db = load()
point_in_the_past = date.today() - timedelta(int(days)) point_in_the_past = date.today() - timedelta(int(days))
request = [] request = []

1
requirements.txt

@ -2,3 +2,4 @@ flask
feedparser feedparser
pathlib pathlib
Flask-APScheduler Flask-APScheduler
backports.zoneinfo
Loading…
Cancel
Save