From e8409b13e615d0287fa22a9cc9868eab884ef0ef Mon Sep 17 00:00:00 2001 From: Goffi Date: Wed, 28 Jun 2017 01:21:49 +0200 Subject: [PATCH] jp (base): added no_lf in disp() to avoid printing a line feed --- frontends/src/jp/base.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/frontends/src/jp/base.py b/frontends/src/jp/base.py index 99273c0a..8300d793 100644 --- a/frontends/src/jp/base.py +++ b/frontends/src/jp/base.py @@ -244,18 +244,25 @@ class Jp(object): 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 @@ class CommandBase(object): """ 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: