handle new issues
This commit is contained in:
parent
db76eafb44
commit
2d1a0b7732
1 changed files with 30 additions and 8 deletions
|
@ -84,12 +84,22 @@ def _parse_dt(s: str) -> datetime:
|
||||||
# TODO isoformat?
|
# TODO isoformat?
|
||||||
return pytz.utc.localize(datetime.strptime(s, '%Y-%m-%dT%H:%M:%SZ'))
|
return pytz.utc.localize(datetime.strptime(s, '%Y-%m-%dT%H:%M:%SZ'))
|
||||||
|
|
||||||
def _parse_repository(d: Dict) -> Event:
|
|
||||||
|
# TODO typing.TypedDict could be handy here..
|
||||||
|
def _parse_common(d: Dict) -> Dict:
|
||||||
url = d['url']
|
url = d['url']
|
||||||
|
body = d.get('body')
|
||||||
|
return {
|
||||||
|
'dt' : _parse_dt(d['created_at']),
|
||||||
|
'link': url,
|
||||||
|
'body': body,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _parse_repository(d: Dict) -> Event:
|
||||||
name = d['name']
|
name = d['name']
|
||||||
return Event(
|
return Event(
|
||||||
dt=_parse_dt(d['created_at']),
|
**_parse_common(d),
|
||||||
link=url,
|
|
||||||
summary='created ' + name,
|
summary='created ' + name,
|
||||||
eid='created_' + name, # TODO ??
|
eid='created_' + name, # TODO ??
|
||||||
)
|
)
|
||||||
|
@ -97,11 +107,20 @@ def _parse_repository(d: Dict) -> Event:
|
||||||
def _parse_issue_comment(d: Dict) -> Event:
|
def _parse_issue_comment(d: Dict) -> Event:
|
||||||
url = d['url']
|
url = d['url']
|
||||||
return Event(
|
return Event(
|
||||||
dt=_parse_dt(d['created_at']),
|
**_parse_common(d),
|
||||||
link=url,
|
|
||||||
summary=f'commented on issue {url}',
|
summary=f'commented on issue {url}',
|
||||||
eid='issue_comment_' + url,
|
eid='issue_comment_' + url,
|
||||||
body=d['body'], # TODO FIXME it's markdown, could use it somehow..
|
)
|
||||||
|
|
||||||
|
|
||||||
|
# Event(dt=datetime.datetime(2019, 10, 15, 22, 50, 57, tzinfo=<UTC>), summary='opened issue Make seting up easier', eid='10638242494', link='https://github.com/karlicoss/my/issues/1', body=None),
|
||||||
|
def _parse_issue(d: Dict) -> Event:
|
||||||
|
url = d['url']
|
||||||
|
title = d['title']
|
||||||
|
return Event(
|
||||||
|
**_parse_common(d),
|
||||||
|
summary=f'opened issue {title}',
|
||||||
|
eid='issue_comment_' + url,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,9 +142,12 @@ def iter_gdpr_events() -> Iterator[Res[Event]]:
|
||||||
"""
|
"""
|
||||||
files = list(sorted(paths.github.gdpr_dir.glob('*.json')))
|
files = list(sorted(paths.github.gdpr_dir.glob('*.json')))
|
||||||
handler_map = {
|
handler_map = {
|
||||||
'schema': None,
|
'schema' : None,
|
||||||
'repositories_': _parse_repository,
|
'issue_events_': None, # eh, doesn't seem to have any useful bodies
|
||||||
|
'attachments_' : None, # not sure if useful
|
||||||
|
'repositories_' : _parse_repository,
|
||||||
'issue_comments_': _parse_issue_comment,
|
'issue_comments_': _parse_issue_comment,
|
||||||
|
'issues_' : _parse_issue,
|
||||||
}
|
}
|
||||||
for f in files:
|
for f in files:
|
||||||
handler: Any
|
handler: Any
|
||||||
|
|
Loading…
Add table
Reference in a new issue