Move info and warn to zavai lib
authorEnrico Zini <enrico@enricozini.org>
Sun, 14 Jun 2009 03:31:29 +0000 (11:31 +0800)
committerEnrico Zini <enrico@enricozini.org>
Sun, 14 Jun 2009 03:31:29 +0000 (11:31 +0800)
src/zavai
zavai/__init__.py

index 6844cab958b8489f9510d47d97dd4776c1c82243..152f4ff7389dc2ea3bc549a2f6bd9455f975dfb8 100755 (executable)
--- a/src/zavai
+++ b/src/zavai
@@ -28,11 +28,6 @@ import zavai
 
 VERSION="0.1"
 
-def warning(*args):
-    sys.stderr.write(" ".join(map(str, args)) + "\n")
-def info(*args):
-    sys.stderr.write(" ".join(map(str, args)) + "\n")
-
 class Parser(optparse.OptionParser):
     def __init__(self, *args, **kwargs):
         # Yes, in 2009 optparse from the *standard library* still uses old
@@ -51,13 +46,11 @@ parser.add_option("-v", "--verbose", action="store_true", help="verbose mode")
 
 (opts, args) = parser.parse_args()
 
-
 if not opts.verbose:
-    def info(*args):
-        pass
+    zavai.set_quiet()
 
 # Read configuration
-info("Loading configuration")
+zavai.info("Loading configuration")
 conf = zavai.read_config(nick="zavai")
 
 # Set up dbus
@@ -72,7 +65,7 @@ registry.register("app", zavai.Zavai)
 registry.register("menu", zavai.Menu)
 
 # Load plugins
-info("Loading plugins")
+zavai.info("Loading plugins")
 for p in zavai.load_plugins(nick="zavai"):
     try:
         p.init(conf = conf, registry = registry)
@@ -89,12 +82,12 @@ def on_kill(signum, frame):
 signal.signal(signal.SIGINT, on_kill)
 signal.signal(signal.SIGTERM, on_kill)
 
-info("Starting")
+zavai.info("Starting")
 app = registry.resource("app")
 app.connect("destroy", gtk.main_quit)
 app.run()
 
-info("Shutting down")
+zavai.info("Shutting down")
 registry.shutdown()
 
 sys.exit(0)
index f74fa5a1c947161c585601608c1768ca243808b6..aea5a9349dd93c7ecf983ac2fd2b8e3425386782 100644 (file)
@@ -21,3 +21,14 @@ from plugins import load_plugins
 from registry import Registry, Resource
 from menu import Menu, MenuLink
 from app import Zavai
+
+def warn(*args):
+    import sys
+    sys.stderr.write(" ".join(map(str, args)) + "\n")
+def info(*args):
+    import sys
+    sys.stderr.write(" ".join(map(str, args)) + "\n")
+
+def set_quiet():
+    def info(*args):
+        pass