From 569de55b827d75ce3272d655ab8afcc3a63903f2 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Mon, 10 Aug 2020 18:44:48 -0700 Subject: [PATCH] sentry: Rename mapping variable to be more explicitly-named. --- zerver/webhooks/sentry/view.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/zerver/webhooks/sentry/view.py b/zerver/webhooks/sentry/view.py index 6faa8667a1..7dfd91a933 100644 --- a/zerver/webhooks/sentry/view.py +++ b/zerver/webhooks/sentry/view.py @@ -35,7 +35,7 @@ EXCEPTION_EVENT_TEMPLATE = """ EXCEPTION_EVENT_TEMPLATE_WITH_TRACEBACK = EXCEPTION_EVENT_TEMPLATE + """ Traceback: -```{platform} +```{syntax_highlight_as} {pre_context}---> {context_line}{post_context}\ ``` """ @@ -63,11 +63,12 @@ ISSUE_IGNORED_MESSAGE_TEMPLATE = """ Issue **{title}** was ignored by **{actor}**. """ -platforms_map = { +# Maps "platform" name provided by Sentry to the Pygments lexer name +syntax_highlight_as_map = { "go": "go", "node": "javascript", "python": "python3", -} # We can expand this as and when users use this integration with different platforms. +} def convert_lines_to_traceback_string(lines: Optional[List[str]]) -> str: @@ -90,8 +91,8 @@ def handle_event_payload(event: Dict[str, Any]) -> Tuple[str, str]: raise UnexpectedWebhookEventType("Sentry", "Raven SDK") platform_name = event["platform"] - platform = platforms_map.get(platform_name) - if platform is None: # nocoverage + syntax_highlight_as = syntax_highlight_as_map.get(platform_name) + if syntax_highlight_as is None: # nocoverage raise UnexpectedWebhookEventType("Sentry", f"platform {platform_name}") context = { @@ -130,7 +131,7 @@ def handle_event_payload(event: Dict[str, Any]) -> Tuple[str, str]: post_context = convert_lines_to_traceback_string(exception_frame["post_context"]) context.update({ - "platform": platform, + "syntax_highlight_as": syntax_highlight_as, "filename": filename, "pre_context": pre_context, "context_line": context_line,