From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1PorWZ-0004v9-N5 for garchives@archives.gentoo.org; Mon, 14 Feb 2011 06:03:12 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 807F6E09D4; Mon, 14 Feb 2011 06:00:35 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 3EE44E09D4 for ; Mon, 14 Feb 2011 06:00:35 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id CCF961B4101 for ; Mon, 14 Feb 2011 06:00:34 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 4284E8006D for ; Mon, 14 Feb 2011 06:00:34 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <69ca817b92d78e91b03ee3e327b9e369c8f26e5a.dol-sen@gentoo> Subject: [gentoo-commits] proj/layman:master commit in: layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/output.py X-VCS-Directories: layman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 69ca817b92d78e91b03ee3e327b9e369c8f26e5a Date: Mon, 14 Feb 2011 06:00:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 82489356df3a951f4bf580624097203a commit: 69ca817b92d78e91b03ee3e327b9e369c8f26e5a Author: Brian Dolbec gmail com> AuthorDate: Mon Feb 14 00:52:19 2011 +0000 Commit: Brian Dolbec gmail com> CommitDate: Mon Feb 14 00:52:19 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/layman.git;a=3D= commit;h=3D69ca817b Split out MessageBase class, more code reduction/cleanup --- layman/output.py | 53 ++++++++++++++++++++++++++++++++++++++----------= ----- 1 files changed, 38 insertions(+), 15 deletions(-) diff --git a/layman/output.py b/layman/output.py index 5785d58..250ce96 100644 --- a/layman/output.py +++ b/layman/output.py @@ -12,15 +12,14 @@ __version__ =3D "0.1" =20 import sys, inspect, types =20 -from optparse import OptionGroup +from optparse import OptionGroup =20 -from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, OFF +from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, DEBUG_LEVEL,= OFF =20 =20 - -class Message: - #FIXME: Think about some simple doctests before you modify this clas= s the - # next time. +class MessageBase(object): + """Base Message class helper functions and variables + """ =20 def __init__(self, out =3D sys.stdout, @@ -29,7 +28,6 @@ class Message: warn_level =3D WARN_LEVEL, col =3D True ): - # Where should the error output go? This can also be a file self.error_out =3D err =20 @@ -43,24 +41,27 @@ class Message: self.info_lev =3D info_level =20 # Should the output be colored? + self.color_func =3D None self.set_colorize(col) =20 + self.debug_lev =3D OFF + self.has_error =3D False =20 =20 - def color (self, col, text): + def _color (self, col, text): return codes[col] + text + codes['reset'] =20 =20 - def no_color (self, col, text): + def _no_color (self, col, text): return text =20 =20 def set_colorize(self, state): if state: - self.color_func =3D self.color + self.color_func =3D self._color else: - self.color_func =3D self.no_color + self.color_func =3D self._no_color =20 =20 def set_info_level(self, info_level =3D INFO_LEVEL): @@ -71,10 +72,34 @@ class Message: self.warn_lev =3D warn_level =20 =20 + def set_debug_level(self, debugging_level =3D DEBUG_LEVEL): + self.debug_lev =3D debugging_level + + + +class Message(MessageBase): + """Primary Message output methods + """ + #FIXME: Think about some simple doctests before you modify this clas= s the + # next time. + + def __init__(self, + out =3D sys.stdout, + err =3D sys.stderr, + info_level =3D INFO_LEVEL, + warn_level =3D WARN_LEVEL, + col =3D True + ): + + MessageBase.__init__(self) + + ## Output Functions =20 def debug(self, info, level =3D OFF): - """empty debug function""" + """empty debug function, does nothing, + declared here for compatibility with DebugMessage + """ pass =20 =20 @@ -84,8 +109,6 @@ class Message: =20 def info (self, info, level =3D INFO_LEVEL): =20 - #print "info =3D", info - if type(info) not in types.StringTypes: info =3D str(info) =20 @@ -145,7 +168,7 @@ class Message: for i in error.split('\n'): # NOTE: Forced flushing ensures that stdout and stderr # stay in nice order. This is a workaround for calls like - # "overlord -L |& less". + # "layman -L |& less". sys.stdout.flush() print >> self.error_out, self.color_func('red', '* ') + i self.error_out.flush() From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1PomiE-0006Nj-IL for garchives@archives.gentoo.org; Mon, 14 Feb 2011 00:54:46 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 074ADE09CF; Mon, 14 Feb 2011 00:54:14 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id B5BC0E09CF for ; Mon, 14 Feb 2011 00:54:14 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E84551B4100 for ; Mon, 14 Feb 2011 00:54:13 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 6051F8006E for ; Mon, 14 Feb 2011 00:54:13 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <69ca817b92d78e91b03ee3e327b9e369c8f26e5a.dol-sen@gentoo> Subject: [gentoo-commits] proj/layman:overlord_merge commit in: layman/ X-VCS-Repository: proj/layman X-VCS-Files: layman/output.py X-VCS-Directories: layman/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 69ca817b92d78e91b03ee3e327b9e369c8f26e5a Date: Mon, 14 Feb 2011 00:54:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 0322ab48545ab6bb6b18b397c22d00b6 Message-ID: <20110214005413.mUi5lhCXe1ne7eqFrF_XW58dcMvus1QJNhySoqcS_Gs@z> commit: 69ca817b92d78e91b03ee3e327b9e369c8f26e5a Author: Brian Dolbec gmail com> AuthorDate: Mon Feb 14 00:52:19 2011 +0000 Commit: Brian Dolbec gmail com> CommitDate: Mon Feb 14 00:52:19 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/layman.git;a=3D= commit;h=3D69ca817b Split out MessageBase class, more code reduction/cleanup --- layman/output.py | 53 ++++++++++++++++++++++++++++++++++++++----------= ----- 1 files changed, 38 insertions(+), 15 deletions(-) diff --git a/layman/output.py b/layman/output.py index 5785d58..250ce96 100644 --- a/layman/output.py +++ b/layman/output.py @@ -12,15 +12,14 @@ __version__ =3D "0.1" =20 import sys, inspect, types =20 -from optparse import OptionGroup +from optparse import OptionGroup =20 -from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, OFF +from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, DEBUG_LEVEL,= OFF =20 =20 - -class Message: - #FIXME: Think about some simple doctests before you modify this clas= s the - # next time. +class MessageBase(object): + """Base Message class helper functions and variables + """ =20 def __init__(self, out =3D sys.stdout, @@ -29,7 +28,6 @@ class Message: warn_level =3D WARN_LEVEL, col =3D True ): - # Where should the error output go? This can also be a file self.error_out =3D err =20 @@ -43,24 +41,27 @@ class Message: self.info_lev =3D info_level =20 # Should the output be colored? + self.color_func =3D None self.set_colorize(col) =20 + self.debug_lev =3D OFF + self.has_error =3D False =20 =20 - def color (self, col, text): + def _color (self, col, text): return codes[col] + text + codes['reset'] =20 =20 - def no_color (self, col, text): + def _no_color (self, col, text): return text =20 =20 def set_colorize(self, state): if state: - self.color_func =3D self.color + self.color_func =3D self._color else: - self.color_func =3D self.no_color + self.color_func =3D self._no_color =20 =20 def set_info_level(self, info_level =3D INFO_LEVEL): @@ -71,10 +72,34 @@ class Message: self.warn_lev =3D warn_level =20 =20 + def set_debug_level(self, debugging_level =3D DEBUG_LEVEL): + self.debug_lev =3D debugging_level + + + +class Message(MessageBase): + """Primary Message output methods + """ + #FIXME: Think about some simple doctests before you modify this clas= s the + # next time. + + def __init__(self, + out =3D sys.stdout, + err =3D sys.stderr, + info_level =3D INFO_LEVEL, + warn_level =3D WARN_LEVEL, + col =3D True + ): + + MessageBase.__init__(self) + + ## Output Functions =20 def debug(self, info, level =3D OFF): - """empty debug function""" + """empty debug function, does nothing, + declared here for compatibility with DebugMessage + """ pass =20 =20 @@ -84,8 +109,6 @@ class Message: =20 def info (self, info, level =3D INFO_LEVEL): =20 - #print "info =3D", info - if type(info) not in types.StringTypes: info =3D str(info) =20 @@ -145,7 +168,7 @@ class Message: for i in error.split('\n'): # NOTE: Forced flushing ensures that stdout and stderr # stay in nice order. This is a workaround for calls like - # "overlord -L |& less". + # "layman -L |& less". sys.stdout.flush() print >> self.error_out, self.color_func('red', '* ') + i self.error_out.flush()