comparison frontends/src/jp/base.py @ 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 fd4111075e00
children c7a72b75232b
comparison
equal deleted inserted replaced
2276:5cd45a79775b 2277:637886ac35f6
242 pass 242 pass
243 else: 243 else:
244 for cache_data in cache: 244 for cache_data in cache:
245 cache_data[0](*cache_data[1:]) 245 cache_data[0](*cache_data[1:])
246 246
247 def disp(self, msg, verbosity=0, error=False): 247 def disp(self, msg, verbosity=0, error=False, no_lf=False):
248 """Print a message to user 248 """Print a message to user
249 249
250 @param msg(unicode): message to print 250 @param msg(unicode): message to print
251 @param verbosity(int): minimal verbosity to display the message 251 @param verbosity(int): minimal verbosity to display the message
252 @param error(bool): if True, print to stderr instead of stdout 252 @param error(bool): if True, print to stderr instead of stdout
253 @param no_lf(bool): if True, do not emit line feed at the end of line
253 """ 254 """
254 if self.verbosity >= verbosity: 255 if self.verbosity >= verbosity:
255 if error: 256 if error:
256 print >>sys.stderr,msg.encode('utf-8') 257 if no_lf:
258 print >>sys.stderr,msg.encode('utf-8'),
259 else:
260 print >>sys.stderr,msg.encode('utf-8')
257 else: 261 else:
258 print msg.encode('utf-8') 262 if no_lf:
263 print msg.encode('utf-8'),
264 else:
265 print msg.encode('utf-8')
259 266
260 def output(self, type_, name, extra_outputs, data): 267 def output(self, type_, name, extra_outputs, data):
261 if name in extra_outputs: 268 if name in extra_outputs:
262 extra_outputs[name](data) 269 extra_outputs[name](data)
263 else: 270 else:
760 767
761 @param error_msg(unicode): error message as sent by bridge.progressError 768 @param error_msg(unicode): error message as sent by bridge.progressError
762 """ 769 """
763 self.disp(_(u"Error while doing operation: {}").format(error_msg), error=True) 770 self.disp(_(u"Error while doing operation: {}").format(error_msg), error=True)
764 771
765 def disp(self, msg, verbosity=0, error=False): 772 def disp(self, msg, verbosity=0, error=False, no_lf=False):
766 return self.host.disp(msg, verbosity, error) 773 return self.host.disp(msg, verbosity, error, no_lf)
767 774
768 def output(self, data): 775 def output(self, data):
769 try: 776 try:
770 output_type = self._output_type 777 output_type = self._output_type
771 except AttributeError: 778 except AttributeError: