Reworked output code
authorkarltk <karltk@gentoo.org>
Wed, 8 Sep 2004 16:46:37 +0000 (16:46 -0000)
committerkarltk <karltk@gentoo.org>
Wed, 8 Sep 2004 16:46:37 +0000 (16:46 -0000)
svn path=/; revision=125

trunk/src/gentoolkit/ChangeLog
trunk/src/gentoolkit/__init__.py [new file with mode: 0644]
trunk/src/gentoolkit/gentoolkit.py
trunk/src/gentoolkit/pprinter.py [new file with mode: 0644]

index 8eea5de019474e4da68011cf44a1465120951fcd..dcb7a61b694129482ef24fca6af21fe9a0a122bc 100644 (file)
@@ -1,3 +1,6 @@
+2004-09-08: Karl Trygve Kalleberg <karltk@gentoo.org>
+       * Reworked printing functions
+
 2004-08-29: Karl Trygve Kalleberg <karltk@gentoo.org>
        * Added printing functions
 
diff --git a/trunk/src/gentoolkit/__init__.py b/trunk/src/gentoolkit/__init__.py
new file mode 100644 (file)
index 0000000..42b7570
--- /dev/null
@@ -0,0 +1 @@
+from gentoolkit import *
\ No newline at end of file
index 9d81d4e1a406bd98afa1885a010f0f25b7e7642d..a7f2f4d5fe7a2a4fe7932a33e063e41c4fad8a47 100644 (file)
@@ -25,8 +25,6 @@ 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"]
@@ -167,7 +165,7 @@ class Package:
                v1=self._scpv
                v2=portage.catpkgsplit(other.get_cpv())
                if v1[0] != v2[0] or v1[1] != v2[1]:
-                       return None
+                       return 0
                return portage.pkgcmp(v1[1:],v2[1:])
        def size(self):
                """Estimates the installed size of the contents of this package, if possible.
@@ -192,26 +190,7 @@ 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
 #
diff --git a/trunk/src/gentoolkit/pprinter.py b/trunk/src/gentoolkit/pprinter.py
new file mode 100644 (file)
index 0000000..b9c6a88
--- /dev/null
@@ -0,0 +1,86 @@
+#!/usr/bin/python
+#
+# Copyright 2004 Karl Trygve Kalleberg <karltk@gentoo.org>
+# Copyright 2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+#
+# $Header$
+
+import gentoolkit
+import output
+import sys
+
+def print_error(s):
+    sys.stderr.write(output.red("!!! ") + s + "\n")
+
+def print_info(lv, s, line_break = True):
+    if gentoolkit.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)
+
+# Colour settings
+
+def cpv(s):
+    return output.green(s)
+
+def slot(s):
+    return output.white(s)
+    
+def useflag(s):
+    return output.blue(s)
+
+def useflagon(s):
+    return output.red(s)
+
+def useflagoff(s):
+    return output.blue(s)
+    
+def maskflag(s):
+    return output.red(s)
+
+def installedflag(s):
+    return output.white(s)
+    
+def number(s):
+    return output.turquoise(s)
+
+def pkgquery(s):
+    return output.white(s)
+
+def regexpquery(s):
+    return output.white(s)
+
+def path(s):
+    return output.white(s)
+
+def path_symlink(s):
+    return output.turquoise(s)
+
+def productname(s):
+    return output.turquoise(s)
+    
+def globaloption(s):
+    return output.yellow(s)
+
+def localoption(s):
+    return output.green(s)
+
+def command(s):
+    return output.green(s)
+    
+def section(s):
+    return output.turquoise(s)    
+
+def subsection(s):
+    return output.turquoise(s)
+    
+def emph(s):
+    return output.white(s)    
\ No newline at end of file