add body for github events

This commit is contained in:
Dima Gerasimov 2019-09-28 18:53:05 +01:00
parent e5b90407dc
commit ffe6c14c74

View file

@ -25,6 +25,7 @@ class Event(NamedTuple):
summary: str summary: str
eid: str eid: str
link: Optional[str] link: Optional[str]
body: Optional[str]=None
# TODO split further, title too # TODO split further, title too
@ -80,19 +81,22 @@ def get_model():
return model return model
def get_events(): def iter_events():
# from kython import setup_logzero
# import logging
# setup_logzero(ghexport().get_logger(), level=logging.INFO)
model = get_model() model = get_model()
ev = [Event( for d in model.events():
summary, link = _get_summary(d)
body = d.get('payload', {}).get('comment', {}).get('body')
yield Event(
# TODO isoformat?
dt=pytz.utc.localize(datetime.strptime(d['created_at'], '%Y-%m-%dT%H:%M:%SZ')), dt=pytz.utc.localize(datetime.strptime(d['created_at'], '%Y-%m-%dT%H:%M:%SZ')),
summary=_get_summary(d)[0], summary=summary,
link=_get_summary(d)[1], link=link,
eid=d['id'], eid=d['id'],
) for d in model.events()] body=body,
return sorted(ev, key=lambda e: e.dt) )
def get_events():
return sorted(iter_events(), key=lambda e: e.dt)
# TODO mm. ok, not much point in deserializing as github.Event as it's basically a fancy dict wrapper? # TODO mm. ok, not much point in deserializing as github.Event as it's basically a fancy dict wrapper?
# from github.Event import Event as GEvent # type: ignore # from github.Event import Event as GEvent # type: ignore