VirtualMailManager/__init__.py
changeset 141 ecd6a379e523
parent 138 617f27715b01
child 152 3dbee02711cd
equal deleted inserted replaced
140:ffac064bd728 141:ecd6a379e523
    17 ENCODING = locale.nl_langinfo(locale.CODESET)
    17 ENCODING = locale.nl_langinfo(locale.CODESET)
    18 
    18 
    19 def w_std(*args):
    19 def w_std(*args):
    20     """Writes each arg of args, encoded in the current ENCODING, to stdout and
    20     """Writes each arg of args, encoded in the current ENCODING, to stdout and
    21     appends a newline."""
    21     appends a newline."""
       
    22     _write = os.sys.stdout.write
    22     for arg in args:
    23     for arg in args:
    23         os.sys.stdout.write(arg.encode(ENCODING, 'replace'))
    24         _write(arg.encode(ENCODING, 'replace'))
    24         os.sys.stdout.write('\n')
    25         _write('\n')
    25 
    26 
    26 def w_err(code, *args):
    27 def w_err(code, *args):
    27     """Writes each arg of args, encoded in the current ENCODING, to stderr and
    28     """Writes each arg of args, encoded in the current ENCODING, to stderr and
    28     appends a newline.
    29     appends a newline.
    29     This function additional interrupts the program execution and uses 'code'
    30     This function additional interrupts the program execution and uses 'code'
    30     system exit status."""
    31     system exit status."""
       
    32     _write = os.sys.stderr.write
    31     for arg in args:
    33     for arg in args:
    32         os.sys.stderr.write(arg.encode(ENCODING, 'replace'))
    34         _write(arg.encode(ENCODING, 'replace'))
    33         os.sys.stderr.write('\n')
    35         _write('\n')
    34     os.sys.exit(code)
    36     os.sys.exit(code)
    35 
    37 
    36 __all__ = [
    38 __all__ = [
    37         # imported modules
    39         # imported modules
    38         'os', 're', 'locale',
    40         'os', 're', 'locale',