twitter module: prettify top level twitter.all

This commit is contained in:
Dima Gerasimov 2020-05-22 19:00:02 +01:00
parent c410daa484
commit 03773a7b2c
7 changed files with 75 additions and 55 deletions

View file

@ -1,24 +1,23 @@
"""
Unified Twitter data (merged from the archive and periodic updates)
"""
from itertools import chain
from . import twint
from . import archive
# NOTE: you can comment out the sources you don't need
# TODO move to .common?
def merge_tweets(*sources):
from more_itertools import unique_everseen
yield from unique_everseen(
chain(*sources),
key=lambda t: t.id_str,
)
from . import twint, archive
from .common import merge_tweets
def tweets():
yield from merge_tweets(twint.tweets(), archive.tweets())
yield from merge_tweets(
twint .tweets(),
archive.tweets(),
)
def likes():
yield from merge_tweets(twint.likes(), archive.likes())
yield from merge_tweets(
twint .likes(),
archive.likes(),
)