Commits

Ali Gholami Rudi  committed 8224340

decorators: not using Pymacs in decorators

  • Participants
  • Parent commits 68aae7f
  • Branches default

Comments (0)

Files changed (2)

File ropecommon/decorators.py

 
 from rope.base import exceptions
 
-from Pymacs import lisp
+
+class Logger(object):
+
+    message = None
+
+    def __call__(self, message):
+        if message is None:
+            print message
+        else:
+            self.message(message)
+
+logger = Logger()
 
 
 def lisphook(func):
             func(*args, **kwds)
         except Exception, e:
             trace = str(traceback.format_exc())
-            lisp.message('%s\nIgnored an exception in ropemacs hook: %s' %
-                         (trace, _exception_message(e)))
+            logger('%s\nIgnored an exception in ropemacs hook: %s' %
+                   (trace, _exception_message(e)))
     newfunc.lisp = None
     newfunc.__name__ = func.__name__
     newfunc.__doc__ = func.__doc__
         try:
             func(*args, **kwds)
         except exceptions.RopeError, e:
-            lisp.message(str(traceback.format_exc()))
+            logger(str(traceback.format_exc()))
             if isinstance(e, input_exceptions):
-                lisp.message(_exception_message(e))
+                logger(_exception_message(e))
     newfunc.__name__ = func.__name__
     newfunc.__doc__ = func.__doc__
     return newfunc
 
 import ropecommon.dialog
 import ropecommon.interface
+import ropecommon.decorators
 
 
 class LispUtils(object):
 )
 """
 
+ropecommon.decorators.logger.message = lisp.message
 lisp(DEFVARS)
 _interface = ropecommon.interface.Ropemacs(env=LispUtils())
 _register_functions(_interface)