diff options
| author | mikeos <mike.osipov@gmail.com> | 2013-09-30 04:36:57 +0400 |
|---|---|---|
| committer | mikeos <mike.osipov@gmail.com> | 2013-09-30 04:36:57 +0400 |
| commit | 0ae5a430e4f92ee7bf9e458cf584a0a12fd5c25a (patch) | |
| tree | da2f685caf97a8c51991360b97b852466f7ca765 /tools.py | |
| parent | 5fb3e2f167ba4a742dc84ed58ddd68c8374a1195 (diff) | |
refactoring
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) |
