jp: replace no_lf argument by end in disp (same as in print)
This commit is contained in:
parent
883a07c591
commit
f4c7f5e55e
1 changed files with 24 additions and 25 deletions
|
|
@ -234,25 +234,19 @@ class Jp(object):
|
|||
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 @@ class Jp(object):
|
|||
|
||||
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 @@ class CommandBase(object):
|
|||
"""
|
||||
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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue