VirtualMailManager/cli/__init__.py
branchv0.6.x
changeset 217 eecd05e31517
parent 215 33f727efa7c4
child 312 6f39a1e56f4a
equal deleted inserted replaced
216:0c8c053b451c 217:eecd05e31517
    21 _std_write = os.sys.stdout.write
    21 _std_write = os.sys.stdout.write
    22 _err_write = os.sys.stderr.write
    22 _err_write = os.sys.stderr.write
    23 
    23 
    24 
    24 
    25 def w_std(*args):
    25 def w_std(*args):
    26     """Writes each arg of `args`, encoded in the current ENCODING, to stdout
    26     """Writes a line for each arg of *args*, encoded in the current
    27     and appends a newline."""
    27     ENCODING, to stdout.
    28     for arg in args:
    28 
    29         _std_write(arg.encode(ENCODING, 'replace'))
    29     """
    30         _std_write('\n')
    30     _std_write('\n'.join(arg.encode(ENCODING, 'replace') for arg in args))
       
    31     _std_write('\n')
    31 
    32 
    32 
    33 
    33 def w_err(code, *args):
    34 def w_err(code, *args):
    34     """Writes each arg of `args`, encoded in the current ENCODING, to stderr
    35     """Writes a line for each arg of *args*, encoded in the current
    35     and appends a newline.
    36     ENCODING, to stderr.
    36 
    37 
    37     This function additional interrupts the program execution and uses
    38     This function additional interrupts the program execution and uses
    38     `code` system exit status."""
    39     *code* as the system exit status.
    39     for arg in args:
    40 
    40         _err_write(arg.encode(ENCODING, 'replace'))
    41     """
    41         _err_write('\n')
    42     _err_write('\n'.join(arg.encode(ENCODING, 'replace') for arg in args))
       
    43     _err_write('\n')
    42     os.sys.exit(code)
    44     os.sys.exit(code)
    43 
    45 
    44 
    46 
    45 def get_winsize():
    47 def get_winsize():
    46     """Returns a tuple of integers ``(ws_row, ws_col)`` with the height and
    48     """Returns a tuple of integers ``(ws_row, ws_col)`` with the height and