core: improvements for warnings, twitter/rss: try using @warn_if_empty
This commit is contained in:
parent
616ffb457e
commit
216944b3cd
5 changed files with 35 additions and 17 deletions
|
@ -1,11 +1,16 @@
|
|||
'''
|
||||
Unified RSS data, merged from different services I used historically
|
||||
'''
|
||||
# NOTE: you can comment out the sources you're not using
|
||||
from . import feedbin, feedly
|
||||
|
||||
from typing import Iterable
|
||||
from .common import Subscription, compute_subscriptions
|
||||
|
||||
|
||||
def subscriptions() -> Iterable[Subscription]:
|
||||
from . import feedbin, feedly
|
||||
# TODO google reader?
|
||||
yield from compute_subscriptions(feedbin.states(), feedly.states())
|
||||
yield from compute_subscriptions(
|
||||
feedbin.states(),
|
||||
feedly .states(),
|
||||
)
|
||||
|
|
|
@ -17,6 +17,8 @@ from typing import Iterable, Tuple, Sequence
|
|||
SubscriptionState = Tuple[datetime, Sequence[Subscription]]
|
||||
|
||||
|
||||
from ..core import warn_if_empty
|
||||
@warn_if_empty
|
||||
def compute_subscriptions(*sources: Iterable[SubscriptionState]) -> List[Subscription]:
|
||||
"""
|
||||
Keeps track of everything I ever subscribed to.
|
||||
|
@ -34,6 +36,9 @@ def compute_subscriptions(*sources: Iterable[SubscriptionState]) -> List[Subscri
|
|||
if feed.url not in by_url:
|
||||
by_url[feed.url] = feed
|
||||
|
||||
if len(states) == 0:
|
||||
return []
|
||||
|
||||
_, last_state = max(states, key=lambda x: x[0])
|
||||
last_urls = {f.url for f in last_state}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue