2016-08-18 20:57:50 +02:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from functools import partial
|
|
|
|
from zerver.lib.actions import check_send_message
|
|
|
|
from zerver.lib.response import json_success
|
|
|
|
from zerver.decorator import api_key_only_webhook_view, REQ, has_request_variables
|
2016-10-06 17:13:40 +02:00
|
|
|
from zerver.lib.webhooks.git import get_push_commits_event_message, EMPTY_SHA,\
|
2016-10-11 18:54:48 +02:00
|
|
|
get_remove_branch_event_message, get_pull_request_event_message,\
|
2016-10-27 21:43:15 +02:00
|
|
|
get_issue_event_message, SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE,\
|
2016-11-08 22:13:23 +01:00
|
|
|
get_commits_comment_action_message, get_push_tag_event_message
|
2016-08-18 20:57:50 +02:00
|
|
|
from zerver.models import Client, UserProfile
|
|
|
|
|
|
|
|
from django.http import HttpRequest, HttpResponse
|
2016-12-04 18:45:46 +01:00
|
|
|
from typing import Dict, Any, Iterable, Optional, Text
|
2016-08-18 20:57:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
class UnknownEventType(Exception):
|
|
|
|
pass
|
|
|
|
|
2016-10-06 17:13:40 +02:00
|
|
|
|
2016-08-18 20:57:50 +02:00
|
|
|
def get_push_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-10-06 17:13:40 +02:00
|
|
|
if payload.get('after') == EMPTY_SHA:
|
|
|
|
return get_remove_branch_event_body(payload)
|
|
|
|
return get_normal_push_event_body(payload)
|
|
|
|
|
|
|
|
def get_normal_push_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-08-18 20:57:50 +02:00
|
|
|
compare_url = u'{}/compare/{}...{}'.format(
|
|
|
|
get_repository_homepage(payload),
|
|
|
|
payload['before'],
|
|
|
|
payload['after']
|
|
|
|
)
|
2016-10-04 21:14:56 +02:00
|
|
|
|
|
|
|
commits = [
|
|
|
|
{
|
|
|
|
'sha': commit.get('id'),
|
|
|
|
'message': commit.get('message'),
|
|
|
|
'url': commit.get('url')
|
|
|
|
}
|
|
|
|
for commit in payload.get('commits')
|
|
|
|
]
|
|
|
|
|
|
|
|
return get_push_commits_event_message(
|
2016-08-18 20:57:50 +02:00
|
|
|
get_user_name(payload),
|
|
|
|
compare_url,
|
2016-10-04 21:14:56 +02:00
|
|
|
get_branch_name(payload),
|
|
|
|
commits
|
2016-08-18 20:57:50 +02:00
|
|
|
)
|
|
|
|
|
2016-10-06 17:13:40 +02:00
|
|
|
def get_remove_branch_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-10-06 17:13:40 +02:00
|
|
|
return get_remove_branch_event_message(
|
|
|
|
get_user_name(payload),
|
|
|
|
get_branch_name(payload)
|
|
|
|
)
|
|
|
|
|
2016-08-18 20:57:50 +02:00
|
|
|
def get_tag_push_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-11-08 22:13:23 +01:00
|
|
|
return get_push_tag_event_message(
|
2016-08-18 20:57:50 +02:00
|
|
|
get_user_name(payload),
|
2016-11-08 22:13:23 +01:00
|
|
|
get_tag_name(payload),
|
|
|
|
action="pushed" if payload.get('checkout_sha') else "removed"
|
2016-08-18 20:57:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def get_issue_created_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-10-19 23:49:23 +02:00
|
|
|
return get_issue_event_message(
|
|
|
|
get_issue_user_name(payload),
|
|
|
|
'created',
|
|
|
|
get_object_url(payload),
|
2016-10-26 21:13:00 +02:00
|
|
|
payload.get('object_attributes').get('iid'),
|
2016-10-19 23:49:23 +02:00
|
|
|
payload.get('object_attributes').get('description'),
|
|
|
|
get_objects_assignee(payload)
|
|
|
|
)
|
2016-08-18 20:57:50 +02:00
|
|
|
|
|
|
|
def get_issue_event_body(payload, action):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any], Text) -> Text
|
2016-10-19 23:49:23 +02:00
|
|
|
return get_issue_event_message(
|
2016-08-18 20:57:50 +02:00
|
|
|
get_issue_user_name(payload),
|
|
|
|
action,
|
2016-10-19 23:49:23 +02:00
|
|
|
get_object_url(payload),
|
2016-10-26 21:13:00 +02:00
|
|
|
payload.get('object_attributes').get('iid'),
|
2016-08-18 20:57:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def get_merge_request_updated_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-08-18 20:57:50 +02:00
|
|
|
if payload.get('object_attributes').get('oldrev'):
|
2016-10-11 18:54:48 +02:00
|
|
|
return get_merge_request_event_body(payload, "added commit(s) to")
|
|
|
|
return get_merge_request_open_or_updated_body(payload, "updated")
|
2016-08-18 20:57:50 +02:00
|
|
|
|
|
|
|
def get_merge_request_event_body(payload, action):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any], Text) -> Text
|
2016-10-11 18:54:48 +02:00
|
|
|
pull_request = payload.get('object_attributes')
|
|
|
|
return get_pull_request_event_message(
|
2016-08-18 20:57:50 +02:00
|
|
|
get_issue_user_name(payload),
|
|
|
|
action,
|
2016-10-11 18:54:48 +02:00
|
|
|
pull_request.get('url'),
|
2016-10-26 21:13:00 +02:00
|
|
|
pull_request.get('iid'),
|
2016-10-11 18:54:48 +02:00
|
|
|
type='MR',
|
|
|
|
)
|
|
|
|
|
|
|
|
def get_merge_request_open_or_updated_body(payload, action):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any], Text) -> Text
|
2016-10-11 18:54:48 +02:00
|
|
|
pull_request = payload.get('object_attributes')
|
|
|
|
return get_pull_request_event_message(
|
|
|
|
get_issue_user_name(payload),
|
|
|
|
action,
|
|
|
|
pull_request.get('url'),
|
2016-10-26 21:13:00 +02:00
|
|
|
pull_request.get('iid'),
|
2016-10-11 18:54:48 +02:00
|
|
|
pull_request.get('source_branch'),
|
|
|
|
pull_request.get('target_branch'),
|
|
|
|
pull_request.get('description'),
|
2016-10-19 23:49:23 +02:00
|
|
|
get_objects_assignee(payload),
|
2016-10-11 18:54:48 +02:00
|
|
|
type='MR',
|
2016-08-18 20:57:50 +02:00
|
|
|
)
|
|
|
|
|
2016-10-19 23:49:23 +02:00
|
|
|
def get_objects_assignee(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-10-19 23:49:23 +02:00
|
|
|
assignee_object = payload.get('assignee')
|
|
|
|
if assignee_object:
|
|
|
|
return assignee_object.get('name')
|
|
|
|
|
2016-08-18 20:57:50 +02:00
|
|
|
def get_commented_commit_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-10-21 17:53:33 +02:00
|
|
|
comment = payload.get('object_attributes')
|
2016-10-27 21:43:15 +02:00
|
|
|
action = u'[commented]({})'.format(comment['url'])
|
|
|
|
return get_commits_comment_action_message(
|
2016-08-18 20:57:50 +02:00
|
|
|
get_issue_user_name(payload),
|
2016-10-21 17:53:33 +02:00
|
|
|
action,
|
|
|
|
payload.get('commit').get('url'),
|
2016-10-27 21:43:15 +02:00
|
|
|
payload.get('commit').get('id'),
|
|
|
|
comment['note'],
|
2016-08-18 20:57:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def get_commented_merge_request_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-10-21 16:01:15 +02:00
|
|
|
comment = payload.get('object_attributes')
|
2016-10-26 20:47:12 +02:00
|
|
|
action = u'[commented]({}) on'.format(comment['url'])
|
2016-10-21 16:01:15 +02:00
|
|
|
url = u'{}/merge_requests/{}'.format(
|
2016-08-18 20:57:50 +02:00
|
|
|
payload.get('project').get('web_url'),
|
2016-10-21 16:01:15 +02:00
|
|
|
payload.get('merge_request').get('iid')
|
|
|
|
)
|
|
|
|
return get_pull_request_event_message(
|
|
|
|
get_issue_user_name(payload),
|
|
|
|
action,
|
|
|
|
url,
|
2016-10-26 21:13:00 +02:00
|
|
|
payload.get('merge_request').get('iid'),
|
2016-10-21 16:01:15 +02:00
|
|
|
message=comment['note'],
|
|
|
|
type='MR'
|
2016-08-18 20:57:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def get_commented_issue_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-10-21 16:01:15 +02:00
|
|
|
comment = payload.get('object_attributes')
|
2016-10-26 20:47:12 +02:00
|
|
|
action = u'[commented]({}) on'.format(comment['url'])
|
2016-10-21 16:01:15 +02:00
|
|
|
url = u'{}/issues/{}'.format(
|
2016-08-18 20:57:50 +02:00
|
|
|
payload.get('project').get('web_url'),
|
2016-10-21 16:01:15 +02:00
|
|
|
payload.get('issue').get('iid')
|
|
|
|
)
|
|
|
|
return get_pull_request_event_message(
|
|
|
|
get_issue_user_name(payload),
|
|
|
|
action,
|
|
|
|
url,
|
2016-10-26 21:13:00 +02:00
|
|
|
payload.get('issue').get('iid'),
|
2016-10-21 16:01:15 +02:00
|
|
|
message=comment['note'],
|
|
|
|
type='Issue'
|
2016-08-18 20:57:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def get_commented_snippet_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-10-21 17:53:33 +02:00
|
|
|
comment = payload.get('object_attributes')
|
2016-10-26 20:47:12 +02:00
|
|
|
action = u'[commented]({}) on'.format(comment['url'])
|
2016-10-21 17:53:33 +02:00
|
|
|
url = u'{}/snippets/{}'.format(
|
2016-08-18 20:57:50 +02:00
|
|
|
payload.get('project').get('web_url'),
|
2016-10-21 17:53:33 +02:00
|
|
|
payload.get('snippet').get('id')
|
|
|
|
)
|
|
|
|
return get_pull_request_event_message(
|
|
|
|
get_issue_user_name(payload),
|
|
|
|
action,
|
|
|
|
url,
|
2016-10-26 21:13:00 +02:00
|
|
|
payload.get('snippet').get('id'),
|
2016-10-21 17:53:33 +02:00
|
|
|
message=comment['note'],
|
|
|
|
type='Snippet'
|
2016-08-18 20:57:50 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
def get_wiki_page_event_body(payload, action):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any], Text) -> Text
|
2016-08-18 20:57:50 +02:00
|
|
|
return u"{} {} [Wiki Page \"{}\"]({}).".format(
|
|
|
|
get_issue_user_name(payload),
|
|
|
|
action,
|
|
|
|
payload.get('object_attributes').get('title'),
|
|
|
|
payload.get('object_attributes').get('url'),
|
|
|
|
)
|
|
|
|
|
2016-09-28 22:02:41 +02:00
|
|
|
def get_build_hook_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-09-28 22:02:41 +02:00
|
|
|
build_status = payload.get('build_status')
|
|
|
|
if build_status == 'created':
|
|
|
|
action = 'was created'
|
|
|
|
elif build_status == 'running':
|
|
|
|
action = 'started'
|
|
|
|
else:
|
|
|
|
action = 'changed status to {}'.format(build_status)
|
|
|
|
return u"Build {} from {} stage {}.".format(
|
|
|
|
payload.get('build_name'),
|
|
|
|
payload.get('build_stage'),
|
|
|
|
action
|
|
|
|
)
|
|
|
|
|
2016-09-28 23:06:04 +02:00
|
|
|
def get_pipeline_event_body(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-09-28 23:06:04 +02:00
|
|
|
pipeline_status = payload.get('object_attributes').get('status')
|
|
|
|
if pipeline_status == 'pending':
|
|
|
|
action = 'was created'
|
|
|
|
elif pipeline_status == 'running':
|
|
|
|
action = 'started'
|
|
|
|
else:
|
|
|
|
action = 'changed status to {}'.format(pipeline_status)
|
|
|
|
|
|
|
|
builds_status = u""
|
|
|
|
for build in payload.get('builds'):
|
|
|
|
builds_status += u"* {} - {}\n".format(build.get('name'), build.get('status'))
|
|
|
|
return u"Pipeline {} with build(s):\n{}.".format(action, builds_status[:-1])
|
|
|
|
|
2016-08-18 20:57:50 +02:00
|
|
|
def get_repo_name(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-08-18 20:57:50 +02:00
|
|
|
return payload['project']['name']
|
|
|
|
|
|
|
|
def get_user_name(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-08-18 20:57:50 +02:00
|
|
|
return payload['user_name']
|
|
|
|
|
|
|
|
def get_issue_user_name(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-08-18 20:57:50 +02:00
|
|
|
return payload['user']['name']
|
|
|
|
|
|
|
|
def get_repository_homepage(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-08-18 20:57:50 +02:00
|
|
|
return payload['repository']['homepage']
|
|
|
|
|
|
|
|
def get_branch_name(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-09-22 18:48:56 +02:00
|
|
|
return payload['ref'].replace('refs/heads/', '')
|
2016-08-18 20:57:50 +02:00
|
|
|
|
|
|
|
def get_tag_name(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-09-22 18:48:56 +02:00
|
|
|
return payload['ref'].replace('refs/tags/', '')
|
2016-08-18 20:57:50 +02:00
|
|
|
|
|
|
|
def get_object_iid(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-08-18 20:57:50 +02:00
|
|
|
return payload['object_attributes']['iid']
|
|
|
|
|
|
|
|
def get_object_url(payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (Dict[str, Any]) -> Text
|
2016-08-18 20:57:50 +02:00
|
|
|
return payload['object_attributes']['url']
|
|
|
|
|
|
|
|
EVENT_FUNCTION_MAPPER = {
|
|
|
|
'Push Hook': get_push_event_body,
|
|
|
|
'Tag Push Hook': get_tag_push_event_body,
|
|
|
|
'Issue Hook open': get_issue_created_event_body,
|
|
|
|
'Issue Hook close': partial(get_issue_event_body, action='closed'),
|
|
|
|
'Issue Hook reopen': partial(get_issue_event_body, action='reopened'),
|
|
|
|
'Issue Hook update': partial(get_issue_event_body, action='updated'),
|
|
|
|
'Note Hook Commit': get_commented_commit_event_body,
|
|
|
|
'Note Hook MergeRequest': get_commented_merge_request_event_body,
|
|
|
|
'Note Hook Issue': get_commented_issue_event_body,
|
|
|
|
'Note Hook Snippet': get_commented_snippet_event_body,
|
2016-10-11 18:54:48 +02:00
|
|
|
'Merge Request Hook open': partial(get_merge_request_open_or_updated_body, action='created'),
|
2016-08-18 20:57:50 +02:00
|
|
|
'Merge Request Hook update': get_merge_request_updated_event_body,
|
|
|
|
'Merge Request Hook merge': partial(get_merge_request_event_body, action='merged'),
|
|
|
|
'Merge Request Hook close': partial(get_merge_request_event_body, action='closed'),
|
|
|
|
'Wiki Page Hook create': partial(get_wiki_page_event_body, action='created'),
|
|
|
|
'Wiki Page Hook update': partial(get_wiki_page_event_body, action='updated'),
|
2016-09-28 22:02:41 +02:00
|
|
|
'Build Hook': get_build_hook_event_body,
|
2016-09-28 23:06:04 +02:00
|
|
|
'Pipeline Hook': get_pipeline_event_body,
|
2016-08-18 20:57:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@api_key_only_webhook_view("Gitlab")
|
|
|
|
@has_request_variables
|
|
|
|
def api_gitlab_webhook(request, user_profile, client,
|
|
|
|
stream=REQ(default='gitlab'),
|
|
|
|
payload=REQ(argument_type='body')):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (HttpRequest, UserProfile, Client, Text, Dict[str, Any]) -> HttpResponse
|
2016-08-18 20:57:50 +02:00
|
|
|
event = get_event(request, payload)
|
|
|
|
body = get_body_based_on_event(event)(payload)
|
2016-09-22 20:15:06 +02:00
|
|
|
subject = get_subject_based_on_event(event, payload)
|
2016-08-18 20:57:50 +02:00
|
|
|
check_send_message(user_profile, client, 'stream', [stream], subject, body)
|
|
|
|
return json_success()
|
|
|
|
|
|
|
|
def get_body_based_on_event(event):
|
|
|
|
# type: (str) -> Any
|
|
|
|
return EVENT_FUNCTION_MAPPER[event]
|
|
|
|
|
2016-09-22 20:15:06 +02:00
|
|
|
def get_subject_based_on_event(event, payload):
|
2016-12-04 18:45:46 +01:00
|
|
|
# type: (str, Dict[str, Any]) -> Text
|
2016-09-22 20:15:06 +02:00
|
|
|
if event == 'Push Hook':
|
2016-09-26 08:29:36 +02:00
|
|
|
return u"{} / {}".format(get_repo_name(payload), get_branch_name(payload))
|
2016-09-28 22:02:41 +02:00
|
|
|
elif event == 'Build Hook':
|
|
|
|
return u"{} / {}".format(payload.get('repository').get('name'), get_branch_name(payload))
|
2016-09-28 23:06:04 +02:00
|
|
|
elif event == 'Pipeline Hook':
|
|
|
|
return u"{} / {}".format(
|
|
|
|
get_repo_name(payload),
|
|
|
|
payload.get('object_attributes').get('ref').replace('refs/heads/', ''))
|
2016-10-11 18:54:48 +02:00
|
|
|
elif event.startswith('Merge Request Hook'):
|
2016-10-19 16:00:40 +02:00
|
|
|
return SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
|
2016-10-11 18:54:48 +02:00
|
|
|
repo=get_repo_name(payload),
|
|
|
|
type='MR',
|
|
|
|
id=payload.get('object_attributes').get('iid'),
|
2016-10-19 23:49:23 +02:00
|
|
|
title=payload.get('object_attributes').get('title')
|
|
|
|
)
|
|
|
|
elif event.startswith('Issue Hook'):
|
|
|
|
return SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
|
|
|
|
repo=get_repo_name(payload),
|
|
|
|
type='Issue',
|
|
|
|
id=payload.get('object_attributes').get('iid'),
|
2016-10-11 18:54:48 +02:00
|
|
|
title=payload.get('object_attributes').get('title')
|
|
|
|
)
|
2016-10-21 16:01:15 +02:00
|
|
|
elif event == 'Note Hook Issue':
|
|
|
|
return SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
|
|
|
|
repo=get_repo_name(payload),
|
|
|
|
type='Issue',
|
|
|
|
id=payload.get('issue').get('iid'),
|
|
|
|
title=payload.get('issue').get('title')
|
|
|
|
)
|
|
|
|
elif event == 'Note Hook MergeRequest':
|
|
|
|
return SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
|
|
|
|
repo=get_repo_name(payload),
|
|
|
|
type='MR',
|
|
|
|
id=payload.get('merge_request').get('iid'),
|
|
|
|
title=payload.get('merge_request').get('title')
|
|
|
|
)
|
2016-10-21 17:53:33 +02:00
|
|
|
|
|
|
|
elif event == 'Note Hook Snippet':
|
|
|
|
return SUBJECT_WITH_PR_OR_ISSUE_INFO_TEMPLATE.format(
|
|
|
|
repo=get_repo_name(payload),
|
|
|
|
type='Snippet',
|
|
|
|
id=payload.get('snippet').get('id'),
|
|
|
|
title=payload.get('snippet').get('title')
|
|
|
|
)
|
2016-09-26 08:12:24 +02:00
|
|
|
return get_repo_name(payload)
|
2016-09-22 20:15:06 +02:00
|
|
|
|
2016-08-18 20:57:50 +02:00
|
|
|
def get_event(request, payload):
|
|
|
|
# type: (HttpRequest, Dict[str, Any]) -> str
|
|
|
|
event = request.META['HTTP_X_GITLAB_EVENT']
|
|
|
|
if event == 'Issue Hook':
|
|
|
|
action = payload.get('object_attributes').get('action')
|
|
|
|
event = "{} {}".format(event, action)
|
|
|
|
elif event == 'Note Hook':
|
|
|
|
action = payload.get('object_attributes').get('noteable_type')
|
|
|
|
event = "{} {}".format(event, action)
|
|
|
|
elif event == 'Merge Request Hook':
|
|
|
|
action = payload.get('object_attributes').get('action')
|
|
|
|
event = "{} {}".format(event, action)
|
|
|
|
elif event == 'Wiki Page Hook':
|
|
|
|
action = payload.get('object_attributes').get('action')
|
|
|
|
event = "{} {}".format(event, action)
|
|
|
|
|
|
|
|
if event in list(EVENT_FUNCTION_MAPPER.keys()):
|
|
|
|
return event
|
|
|
|
raise UnknownEventType(u'Event {} is unknown and cannot be handled'.format(event))
|