X-Git-Url: https://git.distorted.org.uk/~mdw/chopwood/blobdiff_plain/1f8350d2e314e9497fd58c11a125f15b51e98238..5b7c6334a8922d1fe49fb713d4432cbe667133f2:/output.py diff --git a/output.py b/output.py index b849985..8dd967f 100644 --- a/output.py +++ b/output.py @@ -26,6 +26,7 @@ from __future__ import with_statement import contextlib as CTX +import os as OS from cStringIO import StringIO import sys as SYS @@ -77,7 +78,7 @@ class BasicOutputDriver (object): def __init__(me): """Trivial constructor.""" - pass + me.warnings = [] def writeln(me, msg): """Write MSG, as a complete line.""" @@ -87,6 +88,10 @@ class BasicOutputDriver (object): """Write MSG to the output, with any necessary decoration.""" me._write(str(msg)) + def warn(me, msg): + """Write MSG as a warning message.""" + SYS.stderr.write('%s: %s\n' % (OS.path.basename(SYS.argv[0]), msg)) + def close(me): """Wrap up when everything that needs saying has been said.""" pass @@ -194,10 +199,13 @@ class DelegatingOutput (BasicOutputDriver): def writeln(me, msg): me._fluid.target.writeln(msg) def close(me): me._fluid.target.close() def header(me, **kw): me._fluid.target.header(**kw) + def warn(me, msg): me._fluid.target.warn(msg) ## Delegating properties. @property def headerp(me): return me._fluid.target.headerp + @property + def warnings(me): return me._fluid.target.warnings ## The selected output driver. Set this with `output_to'. OUT = DelegatingOutput()