Merge "colorizer: use staticmethod rather than classmethod"

This commit is contained in:
Jenkins 2014-06-19 18:06:40 +00:00 committed by Gerrit Code Review
commit f4598907ad

View File

@ -62,9 +62,10 @@ class _AnsiColorizer(object):
def __init__(self, stream): def __init__(self, stream):
self.stream = stream self.stream = stream
def supported(cls, stream=sys.stdout): @staticmethod
def supported(stream=sys.stdout):
""" """
A class method that returns True if the current platform supports A method that returns True if the current platform supports
coloring terminal output using this method. Returns False otherwise. coloring terminal output using this method. Returns False otherwise.
""" """
if not stream.isatty(): if not stream.isatty():
@ -83,7 +84,6 @@ class _AnsiColorizer(object):
except Exception: except Exception:
# guess false in case of error # guess false in case of error
return False return False
supported = classmethod(supported)
def write(self, text, color): def write(self, text, color):
""" """
@ -121,7 +121,8 @@ class _Win32Colorizer(object):
'white': red | green | blue | bold 'white': red | green | blue | bold
} }
def supported(cls, stream=sys.stdout): @staticmethod
def supported(stream=sys.stdout):
try: try:
import win32console import win32console
screenBuffer = win32console.GetStdHandle( screenBuffer = win32console.GetStdHandle(
@ -138,7 +139,6 @@ class _Win32Colorizer(object):
return False return False
else: else:
return True return True
supported = classmethod(supported)
def write(self, text, color): def write(self, text, color):
color = self._colors[color] color = self._colors[color]
@ -154,9 +154,9 @@ class _NullColorizer(object):
def __init__(self, stream): def __init__(self, stream):
self.stream = stream self.stream = stream
def supported(cls, stream=sys.stdout): @staticmethod
def supported(stream=sys.stdout):
return True return True
supported = classmethod(supported)
def write(self, text, color): def write(self, text, color):
self.stream.write(text) self.stream.write(text)