From 2322e196845dedc8d4694502b11e47d97986549d Mon Sep 17 00:00:00 2001 From: karltk Date: Sun, 29 Aug 2004 21:55:49 +0000 Subject: [PATCH] Added printing functions svn path=/; revision=120 --- trunk/src/gentoolkit/ChangeLog | 3 +++ trunk/src/gentoolkit/gentoolkit.py | 30 ++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/trunk/src/gentoolkit/ChangeLog b/trunk/src/gentoolkit/ChangeLog index 5439d45..8eea5de 100644 --- a/trunk/src/gentoolkit/ChangeLog +++ b/trunk/src/gentoolkit/ChangeLog @@ -1,3 +1,6 @@ +2004-08-29: Karl Trygve Kalleberg + * Added printing functions + 2004-08-22: Karl Trygve Kalleberg * Fixed Package.get_env_var to use the correct tree db. * Renamed Package.get_use_vars to Package.get_use_flags diff --git a/trunk/src/gentoolkit/gentoolkit.py b/trunk/src/gentoolkit/gentoolkit.py index c0bbb3e..9d81d4e 100644 --- a/trunk/src/gentoolkit/gentoolkit.py +++ b/trunk/src/gentoolkit/gentoolkit.py @@ -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 # -- 2.26.2