Salome HOME
ne plus avoir les messages de Christian
[tools/sat.git] / src / debug.py
index 13d7612b22c0f62e9b7026262d2d714dcba89614..5b373aeafd7450d1217154d7ed869fe8bb4894f8 100755 (executable)
@@ -54,14 +54,25 @@ Show pretty print debug representation from instances of SAT classes
 import os
 import sys
 import traceback
-import StringIO as SIO
 import pprint as PP
 
+# Compatibility python 2/3 for unicode
+try:
+    _test = unicode
+except:
+    unicode = str
+
+# Compatibility python 2/3 for StringIO
+try:
+    from StringIO import StringIO
+except ImportError:
+    from io import StringIO
+
 _debug = [False] #support push/pop for temporary activate debug outputs
 
 _user = os.environ['USER']
 # wambeke is christian at home
-_developers = ["christian", "wambeke", "crouzet"] # crouzet, kloss ...
+_developers = ["christian", "wambeke"] # crouzet, kloss ...
 
 
 def isDeveloper():
@@ -168,7 +179,7 @@ def format_color_exception(msg, limit=None, trace=None):
 # utilitaires divers pour debug
 ###############################################
 
-class OutStream(SIO.StringIO):
+class OutStream(StringIO):
     """
     utility class for pyconf.Config output iostream
     """
@@ -178,9 +189,9 @@ class OutStream(SIO.StringIO):
       keep value before lost as self.value
       """
       self.value = self.getvalue()
-      SIO.StringIO.close(self)
+      StringIO.close(self)
     
-class InStream(SIO.StringIO):
+class InStream(StringIO):
     """utility class for pyconf.Config input iostream"""
     pass
 
@@ -234,7 +245,7 @@ def _saveConfigRecursiveDbg(config, aStream, indent, path, nb):
     
     indstr = indent * ' ' # '':no indent, ' ':indent
     strType = str(type(config))
-    if debug: print "saveDbg Type", path, strType
+    if debug: print("saveDbg Type %s %s" % (path, strType))
     
     if "Sequence" in strType:
       for i in range(len(config)):
@@ -259,7 +270,7 @@ def _saveConfigRecursiveDbg(config, aStream, indent, path, nb):
     for key in sorted(data): #order): # data as sort alphabetical, order as initial order
       value = data[key]
       strType = str(type(value))
-      if debug: print 'strType', path, key, strType
+      if debug: print('strType %s %s %s' % (path, key, strType))
       if "Config" in strType:
         _saveConfigRecursiveDbg(value, aStream, indentp, path+"."+key, nbp)
         continue