[debug/source_highlight] rename highlight to highlight_terminal
authorLaurent Peuch <cortex@worlddomination.be>
Wed, 06 Nov 2019 14:43:49 +0100
changeset 12758 db95a417a5ec
parent 12757 e55f6f6a8d28
child 12759 ec834074ea25
[debug/source_highlight] rename highlight to highlight_terminal
cubicweb/misc/source_highlight.py
cubicweb/server/querier.py
cubicweb/server/sources/__init__.py
cubicweb/server/sources/native.py
--- a/cubicweb/misc/source_highlight.py	Thu Oct 24 06:34:42 2019 +0200
+++ b/cubicweb/misc/source_highlight.py	Wed Nov 06 14:43:49 2019 +0100
@@ -12,7 +12,7 @@
     has_pygments = False
 
 
-def highlight(code, language):
+def highlight_terminal(code, language):
     if not has_pygments:
         return code
 
--- a/cubicweb/server/querier.py	Thu Oct 24 06:34:42 2019 +0200
+++ b/cubicweb/server/querier.py	Wed Nov 06 14:43:49 2019 +0100
@@ -32,7 +32,7 @@
 from cubicweb.rset import ResultSet
 
 from cubicweb.utils import QueryCache, RepeatList
-from cubicweb.misc.source_highlight import highlight
+from cubicweb.misc.source_highlight import highlight_terminal
 from cubicweb.server.rqlannotation import SQLGenAnnotator, set_qdata
 from cubicweb.server.ssplanner import READ_ONLY_RTYPES, add_types_restriction
 from cubicweb.server.edition import EditedEntity
@@ -524,7 +524,7 @@
         if server.DEBUG & (server.DBG_RQL | server.DBG_SQL):
             if server.DEBUG & (server.DBG_MORE | server.DBG_SQL):
                 print('*'*80)
-            print("querier input", highlight(repr(rql)[1:-1], 'RQL'), repr(args))
+            print("querier input", highlight_terminal(repr(rql)[1:-1], 'RQL'), repr(args))
         try:
             rqlst, cachekey = self.rql_cache.get(cnx, rql, args)
         except UnknownEid:
--- a/cubicweb/server/sources/__init__.py	Thu Oct 24 06:34:42 2019 +0200
+++ b/cubicweb/server/sources/__init__.py	Wed Nov 06 14:43:49 2019 +0100
@@ -27,13 +27,13 @@
 
 from cubicweb import ValidationError, set_log_methods, server, _
 from cubicweb.server import SOURCE_TYPES
-from cubicweb.misc.source_highlight import highlight
+from cubicweb.misc.source_highlight import highlight_terminal
 
 
 def dbg_st_search(uri, union, args, cachekey=None, prefix='rql for'):
     if server.DEBUG & server.DBG_RQL:
         global t
-        print(" ", prefix, uri, "source:", highlight(repr(union.as_string())[1:-1], 'RQL'))
+        print(" ", prefix, uri, "source:", highlight_terminal(repr(union.as_string())[1:-1], 'RQL'))
         t = time()
         if server.DEBUG & server.DBG_MORE:
             print('    args', repr(args))
--- a/cubicweb/server/sources/native.py	Thu Oct 24 06:34:42 2019 +0200
+++ b/cubicweb/server/sources/native.py	Wed Nov 06 14:43:49 2019 +0100
@@ -50,7 +50,7 @@
 from cubicweb.server.edition import EditedEntity
 from cubicweb.server.sources import AbstractSource, dbg_st_search, dbg_results
 from cubicweb.server.sources.rql2sql import SQLGenerator
-from cubicweb.misc.source_highlight import highlight
+from cubicweb.misc.source_highlight import highlight_terminal
 from cubicweb.statsd_logger import statsd_timeit
 
 
@@ -68,12 +68,12 @@
         it's a function just so that it shows up in profiling
         """
         if server.DEBUG & server.DBG_SQL:
-            print('exec', highlight(query, "SQL"), args)
+            print('exec', highlight_terminal(query, "SQL"), args)
         try:
             self.cu.execute(str(query), args)
         except Exception as ex:
             print("sql: %r\n args: %s\ndbms message: %r" % (
-                highlight(query, "SQL"), args, ex.args[0]))
+                highlight_terminal(query, "SQL"), args, ex.args[0]))
             raise
 
     def fetchall(self):
@@ -686,7 +686,7 @@
         """
         cursor = cnx.cnxset.cu
         if server.DEBUG & server.DBG_SQL:
-            print('exec', highlight(query, "SQL"), args, cnx.cnxset.cnx)
+            print('exec', highlight_terminal(query, "SQL"), args, cnx.cnxset.cnx)
         try:
             # str(query) to avoid error if it's a unicode string
             cursor.execute(str(query), args)
@@ -749,7 +749,7 @@
         it's a function just so that it shows up in profiling
         """
         if server.DEBUG & server.DBG_SQL:
-            print('execmany', highlight(query, "SQL"), 'with', len(args), 'arguments',
+            print('execmany', highlight_terminal(query, "SQL"), 'with', len(args), 'arguments',
                   cnx.cnxset.cnx)
         cursor = cnx.cnxset.cu
         try: