@@ -0,0 +1,1929 @@
+import sys%0A%0A%0Aclass colorize(str):%0A    %22%22%22%0A    Pretty simple to use::%0A%0A        colorize.make('foo').bold%0A        colorize.make('foo').green%0A        colorize.make('foo').yellow%0A        colorize.make('foo').red%0A        colorize.make('foo').blue%0A%0A    Otherwise you could go the long way (for example if you are%0A    testing this class)::%0A%0A        string = colorize('foo')%0A        string._set_attributes()%0A        string.red%0A%0A    %22%22%22%0A%0A    def __init__(self, string):%0A        self.stdout = sys.__stdout__%0A        self.appends = ''%0A        self.prepends = ''%0A        self.isatty = self.stdout.isatty()%0A%0A    def _set_attributes(self):%0A        %22%22%22%0A        Sets the attributes here because the str class does not%0A        allow to pass in anything other than a string to the constructor%0A        so we can't really mess with the other attributes.%0A        %22%22%22%0A        for k, v in self.__colors__.items():%0A            setattr(self, k, self.make_color(v))%0A%0A    def make_color(self, color):%0A        if not self.isatty or self.is_windows:%0A            return self%0A        return color + self + '%5C033%5B0m' + self.appends%0A%0A    @property%0A    def __colors__(self):%0A        return  dict(%0A                blue   = '%5C033%5B34m',%0A                green  = '%5C033%5B92m',%0A                yellow = '%5C033%5B33m',%0A                red    = '%5C033%5B91m',%0A                bold   = '%5C033%5B1m',%0A                ends   = '%5C033%5B0m'%0A        )%0A%0A    @property%0A    def is_windows(self):%0A        if sys.platform == 'win32':%0A            return True%0A        return False%0A%0A    @classmethod%0A    def make(cls, string):%0A        %22%22%22%0A        A helper method to return itself and workaround the fact that%0A        the str object doesn't allow extra arguments passed in to the%0A        constructor%0A        %22%22%22%0A        obj = cls(string)%0A        obj._set_attributes()%0A        return obj%0A%0A#%0A# Common string manipulations%0A#%0Ared_arrow = colorize.make('--%3E').red%0Ablue_arrow = colorize.make('--%3E').blue%0A

create a module for dealing with terminal output