colorizer: use staticmethod rather than classmethod

The methods are actually not class methods at all as they do not use the
class nor the instance.

Change-Id: I04721bcaef30da291389a1144bdcfe65f10753b2
This commit is contained in:
Julien Danjou 2014-06-12 15:31:02 +02:00
parent 00bc84b052
commit 2d2a3f3780

View File

@ -62,9 +62,10 @@ class _AnsiColorizer(object):
def __init__(self, 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.
"""
if not stream.isatty():
@ -83,7 +84,6 @@ class _AnsiColorizer(object):
except Exception:
# guess false in case of error
return False
supported = classmethod(supported)
def write(self, text, color):
"""
@ -121,7 +121,8 @@ class _Win32Colorizer(object):
'white': red | green | blue | bold
}
def supported(cls, stream=sys.stdout):
@staticmethod
def supported(stream=sys.stdout):
try:
import win32console
screenBuffer = win32console.GetStdHandle(
@ -138,7 +139,6 @@ class _Win32Colorizer(object):
return False
else:
return True
supported = classmethod(supported)
def write(self, text, color):
color = self._colors[color]
@ -154,9 +154,9 @@ class _NullColorizer(object):
def __init__(self, stream):
self.stream = stream
def supported(cls, stream=sys.stdout):
@staticmethod
def supported(stream=sys.stdout):
return True
supported = classmethod(supported)
def write(self, text, color):
self.stream.write(text)