misc: replace uses of pytz.utc with timezone.utc where it makes sense

This commit is contained in:
Dima Gerasimov 2023-06-09 03:04:54 +01:00 committed by karlicoss
parent c91534b966
commit c12224af74
9 changed files with 24 additions and 42 deletions

View file

@ -1,23 +1,21 @@
"""
Feedly RSS reader
"""
from my.config import feedly as config
from datetime import datetime, timezone
import json
from pathlib import Path
from typing import Sequence
from typing import Iterable, Sequence
from ..core.common import listify, get_files
from .common import Subscription
from .common import Subscription, SubscriptionState
def inputs() -> Sequence[Path]:
return get_files(config.export_path)
import json
@listify
def parse_file(f: Path):
raw = json.loads(f.read_text())
@ -33,14 +31,9 @@ def parse_file(f: Path):
)
from datetime import datetime
from typing import Iterable
from .common import SubscriptionState
def states() -> Iterable[SubscriptionState]:
import pytz
for f in inputs():
dts = f.stem.split('_')[-1]
dt = datetime.strptime(dts, '%Y%m%d%H%M%S')
dt = pytz.utc.localize(dt)
dt = datetime.strptime(dts, '%Y%m%d%H%M%S').replace(tzinfo=timezone.utc)
subs = parse_file(f)
yield dt, subs