From 41e002fec91587933f703d75647178909df6e4a9 Mon Sep 17 00:00:00 2001
From: arghdos <arghdos@gmail.com>
Date: Wed, 12 Jul 2017 20:42:44 -0400
Subject: [PATCH] unify highlighters

---
 loopy/target/execution.py | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/loopy/target/execution.py b/loopy/target/execution.py
index ffa0aa2ab..d89eb8ba8 100644
--- a/loopy/target/execution.py
+++ b/loopy/target/execution.py
@@ -774,28 +774,22 @@ class KernelExecutorBase(object):
 # {{{ code highlighers
 
 
-def get_highlighted_python_code(text):
+def get_highlighted_code(text, python=False):
     try:
         from pygments import highlight
     except ImportError:
         return text
     else:
-        from pygments.lexers import PythonLexer
+        from pygments.lexers import CLexer, PythonLexer
         from pygments.formatters import TerminalFormatter
 
-        return highlight(text, PythonLexer(), TerminalFormatter())
+        return highlight(text, CLexer() if not python else PythonLexer(),
+                         TerminalFormatter())
 
 
-def get_highlighted_code(text):
-    try:
-        from pygments import highlight
-    except ImportError:
-        return text
-    else:
-        from pygments.lexers import CLexer
-        from pygments.formatters import TerminalFormatter
+def get_highlighted_python_code(text):
+    return get_highlighted_code(text, True)
 
-        return highlight(text, CLexer(), TerminalFormatter())
 
 # }}}
 
-- 
GitLab