Handle twidump config properly, nicer wrapping
This commit is contained in:
parent
473b8d476c
commit
fc41c78d20
1 changed files with 17 additions and 16 deletions
|
@ -3,19 +3,6 @@ from typing import Union, List
|
|||
|
||||
KARLICOSS_ID = '119756204'
|
||||
|
||||
# TODO how to discover configs? ... I guess symlinking...
|
||||
def tweets_all():
|
||||
import sys
|
||||
sys.path.append("/L/coding/twidump")
|
||||
import twidump
|
||||
# add current package to path to discover config?... nah, twidump should be capable of that.
|
||||
from twidump.data_manipulation.timelines import TimelineLoader
|
||||
from twidump.component import get_app_injector
|
||||
tl_loader = get_app_injector().get(TimelineLoader) # type: TimelineLoader
|
||||
tl = tl_loader.load_timeline(KARLICOSS_ID)
|
||||
return tl
|
||||
|
||||
|
||||
class Tweet:
|
||||
def __init__(self, tw):
|
||||
self.tw = tw
|
||||
|
@ -33,20 +20,34 @@ class Tweet:
|
|||
return self.tw.created_at
|
||||
|
||||
@property
|
||||
def datetime(self) -> datetime:
|
||||
def dt(self) -> datetime:
|
||||
return self.tw.get_utc_datetime()
|
||||
|
||||
@property
|
||||
def text(self) -> str:
|
||||
return self.tw.text
|
||||
|
||||
def __str__(self) -> str:
|
||||
return str(self.tw)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return repr(self.tw)
|
||||
|
||||
def tweets_all():
|
||||
import twidump
|
||||
# add current package to path to discover config?... nah, twidump should be capable of that.
|
||||
from twidump.data_manipulation.timelines import TimelineLoader
|
||||
from twidump.component import get_app_injector
|
||||
tl_loader = get_app_injector().get(TimelineLoader) # type: TimelineLoader
|
||||
tl = tl_loader.load_timeline(KARLICOSS_ID)
|
||||
return [Tweet(x) for x in tl]
|
||||
|
||||
|
||||
def predicate(p) -> List[Tweet]:
|
||||
return [Tweet(t) for t in tweets_all() if p(t)]
|
||||
return [t for t in tweets_all() if p(t)]
|
||||
|
||||
def predicate_date(p) -> List[Tweet]:
|
||||
return predicate(lambda t: p(t.get_utc_datetime().date()))
|
||||
return predicate(lambda t: p(t.dt.date()))
|
||||
|
||||
Datish = Union[date, str]
|
||||
def tweets_on(*dts: Datish) -> List[Tweet]:
|
||||
|
|
Loading…
Add table
Reference in a new issue