From: karltk Date: Wed, 8 Sep 2004 16:46:37 +0000 (-0000) Subject: Reworked output code X-Git-Tag: gentoolkit-0.2.4.3~377 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8cd113fdd3a6db2b56e411d86eca8af79df0cdd3;p=gentoolkit.git Reworked output code svn path=/; revision=125 --- diff --git a/trunk/src/gentoolkit/ChangeLog b/trunk/src/gentoolkit/ChangeLog index 8eea5de..dcb7a61 100644 --- a/trunk/src/gentoolkit/ChangeLog +++ b/trunk/src/gentoolkit/ChangeLog @@ -1,3 +1,6 @@ +2004-09-08: Karl Trygve Kalleberg + * Reworked printing functions + 2004-08-29: Karl Trygve Kalleberg * Added printing functions diff --git a/trunk/src/gentoolkit/__init__.py b/trunk/src/gentoolkit/__init__.py new file mode 100644 index 0000000..42b7570 --- /dev/null +++ b/trunk/src/gentoolkit/__init__.py @@ -0,0 +1 @@ +from gentoolkit import * \ No newline at end of file diff --git a/trunk/src/gentoolkit/gentoolkit.py b/trunk/src/gentoolkit/gentoolkit.py index 9d81d4e..a7f2f4d 100644 --- a/trunk/src/gentoolkit/gentoolkit.py +++ b/trunk/src/gentoolkit/gentoolkit.py @@ -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 index 0000000..b9c6a88 --- /dev/null +++ b/trunk/src/gentoolkit/pprinter.py @@ -0,0 +1,86 @@ +#!/usr/bin/python +# +# Copyright 2004 Karl Trygve Kalleberg +# 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