public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/layman:overlord_merge commit in: layman/
@ 2011-02-14  0:54 Brian Dolbec
  2011-02-14  6:00 ` [gentoo-commits] proj/layman:master " Brian Dolbec
  0 siblings, 1 reply; 8+ messages in thread
From: Brian Dolbec @ 2011-02-14  0:54 UTC (permalink / raw
  To: gentoo-commits

commit:     503c1586ac80109089f0bf6d0a1a0a579a19a6d7
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Feb 14 00:49:30 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Feb 14 00:49:30 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=503c1586

fix a missed color_off(), add myself to the copyright, whitespace cleaning

---
 layman/config.py |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/layman/config.py b/layman/config.py
index e515155..6f8f658 100644
--- a/layman/config.py
+++ b/layman/config.py
@@ -10,6 +10,7 @@
 # Copyright:
 #             (c) 2005 - 2009 Gunnar Wrobel
 #             (c) 2009        Sebastian Pipping
+#             (c) 2010 - 2011 Brian Dolbec
 #             Distributed under the terms of the GNU General Public License v2
 #
 # Author(s):
@@ -30,18 +31,14 @@ __version__ = "$Id: config.py 286 2007-01-09 17:48:23Z wrobel $"
 import sys, ConfigParser
 import os
 
-from   optparse                 import OptionParser, OptionGroup
+from optparse import OptionParser, OptionGroup
 
-#from   layman.debug             import OUT
-from   layman.output            import OUT
+#from layman.debug import OUT
+from layman.output import OUT
 
-from   layman.version           import VERSION
+from layman.constants import OFF
+from layman.version import VERSION
 
-#===============================================================================
-#
-# Class Config
-#
-#-------------------------------------------------------------------------------
 
 _USAGE = """
   layman (-a|-d|-s|-i) (OVERLAY|ALL)
@@ -375,7 +372,7 @@ class ArgsParser(object):
 
 
         if self.options.__dict__['nocolor']:
-            self.output.color_off()
+            self.output.set_colorize(OFF)
 
         # Fetch only an alternate config setting from the options
         if not self.options.__dict__['config'] is None:



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/layman:overlord_merge commit in: layman/
@ 2011-02-14  0:54 Brian Dolbec
  0 siblings, 0 replies; 8+ messages in thread
From: Brian Dolbec @ 2011-02-14  0:54 UTC (permalink / raw
  To: gentoo-commits

commit:     ac8a52948f107265718dabe97e144a7cc4a70091
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Feb 14 00:47:14 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Feb 14 00:47:14 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=ac8a5294

fix a long line, clean an unused import, fix the sync return value better

---
 layman/api.py |    7 +++----
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/layman/api.py b/layman/api.py
index f3d68b6..63682f6 100644
--- a/layman/api.py
+++ b/layman/api.py
@@ -17,7 +17,6 @@ from sys import stderr
 import os
 
 from layman.config import BareConfig
-#from layman.action import Sync
 
 from layman.dbbase import UnknownOverlayException, UnknownOverlayMessage
 from layman.db import DB, RemoteDB
@@ -320,7 +319,8 @@ class LaymanAPI(object):
                         candidates = '  %s' % tuple(available_srcs)[0]
                     else:
                         plural = 's'
-                        candidates = '\n'.join(('  %d. %s' % (ovl + 1, v)) for ovl, v in enumerate(available_srcs))
+                        candidates = '\n'.join(('  %d. %s' % (ovl + 1, v)) \
+                         for ovl, v in enumerate(available_srcs))
 
                     warnings.append((ovl,
                         'The source of the overlay "%(repo_name)s" seems to have changed.\n'
@@ -363,11 +363,10 @@ class LaymanAPI(object):
                 self.output.error('\nErrors:\n------\n')
                 for ovl, result in fatals:
                     self.output.error(result + '\n')
-                return False
 
         self.sync_results = (success, warnings, fatals)
 
-        return True
+        return fatals != []
 
 
     def fetch_remote_list(self):



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/layman:overlord_merge commit in: layman/
@ 2011-02-14  0:54 Brian Dolbec
  0 siblings, 0 replies; 8+ messages in thread
From: Brian Dolbec @ 2011-02-14  0:54 UTC (permalink / raw
  To: gentoo-commits

commit:     6a85b05289ae2bb9f5da1748985322e83d064f60
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Feb 13 09:31:54 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Feb 13 09:31:54 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=6a85b052

simplify debug.py to subclass the simplified Message class

---
 layman/debug.py |  151 ++++++++----------------------------------------------
 1 files changed, 23 insertions(+), 128 deletions(-)

diff --git a/layman/debug.py b/layman/debug.py
index 7c42974..d7af5aa 100644
--- a/layman/debug.py
+++ b/layman/debug.py
@@ -18,8 +18,10 @@ import sys, inspect, types
 
 from   optparse      import OptionGroup
 
-from   layman.constants  import codes
+from   layman.constants  import (codes, DEBUG_LEVEL, DEBUG_VERBOSITY,
+    INFO_LEVEL, WARN_LEVEL, OFF)
 
+from output import Message
 
 #################################################################################
 ##
@@ -27,7 +29,7 @@ from   layman.constants  import codes
 ##
 #################################################################################
 
-class Message:
+class DebugMessage(Message):
     #FIXME: Think about some simple doctests before you modify this class the
     #       next time.
 
@@ -35,10 +37,10 @@ class Message:
                  out = sys.stdout,
                  err = sys.stderr,
                  dbg = sys.stderr,
-                 debugging_level = 4,
-                 debugging_verbosity = 2,
-                 info_level = 4,
-                 warn_level = 4,
+                 debugging_level = DEBUG_LEVEL,
+                 debugging_verbosity = DEBUG_VERBOSITY,
+                 info_level = INFO_LEVEL,
+                 warn_level = WARN_LEVEL,
                  col = True,
                  mth = None,
                  obj = None,
@@ -94,6 +96,14 @@ class Message:
 
         self.has_error = False
 
+        Message.__init__(self,
+                out = self.std_out,
+                err = self.error_out,
+                info_level = self.info_level,
+                warn_level = self.warn_level,
+                col = self.col
+                )
+
 
     ############################################################################
     # Add command line options
@@ -170,9 +180,9 @@ class Message:
 
         if (options.__dict__.has_key('debug')
             and options.__dict__['debug']):
-            self.debug_on()
+            self.set_debug_level(DEBUG_LEVEL)
         else:
-            self.debug_off()
+            self.set_debug_level(OFF)
             return
 
         if (options.__dict__.has_key('debug_class_vars')
@@ -183,9 +193,9 @@ class Message:
 
         if (options.__dict__.has_key('debug_nocolor')
             and options.__dict__['debug_nocolor']):
-            self.color_off()
+            self.set_colorize(False)
         else:
-            self.color_on()
+            self.set_colorize(True)
 
         if (options.__dict__.has_key('debug_level') and
             options.__dict__['debug_level']):
@@ -242,46 +252,12 @@ class Message:
         if variables:
             self.debug_var = variables
 
-    def maybe_color (self, col, text):
-        if self.use_color:
-            return codes[col] + text + codes['reset']
-        return text
-
-    def set_info_level(self, info_level = 4):
-        self.info_lev = info_level
-
-    def info_off(self):
-        self.set_info_level(0)
-
-    def info_on(self, info_level = 4):
-        self.set_info_level(info_level)
-
-    def set_warn_level(self, warn_level = 4):
-        self.warn_lev = warn_level
-
-    def warn_off(self):
-        self.set_warn_level(0)
-
-    def warn_on(self, warn_level = 4):
-        self.set_warn_level(warn_level)
-
-    def set_debug_level(self, debugging_level = 4):
+    def set_debug_level(self, debugging_level = DEBUG_LEVEL):
         self.debug_lev = debugging_level
 
-    def set_debug_verbosity(self, debugging_verbosity = 2):
+    def set_debug_verbosity(self, debugging_verbosity = DEBUG_VERBOSITY):
         self.debug_vrb = debugging_verbosity
 
-    def debug_off(self):
-        self.set_debug_level(0)
-
-    def debug_on(self):
-        self.set_debug_level()
-
-    def color_off(self):
-        self.use_color = False
-
-    def color_on(self):
-        self.use_color = True
 
     def class_variables_off(self):
         self.show_class_variables = False
@@ -292,88 +268,7 @@ class Message:
     #############################################################################
     ## Output Functions
 
-    def notice (self, note):
-        print >> self.std_out, note
-
-    def info (self, info, level = 4):
-
-        #print "info =", info
-
-        if type(info) not in types.StringTypes:
-            info = str(info)
-
-        if level > self.info_lev:
-            return
-
-        for i in info.split('\n'):
-            print  >> self.std_out, self.maybe_color('green', '* ') + i
-
-    def status (self, message, status, info = 'ignored'):
-
-        if type(message) not in types.StringTypes:
-            message = str(message)
-
-        lines = message.split('\n')
-
-        if not lines:
-            return
-
-        for i in lines[0:-1]:
-            print  >> self.std_out, self.maybe_color('green', '* ') + i
-
-        i = lines[-1]
-
-        if len(i) > 58:
-            i = i[0:57]
-
-        if status == 1:
-            result = '[' + self.maybe_color('green', 'ok') + ']'
-        elif status == 0:
-            result = '[' + self.maybe_color('red', 'failed') + ']'
-        else:
-            result = '[' + self.maybe_color('yellow', info) + ']'
-
-        print  >> self.std_out, self.maybe_color('green', '* ') + i + ' ' + '.' * (58 - len(i))  \
-              + ' ' + result
-
-    def warn (self, warn, level = 4):
-
-        #print "DEBUG.warn()"
-
-        if type(warn) not in types.StringTypes:
-            warn = str(warn)
-
-        if level > self.warn_lev:
-            return
-
-        for i in warn.split('\n'):
-            print  >> self.std_out, self.maybe_color('yellow', '* ') + i
-
-    def error (self, error):
-
-        if type(error) not in types.StringTypes:
-            error = str(error)
-
-        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
-            # "layman -L |& less".
-            sys.stdout.flush()
-            print >> self.error_out, self.maybe_color('red', '* ') + i
-            self.error_out.flush()
-        self.has_error = True
-
-    def die (self, error):
-
-        if type(error) not in types.StringTypes:
-            error = str(error)
-
-        for i in error.split('\n'):
-            self.error(self.maybe_color('red', 'Fatal error: ') + i)
-        self.error(self.maybe_color('red', 'Fatal error(s) - aborting'))
-        sys.exit(1)
-
-    def debug (self, message, level = 4):
+    def debug (self, message, level = DEBUG_LEVEL):
         '''
         This is a generic debugging method.
         '''



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/layman:overlord_merge commit in: layman/
@ 2011-02-14  0:54 Brian Dolbec
  0 siblings, 0 replies; 8+ messages in thread
From: Brian Dolbec @ 2011-02-14  0:54 UTC (permalink / raw
  To: gentoo-commits

commit:     d308b929d9fb4a0c69d331079f9a8b3ebbb2164a
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Feb 14 00:50:45 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Feb 14 00:50:45 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=d308b929

more DebugMessage class cleanup/transition to subclassing Message

---
 layman/debug.py |   39 ++++++++++++++-------------------------
 1 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/layman/debug.py b/layman/debug.py
index d7af5aa..f5c247b 100644
--- a/layman/debug.py
+++ b/layman/debug.py
@@ -23,13 +23,10 @@ from   layman.constants  import (codes, DEBUG_LEVEL, DEBUG_VERBOSITY,
 
 from output import Message
 
-#################################################################################
-##
-## Message Class
-##
-#################################################################################
 
 class DebugMessage(Message):
+    """fully Debug enabled subclass of output.py's Message
+    """
     #FIXME: Think about some simple doctests before you modify this class the
     #       next time.
 
@@ -37,8 +34,8 @@ class DebugMessage(Message):
                  out = sys.stdout,
                  err = sys.stderr,
                  dbg = sys.stderr,
-                 debugging_level = DEBUG_LEVEL,
-                 debugging_verbosity = DEBUG_VERBOSITY,
+                 debug_level = DEBUG_LEVEL,
+                 debug_verbosity = DEBUG_VERBOSITY,
                  info_level = INFO_LEVEL,
                  warn_level = WARN_LEVEL,
                  col = True,
@@ -50,6 +47,8 @@ class DebugMessage(Message):
         if obj == None: obj = ['*']
         if var == None: var = ['*']
 
+        Message.__init__(self)
+
         # A description of the module that is being debugged
         self.debug_env = module
 
@@ -57,24 +56,24 @@ class DebugMessage(Message):
         self.debug_out = dbg
 
         # Where should the error output go? This can also be a file
-        self.error_out = err
+        #self.error_out = err
 
         # Where should the normal output go? This can also be a file
-        self.std_out = out
+        #self.std_out = out
 
         # The higher the level the more information you will get
-        self.warn_lev = warn_level
+        #self.warn_lev = warn_level
 
         # The higher the level the more information you will get
-        self.info_lev = info_level
+        #self.info_lev = info_level
 
         # The highest level of debugging messages acceptable for output
         # The higher the level the more output you will get
-        self.debug_lev = debugging_level
+        #self.debug_lev = debugging_level
 
         # The debugging output can range from very verbose (3) to
         # very compressed (1)
-        self.debug_vrb = debugging_verbosity
+        self.debug_vrb = debug_verbosity
 
         # Which methods should actually be debugged?
         # Use '*' to indicate 'All methods'
@@ -92,17 +91,9 @@ class DebugMessage(Message):
         self.show_class_variables = False
 
         # Should the output be colored?
-        self.use_color = col
-
-        self.has_error = False
+        #self.use_color = col
 
-        Message.__init__(self,
-                out = self.std_out,
-                err = self.error_out,
-                info_level = self.info_level,
-                warn_level = self.warn_level,
-                col = self.col
-                )
+        #self.has_error = False
 
 
     ############################################################################
@@ -252,8 +243,6 @@ class DebugMessage(Message):
         if variables:
             self.debug_var = variables
 
-    def set_debug_level(self, debugging_level = DEBUG_LEVEL):
-        self.debug_lev = debugging_level
 
     def set_debug_verbosity(self, debugging_verbosity = DEBUG_VERBOSITY):
         self.debug_vrb = debugging_verbosity



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/layman:overlord_merge commit in: layman/
@ 2011-02-14  0:54 Brian Dolbec
  0 siblings, 0 replies; 8+ messages in thread
From: Brian Dolbec @ 2011-02-14  0:54 UTC (permalink / raw
  To: gentoo-commits

commit:     cc15f2551e105540850101572ccba275a6fc1ace
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Feb 14 00:53:33 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Feb 14 00:53:33 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=cc15f255

fix the incorrect exit code settings which are opposite the True/False that the api returns

---
 layman/cli.py       |    7 ++++---
 layman/constants.py |    3 +++
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/layman/cli.py b/layman/cli.py
index 3277c1b..8f94f4a 100644
--- a/layman/cli.py
+++ b/layman/cli.py
@@ -27,7 +27,8 @@ import os, sys
 from layman.api import LaymanAPI
 from layman.utils import (decode_selection, encoder, get_encoding,
     pad, terminal_width)
-from layman.constants import NOT_OFFICIAL_MSG, NOT_SUPPORTED_MSG
+from layman.constants import (NOT_OFFICIAL_MSG, NOT_SUPPORTED_MSG,
+    FAILURE, SUCCEED)
 
 
 
@@ -180,9 +181,9 @@ class Main(object):
         os.umask(old_umask)
 
         if not result:
-            sys.exit(0)
+            sys.exit(FAILURE)
         else:
-            sys.exit(1)
+            sys.exit(SUCCEED)
 
 
     def Fetch(self):

diff --git a/layman/constants.py b/layman/constants.py
index 6962867..6f53de3 100644
--- a/layman/constants.py
+++ b/layman/constants.py
@@ -50,3 +50,6 @@ WARN_LEVEL = 4
 INFO_LEVEL = 4
 DEBUG_LEVEL = 4
 DEBUG_VERBOSITY = 2
+
+FAILURE = 1
+SUCCEED = 0



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/
@ 2011-02-14  6:00 Brian Dolbec
  2011-02-14  0:54 ` [gentoo-commits] proj/layman:overlord_merge " Brian Dolbec
  0 siblings, 1 reply; 8+ messages in thread
From: Brian Dolbec @ 2011-02-14  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     306b419af140c6e1eb41a2114005b20b82a5332c
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Feb 13 09:30:24 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Feb 13 09:30:24 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=306b419a

further simplify, reduce the number of functions

---
 layman/constants.py |    7 +++++++
 layman/output.py    |   37 +++++++++----------------------------
 2 files changed, 16 insertions(+), 28 deletions(-)

diff --git a/layman/constants.py b/layman/constants.py
index 7fc72ea..6962867 100644
--- a/layman/constants.py
+++ b/layman/constants.py
@@ -43,3 +43,10 @@ codes['turquoise'] = esc_seq + '36;01m'
 NOT_OFFICIAL_MSG = '*** This is not an official gentoo overlay ***\n'
 NOT_SUPPORTED_MSG = '*** You are lacking the necessary tools' +\
     ' to install this overlay ***\n'
+
+
+OFF = 0
+WARN_LEVEL = 4
+INFO_LEVEL = 4
+DEBUG_LEVEL = 4
+DEBUG_VERBOSITY = 2

diff --git a/layman/output.py b/layman/output.py
index 49ebb34..5785d58 100644
--- a/layman/output.py
+++ b/layman/output.py
@@ -14,7 +14,7 @@ import sys, inspect, types
 
 from   optparse      import OptionGroup
 
-from   overlord.constants  import codes
+from   layman.constants  import codes, INFO_LEVEL, WARN_LEVEL, OFF
 
 
 
@@ -25,8 +25,8 @@ class Message:
     def __init__(self,
                  out = sys.stdout,
                  err = sys.stderr,
-                 info_level = 4,
-                 warn_level = 4,
+                 info_level = INFO_LEVEL,
+                 warn_level = WARN_LEVEL,
                  col = True
                  ):
 
@@ -63,43 +63,26 @@ class Message:
             self.color_func = self.no_color
 
 
-    def set_info_level(self, info_level = 4):
+    def set_info_level(self, info_level = INFO_LEVEL):
         self.info_lev = info_level
 
 
-    def info_off(self):
-        self.set_info_level(0)
-
-
-    def info_on(self, info_level = 4):
-        self.set_info_level(info_level)
-
-
-    def set_warn_level(self, warn_level = 4):
+    def set_warn_level(self, warn_level = WARN_LEVEL):
         self.warn_lev = warn_level
 
 
-    def warn_off(self):
-        self.set_warn_level(0)
-
-
-    def warn_on(self, warn_level = 4):
-        self.set_warn_level(warn_level)
-
-
-
-
     ## Output Functions
 
-    def debug(self, info, level=0):
+    def debug(self, info, level = OFF):
         """empty debug function"""
         pass
 
+
     def notice (self, note):
         print >> self.std_out, note
 
 
-    def info (self, info, level = 4):
+    def info (self, info, level = INFO_LEVEL):
 
         #print "info =", info
 
@@ -142,9 +125,7 @@ class Message:
             '.' * (58 - len(i)) + ' ' + result
 
 
-    def warn (self, warn, level = 4):
-
-        #print "DEBUG.warn()"
+    def warn (self, warn, level = WARN_LEVEL):
 
         if type(warn) not in types.StringTypes:
             warn = str(warn)



^ permalink raw reply related	[flat|nested] 8+ messages in thread
* [gentoo-commits] proj/layman:master commit in: layman/
@ 2011-02-14  6:00 Brian Dolbec
  2011-02-14  0:54 ` [gentoo-commits] proj/layman:overlord_merge " Brian Dolbec
  0 siblings, 1 reply; 8+ messages in thread
From: Brian Dolbec @ 2011-02-14  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     69ca817b92d78e91b03ee3e327b9e369c8f26e5a
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Feb 14 00:52:19 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Feb 14 00:52:19 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=69ca817b

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__ = "0.1"
 
 import sys, inspect, types
 
-from   optparse      import OptionGroup
+from optparse import OptionGroup
 
-from   layman.constants  import codes, INFO_LEVEL, WARN_LEVEL, OFF
+from layman.constants import codes, INFO_LEVEL, WARN_LEVEL, DEBUG_LEVEL, OFF
 
 
-
-class Message:
-    #FIXME: Think about some simple doctests before you modify this class the
-    #       next time.
+class MessageBase(object):
+    """Base Message class helper functions and variables
+    """
 
     def __init__(self,
                  out = sys.stdout,
@@ -29,7 +28,6 @@ class Message:
                  warn_level = WARN_LEVEL,
                  col = True
                  ):
-
         # Where should the error output go? This can also be a file
         self.error_out = err
 
@@ -43,24 +41,27 @@ class Message:
         self.info_lev = info_level
 
         # Should the output be colored?
+        self.color_func = None
         self.set_colorize(col)
 
+        self.debug_lev = OFF
+
         self.has_error = False
 
 
-    def color (self, col, text):
+    def _color (self, col, text):
         return codes[col] + text + codes['reset']
 
 
-    def no_color (self, col, text):
+    def _no_color (self, col, text):
         return text
 
 
     def set_colorize(self, state):
         if state:
-            self.color_func = self.color
+            self.color_func = self._color
         else:
-            self.color_func = self.no_color
+            self.color_func = self._no_color
 
 
     def set_info_level(self, info_level = INFO_LEVEL):
@@ -71,10 +72,34 @@ class Message:
         self.warn_lev = warn_level
 
 
+    def set_debug_level(self, debugging_level = DEBUG_LEVEL):
+        self.debug_lev = debugging_level
+
+
+
+class Message(MessageBase):
+    """Primary Message output methods
+    """
+    #FIXME: Think about some simple doctests before you modify this class the
+    #       next time.
+
+    def __init__(self,
+                 out = sys.stdout,
+                 err = sys.stderr,
+                 info_level = INFO_LEVEL,
+                 warn_level = WARN_LEVEL,
+                 col = True
+                 ):
+
+        MessageBase.__init__(self)
+
+
     ## Output Functions
 
     def debug(self, info, level = OFF):
-        """empty debug function"""
+        """empty debug function, does nothing,
+        declared here for compatibility with DebugMessage
+        """
         pass
 
 
@@ -84,8 +109,6 @@ class Message:
 
     def info (self, info, level = INFO_LEVEL):
 
-        #print "info =", info
-
         if type(info) not in types.StringTypes:
             info = str(info)
 
@@ -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()



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-02-14  6:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-14  0:54 [gentoo-commits] proj/layman:overlord_merge commit in: layman/ Brian Dolbec
2011-02-14  6:00 ` [gentoo-commits] proj/layman:master " Brian Dolbec
  -- strict thread matches above, loose matches on Subject: below --
2011-02-14  0:54 [gentoo-commits] proj/layman:overlord_merge " Brian Dolbec
2011-02-14  0:54 Brian Dolbec
2011-02-14  0:54 Brian Dolbec
2011-02-14  0:54 Brian Dolbec
2011-02-14  6:00 [gentoo-commits] proj/layman:master " Brian Dolbec
2011-02-14  0:54 ` [gentoo-commits] proj/layman:overlord_merge " Brian Dolbec
2011-02-14  6:00 [gentoo-commits] proj/layman:master " Brian Dolbec
2011-02-14  0:54 ` [gentoo-commits] proj/layman:overlord_merge " Brian Dolbec

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox