[debug/DBG_UICFG] add syntaxe highlight

authorLaurent Peuch <cortex@worlddomination.be>
changeset25b42cbd8c13
branchdefault
phasedraft
hiddenno
parent revision#6874f361aa1b [debug/dbglevel] add new dbglevel flag DBG_UICFG
child revision#d9292ce0698f [debug_toolbar] add a uicfg declarations panel
files modified by this revision
cubicweb/rtags.py
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1611742835 -3600
# Wed Jan 27 11:20:35 2021 +0100
# Node ID 25b42cbd8c13f2bb8310c1ae8b8baa0707b0e28c
# Parent 6874f361aa1b57867a9abf1006dbe422e35dd936
[debug/DBG_UICFG] add syntaxe highlight

diff --git a/cubicweb/rtags.py b/cubicweb/rtags.py
@@ -44,10 +44,11 @@
1 
2  from logilab.common.logging_ext import set_log_methods
3  from logilab.common.registry import RegistrableInstance, yes
4 
5  from cubicweb import server
6 +from cubicweb.misc.source_highlight import highlight
7 
8 
9  def _ensure_str_key(key):
10      return tuple(str(k) for k in key)
11 
@@ -129,12 +130,12 @@
12          stack = inspect.stack()
13          declaration = self._get_declaration(stack, key, value)
14 
15          if declaration and (server.DEBUG & server.DBG_UICFG):
16              print('uicfg: add "%s" from "%s" at %s:%s' % (
17 -                ("%s = %s" % (declaration["key"], repr(declaration["value"]))).strip(),
18 -                "\n".join(declaration["inspect_frame"].code_context).strip(),
19 +                highlight("%s = %s" % (declaration["key"], repr(declaration["value"])), "python").strip(),
20 +                highlight("\n".join(declaration["inspect_frame"].code_context), "python").strip(),
21                  declaration["inspect_frame"].filename,
22                  declaration["inspect_frame"].lineno,
23              ))
24 
25          return super(DebugDict, self).__setitem__(key, value)