rss module: prettify & reorganize to allow for easily adding extra modules
This commit is contained in:
parent
92cf375480
commit
63d4198fd9
6 changed files with 66 additions and 58 deletions
|
@ -8,7 +8,7 @@ from pathlib import Path
|
|||
from typing import Sequence
|
||||
|
||||
from ..core.common import listify, get_files, isoparse
|
||||
from ._rss import Subscription
|
||||
from .common import Subscription
|
||||
|
||||
|
||||
def inputs() -> Sequence[Path]:
|
||||
|
@ -16,9 +16,6 @@ def inputs() -> Sequence[Path]:
|
|||
|
||||
|
||||
import json
|
||||
from typing import Dict, List
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
@listify
|
||||
def parse_file(f: Path):
|
||||
|
@ -32,14 +29,14 @@ def parse_file(f: Path):
|
|||
)
|
||||
|
||||
|
||||
def get_states() -> Dict[datetime, List[Subscription]]:
|
||||
from typing import Iterable
|
||||
from .common import SubscriptionState
|
||||
def states() -> Iterable[SubscriptionState]:
|
||||
# meh
|
||||
from dateutil.parser import isoparse # type: ignore
|
||||
res = {}
|
||||
for f in inputs():
|
||||
# TODO ugh. depends on my naming. not sure if useful?
|
||||
dts = f.stem.split('_')[-1]
|
||||
dt = isoparse(dts)
|
||||
subs = parse_file(f)
|
||||
res[dt] = subs
|
||||
return res
|
||||
yield dt, subs
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue