# Path: pkg/win32/Python27/Lib/site-packages/clint/textui/colored.py
# class ColoredString(object):
#     """Enhanced string for __len__ operations on Colored output."""
#     def __init__(self, color, s):
#         super(ColoredString, self).__init__()
#         self.s = s
#         self.color = color
# 
#     @property
#     def color_str(self):
#         if sys.stdout.isatty() and not DISABLE_COLOR:
#             return '%s%s%s' % (
#                 getattr(colorama.Fore, self.color), self.s, colorama.Fore.RESET)
#         else:
#             return self.s
# 
# 
#     def __len__(self):
#         return len(self.s)
# 
#     def __repr__(self):
#         return "<%s-string: '%s'>" % (self.color, self.s)
# 
#     def __unicode__(self):
#         value = self.color_str
#         if isinstance(value, str) and hasattr(value, 'decode'):
#             return value.decode('utf8')
#         return value
# 
#     if PY3:
#         __str__ = __unicode__
#     else:
#         def __str__(self):
#             return unicode(self).encode('utf8')
# 
#     def __iter__(self):
#         return iter(self.color_str)
# 
#     def __add__(self, other):
#         return str(self.color_str) + str(other)
# 
#     def __radd__(self, other):
#         return str(other) + str(self.color_str)
# 
#     def __mul__(self, other):
#         return (self.color_str * other)
# 
#     def split(self, sep=None):
#         return [self._new(s) for s in self.s.split(sep)]
# 
#     def _new(self, s):
#         return ColoredString(self.color, s)
# 
# def clean(s):
#     strip = re.compile("([^-_a-zA-Z0-9!@#%&=,/'\";:~`\$\^\*\(\)\+\[\]\.\{\}\|\?\<\>\\]+|[^\s]+)")
#     txt = strip.sub('', str(s))
# 
#     strip = re.compile(r'\[\d+m')
#     txt = strip.sub('', txt)
# 
#     return txt
# 
# Path: pkg/win32/Python27/Lib/site-packages/clint/utils.py
# def tsplit(string, delimiters):
#     """Behaves str.split but supports tuples of delimiters."""
# 
#     delimiters = tuple(delimiters)
#     stack = [string,]
# 
#     for delimiter in delimiters:
#         for i, substring in enumerate(stack):
#             substack = substring.split(delimiter)
#             stack.pop(i)
#             for j, _substring in enumerate(substack):
#                 stack.insert(i+j, _substring)
# 
#     return stack
# 
# def schunk(string, size):
#     """Splits string into n sized chunks."""
# 
#     stack = []
# 
#     substack = []
#     current_count = 0
# 
#     for char in string:
#         if not current_count < size:
#             stack.append(''.join(substack))
#             substack = []
#             current_count = 0
# 
#         substack.append(char)
#         current_count += 1
# 
#     if len(substack):
#         stack.append(''.join(substack))
# 
#     return stack


from .colored import ColoredString, clean
from ..utils import tsplit, schunk
# -*- coding: utf-8 -*-

"""
clint.textui.formatters
~~~~~~~~~~~~~~~~~~~~~~~

Core TextUI functionality for text formatting.

"""

from __future__ import absolute_import



NEWLINES = ('\n', '\r', '\r\n')


def min_width(string, cols, padding=' '):
    """Returns given string with right padding."""

    is_color = isinstance(string, ColoredString)

    stack = tsplit(str(string), NEWLINES)

    for i, substring in enumerate(stack):
        _sub = clean(substring).ljust((cols + 0), padding)
        if is_color:

# Path: pkg/win32/Python27/Lib/site-packages/clint/textui/colored.py
# class ColoredString(object):
#     """Enhanced string for __len__ operations on Colored output."""
#     def __init__(self, color, s):
#         super(ColoredString, self).__init__()
#         self.s = s
#         self.color = color
# 
#     @property
#     def color_str(self):
#         if sys.stdout.isatty() and not DISABLE_COLOR:
#             return '%s%s%s' % (
#                 getattr(colorama.Fore, self.color), self.s, colorama.Fore.RESET)
#         else:
#             return self.s
# 
# 
#     def __len__(self):
#         return len(self.s)
# 
#     def __repr__(self):
#         return "<%s-string: '%s'>" % (self.color, self.s)
# 
#     def __unicode__(self):
#         value = self.color_str
#         if isinstance(value, str) and hasattr(value, 'decode'):
#             return value.decode('utf8')
#         return value
# 
#     if PY3:
#         __str__ = __unicode__
#     else:
#         def __str__(self):
#             return unicode(self).encode('utf8')
# 
#     def __iter__(self):
#         return iter(self.color_str)
# 
#     def __add__(self, other):
#         return str(self.color_str) + str(other)
# 
#     def __radd__(self, other):
#         return str(other) + str(self.color_str)
# 
#     def __mul__(self, other):
#         return (self.color_str * other)
# 
#     def split(self, sep=None):
#         return [self._new(s) for s in self.s.split(sep)]
# 
#     def _new(self, s):
#         return ColoredString(self.color, s)
# 
# def clean(s):
#     strip = re.compile("([^-_a-zA-Z0-9!@#%&=,/'\";:~`\$\^\*\(\)\+\[\]\.\{\}\|\?\<\>\\]+|[^\s]+)")
#     txt = strip.sub('', str(s))
# 
#     strip = re.compile(r'\[\d+m')
#     txt = strip.sub('', txt)
# 
#     return txt
# 
# Path: pkg/win32/Python27/Lib/site-packages/clint/utils.py
# def tsplit(string, delimiters):
#     """Behaves str.split but supports tuples of delimiters."""
# 
#     delimiters = tuple(delimiters)
#     stack = [string,]
# 
#     for delimiter in delimiters:
#         for i, substring in enumerate(stack):
#             substack = substring.split(delimiter)
#             stack.pop(i)
#             for j, _substring in enumerate(substack):
#                 stack.insert(i+j, _substring)
# 
#     return stack
# 
# def schunk(string, size):
#     """Splits string into n sized chunks."""
# 
#     stack = []
# 
#     substack = []
#     current_count = 0
# 
#     for char in string:
#         if not current_count < size:
#             stack.append(''.join(substack))
#             substack = []
#             current_count = 0
# 
#         substack.append(char)
#         current_count += 1
# 
#     if len(substack):
#         stack.append(''.join(substack))
# 
#     return stack


# Path: pkg/win32/Python27/Lib/site-packages/clint/textui/formatters.py
from .colored import ColoredString, clean
from ..utils import tsplit, schunk

# -*- coding: utf-8 -*-

"""
clint.textui.formatters
~~~~~~~~~~~~~~~~~~~~~~~

Core TextUI functionality for text formatting.

"""

from __future__ import absolute_import



NEWLINES = ('\n', '\r', '\r\n')


def min_width(string, cols, padding=' '):
    """Returns given string with right padding."""

    is_color = isinstance(string, ColoredString)

    stack = tsplit(str(string), NEWLINES)

    for i, substring in enumerate(stack):
        _sub = clean(substring).ljust((cols + 0), padding)
        if is_color:

            _sub = (_sub.replace(clean(substring), substring))