changeset 2277:637886ac35f6

jp (base): added no_lf in disp() to avoid printing a line feed
author Goffi <goffi@goffi.org>
date Wed, 28 Jun 2017 01:21:49 +0200
parents 5cd45a79775b
children 489efbda377c
files frontends/src/jp/base.py
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/jp/base.py	Wed Jun 28 01:20:44 2017 +0200
+++ b/frontends/src/jp/base.py	Wed Jun 28 01:21:49 2017 +0200
@@ -244,18 +244,25 @@
             for cache_data in cache:
                 cache_data[0](*cache_data[1:])
 
-    def disp(self, msg, verbosity=0, error=False):
+    def disp(self, msg, verbosity=0, error=False, no_lf=False):
         """Print a message to user
 
         @param msg(unicode): message to print
         @param verbosity(int): minimal verbosity to display the message
         @param error(bool): if True, print to stderr instead of stdout
+        @param no_lf(bool): if True, do not emit line feed at the end of line
         """
         if self.verbosity >= verbosity:
             if error:
-                print >>sys.stderr,msg.encode('utf-8')
+                if no_lf:
+                    print >>sys.stderr,msg.encode('utf-8'),
+                else:
+                    print >>sys.stderr,msg.encode('utf-8')
             else:
-                print msg.encode('utf-8')
+                if no_lf:
+                    print msg.encode('utf-8'),
+                else:
+                    print msg.encode('utf-8')
 
     def output(self, type_, name, extra_outputs, data):
         if name in extra_outputs:
@@ -762,8 +769,8 @@
         """
         self.disp(_(u"Error while doing operation: {}").format(error_msg), error=True)
 
-    def disp(self, msg, verbosity=0, error=False):
-        return self.host.disp(msg, verbosity, error)
+    def disp(self, msg, verbosity=0, error=False, no_lf=False):
+        return self.host.disp(msg, verbosity, error, no_lf)
 
     def output(self, data):
         try: