add body for github events
This commit is contained in:
parent
e5b90407dc
commit
ffe6c14c74
1 changed files with 15 additions and 11 deletions
|
@ -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():
|
||||||
dt=pytz.utc.localize(datetime.strptime(d['created_at'], '%Y-%m-%dT%H:%M:%SZ')),
|
summary, link = _get_summary(d)
|
||||||
summary=_get_summary(d)[0],
|
body = d.get('payload', {}).get('comment', {}).get('body')
|
||||||
link=_get_summary(d)[1],
|
yield Event(
|
||||||
eid=d['id'],
|
# TODO isoformat?
|
||||||
) for d in model.events()]
|
dt=pytz.utc.localize(datetime.strptime(d['created_at'], '%Y-%m-%dT%H:%M:%SZ')),
|
||||||
return sorted(ev, key=lambda e: e.dt)
|
summary=summary,
|
||||||
|
link=link,
|
||||||
|
eid=d['id'],
|
||||||
|
body=body,
|
||||||
|
)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
Loading…
Add table
Reference in a new issue