diff options
Diffstat (limited to 'tools.py')
| -rw-r--r-- | tools.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools.py b/tools.py new file mode 100644 index 0000000..69d8bdb --- /dev/null +++ b/tools.py @@ -0,0 +1,26 @@ +import sys +import os + +progname = os.path.basename(sys.argv[0]) + +def quote(s, ch = '"'): + return s if " " not in s else ch + s + ch + +def printf(fmt, *args): + out = fmt % args + sys.stdout.write(out) + + if out[-1] != '\n': + sys.stdout.flush() + +def printerr(fmt, *args): + msg = fmt % args + if msg[-1] != "\n": + msg += "\n" + sys.stderr.write("** " + progname + ": " + msg) + +def debug(fmt, *args): + msg = fmt % args + if msg[-1] != "\n": + msg += "\n" + sys.stderr.write("-- " + msg) |
