Mercurial > libervia-backend
diff sat_frontends/jp/base.py @ 3407:2f0be2b7de68
jp: replace `no_lf` argument by `end` in `disp` (same as in `print`)
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 12 Nov 2020 14:53:16 +0100 |
parents | 67e306cae157 |
children | 19bc03743aeb |
line wrap: on
line diff
--- a/sat_frontends/jp/base.py Thu Nov 12 14:53:15 2020 +0100 +++ b/sat_frontends/jp/base.py Thu Nov 12 14:53:16 2020 +0100 @@ -234,25 +234,19 @@ for cache_data in cache: await cache_data[0](*cache_data[1:]) - def disp(self, msg, verbosity=0, error=False, no_lf=False): + def disp(self, msg, verbosity=0, error=False, end='\n'): """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 + @param end(str): string appended after the last value, default a newline """ if self.verbosity >= verbosity: if error: - if no_lf: - print(msg, end=' ', file=sys.stderr) - else: - print(msg, file=sys.stderr) + print(msg, end=end, file=sys.stderr) else: - if no_lf: - print(msg, end=' ') - else: - print(msg) + print(msg, end=end) async def output(self, type_, name, extra_outputs, data): if name in extra_outputs: @@ -684,7 +678,7 @@ async def ainput(self, msg=''): """Asynchronous version of buildin "input" function""" - self.disp(msg, no_lf=True) + self.disp(msg, end=' ') sys.stdout.flush() loop = asyncio.get_running_loop() stdin_fut = loop.create_future() @@ -1150,8 +1144,8 @@ """ self.disp(_(f"Error while doing operation: {e}"), error=True) - def disp(self, msg, verbosity=0, error=False, no_lf=False): - return self.host.disp(msg, verbosity, error, no_lf) + def disp(self, msg, verbosity=0, error=False, end='\n'): + return self.host.disp(msg, verbosity, error, end) def output(self, data): try: