1 import os 2 import sys 3 4 def _write_message(kind, message): 5 program = os.path.basename(sys.argv[0]) 6 sys.stderr.write('%s: %s: %s\n' % (program, kind, message)) 7 8 note = lambda message: _write_message('note', message) 9 warning = lambda message: _write_message('warning', message) 10 error = lambda message: _write_message('error', message) 11 fatal = lambda message: (_write_message('fatal error', message), sys.exit(1)) 12 13 __all__ = ['note', 'warning', 'error', 'fatal'] 14