]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
util module
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 25 Apr 2010 18:51:48 +0000 (14:51 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 25 Apr 2010 18:51:48 +0000 (14:51 -0400)
alembic/util.py [new file with mode: 0644]

diff --git a/alembic/util.py b/alembic/util.py
new file mode 100644 (file)
index 0000000..a7ae885
--- /dev/null
@@ -0,0 +1,30 @@
+from mako.template import Template
+import sys
+import os
+import textwrap
+
+def template_to_file(template_file, dest, **kw):
+    f = open(dest, 'w')
+    f.write(
+        Template(filename=template_file).render(**kw)
+    )
+    f.close()
+
+
+def format_opt(opt, hlp, padding=22):
+    return "  " + opt + \
+        ((padding - len(opt)) * " ") + hlp
+
+def status(msg, fn, *arg, **kw):
+    sys.stdout.write("  " + msg + "...")
+    try:
+        ret = fn(*arg, **kw)
+        sys.stdout.write("done\n")
+        return ret
+    except:
+        sys.stdout.write("FAILED\n")
+        raise
+
+
+def msg(msg):
+    sys.stdout.write(textwrap.wrap(msg))
\ No newline at end of file