Added printing functions
authorkarltk <karltk@gentoo.org>
Sun, 29 Aug 2004 21:55:49 +0000 (21:55 -0000)
committerkarltk <karltk@gentoo.org>
Sun, 29 Aug 2004 21:55:49 +0000 (21:55 -0000)
svn path=/; revision=120

trunk/src/gentoolkit/ChangeLog
trunk/src/gentoolkit/gentoolkit.py

index 5439d4530a48924c177722e6f55b2b02a2175115..8eea5de019474e4da68011cf44a1465120951fcd 100644 (file)
@@ -1,3 +1,6 @@
+2004-08-29: Karl Trygve Kalleberg <karltk@gentoo.org>
+       * Added printing functions
+
 2004-08-22: Karl Trygve Kalleberg <karltk@gentoo.org>
        * Fixed Package.get_env_var to use the correct tree db.
        * Renamed Package.get_use_vars to Package.get_use_flags
index c0bbb3ef690478312548ebd7c534cfe2af337af8..9d81d4e1a406bd98afa1885a010f0f25b7e7642d 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 #
-# Copyright 2003 Karl Trygve Kalleberg
-# Copyright 2003 Gentoo Technologies, Inc.
+# Copyright 2003-2004 Karl Trygve Kalleberg
+# Copyright 2003-2004 Gentoo Technologies, Inc.
 # Distributed under the terms of the GNU General Public License v2
 #
 # $Header$
@@ -25,11 +25,17 @@ import re
 import string
 import types
 
+from output import *
+
 settings = portage.config(clone=portage.settings)
 porttree = portage.db[portage.root]["porttree"]
 vartree  = portage.db[portage.root]["vartree"]
 virtuals = portage.db[portage.root]["virtuals"]
 
+Config = {
+       "verbosityLevel": 3
+}
+       
 # Nomenclature:
 #
 # CPV - category/package-version
@@ -186,6 +192,26 @@ class Package:
                        pnv=self.get_name()+"-"+self.get_version()
                        self._db=portage.dblink(cat,pnv,"/",settings)
 
+#
+# Output 
+#
+
+def print_error(s):
+       sys.stderr.write(red("!!! ") + s + "\n")
+
+def print_info(lv, s, line_break = True):
+       if Config["verbosityLevel"] >= lv:
+               sys.stdout.write(s)
+               if line_break:
+                       sys.stdout.write("\n")
+
+def print_warn(s):
+       sys.stderr.write("!!! " + s + "\n")
+       
+def die(err, s):
+       error(s)
+       sys.exit(-err)
+       
 #
 # Global helper functions
 #