crayons-0.4.0/0000755000175100001640000000000013721552524014000 5ustar runnerdocker00000000000000crayons-0.4.0/LICENSE0000644000175100001640000000212213721552517015004 0ustar runnerdocker00000000000000The MIT License (MIT) Copyright 2017 Kenneth Reitz Copyright 2019 Matthew Peveler Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.crayons-0.4.0/PKG-INFO0000644000175100001640000000627113721552524015103 0ustar runnerdocker00000000000000Metadata-Version: 1.2 Name: crayons Version: 0.4.0 Summary: TextUI colors for Python. Home-page: https://github.com/MasterOdin/crayons Author: Kenneth Reitz Author-email: me@kennethreitz.com Maintainer: Matthew Peveler Maintainer-email: matt.peveler@gmail.com License: MIT Description: Crayons: Text UI colors for Python. =================================== .. image:: https://img.shields.io/pypi/v/crayons.svg :target: https://pypi.org/project/crayons/ .. image:: https://github.com/MasterOdin/crayons/workflows/Test/badge.svg :target: https://github.com/MasterOdin/crayons/actions?query=workflow%3ATest+branch%3Amaster .. image:: https://img.shields.io/pypi/l/crayons.svg :target: https://pypi.python.org/pypi/crayons .. image:: https://img.shields.io/pypi/wheel/crayons.svg :target: https://pypi.python.org/pypi/crayons .. image:: https://img.shields.io/pypi/pyversions/crayons.svg :target: https://pypi.python.org/pypi/crayons This module is really simple, it gives you colored strings for terminal usage. Included colors are ``red``, ``green``, ``yellow``, ``blue``, ``black``, ``magenta``, ``cyan``, ``white``, and ``normal`` (as well as ``clean`` and ``disable``). **Crayons** is nice because it automatically wraps a given string in both the foreground color, as well as returning to the original state after the string is complete. Most terminal color libraries make you manage this yourself. .. image:: https://d3vv6lp55qjaqc.cloudfront.net/items/3q0I293q1z293R3a3a3n/Screen%20Shot%202017-01-23%20at%206.00.02%20PM.png?X-CloudApp-Visitor-Id=2577 Arguments include ``always=True`` and ``bold=True``. Features -------- - If you call ``disable()``, all future calls to colors will be ignored. - If you call ``normal()``, color is reset to default foreground color - If the current process is not in a TTY (e.g. being piped), no colors will be displayed. - Length of ColoredStrings can be properly calculated. - Powered by colorama. Usage is simple --------------- :: # red is red, white is white. >>> print('{} white'.format(crayons.red('red'))) red white That's it! Installation ------------ :: $ pip install crayons Platform: UNKNOWN Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy crayons-0.4.0/README.rst0000644000175100001640000000355013721552517015474 0ustar runnerdocker00000000000000Crayons: Text UI colors for Python. =================================== .. image:: https://img.shields.io/pypi/v/crayons.svg :target: https://pypi.org/project/crayons/ .. image:: https://github.com/MasterOdin/crayons/workflows/Test/badge.svg :target: https://github.com/MasterOdin/crayons/actions?query=workflow%3ATest+branch%3Amaster .. image:: https://img.shields.io/pypi/l/crayons.svg :target: https://pypi.python.org/pypi/crayons .. image:: https://img.shields.io/pypi/wheel/crayons.svg :target: https://pypi.python.org/pypi/crayons .. image:: https://img.shields.io/pypi/pyversions/crayons.svg :target: https://pypi.python.org/pypi/crayons This module is really simple, it gives you colored strings for terminal usage. Included colors are ``red``, ``green``, ``yellow``, ``blue``, ``black``, ``magenta``, ``cyan``, ``white``, and ``normal`` (as well as ``clean`` and ``disable``). **Crayons** is nice because it automatically wraps a given string in both the foreground color, as well as returning to the original state after the string is complete. Most terminal color libraries make you manage this yourself. .. image:: https://d3vv6lp55qjaqc.cloudfront.net/items/3q0I293q1z293R3a3a3n/Screen%20Shot%202017-01-23%20at%206.00.02%20PM.png?X-CloudApp-Visitor-Id=2577 Arguments include ``always=True`` and ``bold=True``. Features -------- - If you call ``disable()``, all future calls to colors will be ignored. - If you call ``normal()``, color is reset to default foreground color - If the current process is not in a TTY (e.g. being piped), no colors will be displayed. - Length of ColoredStrings can be properly calculated. - Powered by colorama. Usage is simple --------------- :: # red is red, white is white. >>> print('{} white'.format(crayons.red('red'))) red white That's it! Installation ------------ :: $ pip install crayons crayons-0.4.0/crayons.egg-info/0000755000175100001640000000000013721552524017150 5ustar runnerdocker00000000000000crayons-0.4.0/crayons.egg-info/PKG-INFO0000644000175100001640000000627113721552524020253 0ustar runnerdocker00000000000000Metadata-Version: 1.2 Name: crayons Version: 0.4.0 Summary: TextUI colors for Python. Home-page: https://github.com/MasterOdin/crayons Author: Kenneth Reitz Author-email: me@kennethreitz.com Maintainer: Matthew Peveler Maintainer-email: matt.peveler@gmail.com License: MIT Description: Crayons: Text UI colors for Python. =================================== .. image:: https://img.shields.io/pypi/v/crayons.svg :target: https://pypi.org/project/crayons/ .. image:: https://github.com/MasterOdin/crayons/workflows/Test/badge.svg :target: https://github.com/MasterOdin/crayons/actions?query=workflow%3ATest+branch%3Amaster .. image:: https://img.shields.io/pypi/l/crayons.svg :target: https://pypi.python.org/pypi/crayons .. image:: https://img.shields.io/pypi/wheel/crayons.svg :target: https://pypi.python.org/pypi/crayons .. image:: https://img.shields.io/pypi/pyversions/crayons.svg :target: https://pypi.python.org/pypi/crayons This module is really simple, it gives you colored strings for terminal usage. Included colors are ``red``, ``green``, ``yellow``, ``blue``, ``black``, ``magenta``, ``cyan``, ``white``, and ``normal`` (as well as ``clean`` and ``disable``). **Crayons** is nice because it automatically wraps a given string in both the foreground color, as well as returning to the original state after the string is complete. Most terminal color libraries make you manage this yourself. .. image:: https://d3vv6lp55qjaqc.cloudfront.net/items/3q0I293q1z293R3a3a3n/Screen%20Shot%202017-01-23%20at%206.00.02%20PM.png?X-CloudApp-Visitor-Id=2577 Arguments include ``always=True`` and ``bold=True``. Features -------- - If you call ``disable()``, all future calls to colors will be ignored. - If you call ``normal()``, color is reset to default foreground color - If the current process is not in a TTY (e.g. being piped), no colors will be displayed. - Length of ColoredStrings can be properly calculated. - Powered by colorama. Usage is simple --------------- :: # red is red, white is white. >>> print('{} white'.format(crayons.red('red'))) red white That's it! Installation ------------ :: $ pip install crayons Platform: UNKNOWN Classifier: License :: OSI Approved :: MIT License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.4 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: 3.6 Classifier: Programming Language :: Python :: 3.7 Classifier: Programming Language :: Python :: 3.8 Classifier: Programming Language :: Python :: Implementation :: CPython Classifier: Programming Language :: Python :: Implementation :: PyPy crayons-0.4.0/crayons.egg-info/SOURCES.txt0000644000175100001640000000031213721552524021030 0ustar runnerdocker00000000000000LICENSE README.rst crayons.py setup.cfg setup.py crayons.egg-info/PKG-INFO crayons.egg-info/SOURCES.txt crayons.egg-info/dependency_links.txt crayons.egg-info/requires.txt crayons.egg-info/top_level.txtcrayons-0.4.0/crayons.egg-info/dependency_links.txt0000644000175100001640000000000113721552524023216 0ustar runnerdocker00000000000000 crayons-0.4.0/crayons.egg-info/requires.txt0000644000175100001640000000001113721552524021540 0ustar runnerdocker00000000000000colorama crayons-0.4.0/crayons.egg-info/top_level.txt0000644000175100001640000000001013721552524021671 0ustar runnerdocker00000000000000crayons crayons-0.4.0/crayons.py0000644000175100001640000001077313721552517016042 0ustar runnerdocker00000000000000# -*- coding: utf-8 -*- """A simple and elegant wrapper for colorama.""" import os from random import choice, seed import re import sys import colorama PY3 = sys.version_info[0] >= 3 COLORS = ( 'red', 'green', 'yellow', 'blue', 'black', 'magenta', 'cyan', 'white' ) __all__ = COLORS + ( 'normal', 'clean', 'disable', 'enable', 'random', 'replace_colors', 'reset_replace_colors' ) colorama.init() REPLACE_COLORS = {} seed() if 'get_ipython' in dir(): """ when ipython is fired lot of variables like _oh, etc are used. There are so many ways to find current python interpreter is ipython. get_ipython is easiest is most appealing for readers to understand. """ DISABLE_COLOR = True else: DISABLE_COLOR = False if os.getenv("TERM") == "dumb": DISABLE_COLOR = True class ColoredString(object): """Enhanced string for __len__ operations on Colored output.""" def __init__(self, color, s, always_color=False, bold=False): super(ColoredString, self).__init__() if not PY3 and isinstance(s, unicode): # noqa: F821 self.s = s.encode('utf-8') else: self.s = str(s) self.color = REPLACE_COLORS.get(color, color) self.always_color = always_color self.bold = bold if os.environ.get('CLINT_FORCE_COLOR'): self.always_color = True def __getattr__(self, att): def func_help(*args, **kwargs): result = getattr(self.s, att)(*args, **kwargs) try: is_result_string = isinstance(result, basestring) except NameError: is_result_string = isinstance(result, str) if is_result_string: return self._new(result) elif isinstance(result, list): return [self._new(x) for x in result] else: return result return func_help @property def color_str(self): style = 'BRIGHT' if self.bold else 'NORMAL' c = '%s%s%s%s%s' % (getattr(colorama.Fore, self.color), getattr(colorama.Style, style), self.s, colorama.Fore.RESET, colorama.Style.NORMAL) if self.always_color: return c elif hasattr(sys.stdout, 'isatty') \ and sys.stdout.isatty() \ and not DISABLE_COLOR: return c 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, bytes): return value.decode('utf8') return value if PY3: __str__ = __unicode__ else: def __str__(self): return self.color_str 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 _new(self, s): return ColoredString(self.color, s) _colors = {x: x.upper() for x in COLORS} _colors['normal'] = 'RESET' for key, val in _colors.items(): function = eval( 'lambda s, always=False, bold=False: ColoredString("{}", s, always_color=always, bold=bold)'.format(val)) # noqa: E501 locals()[key] = function del key, val, _colors, function def clean(s): strip = re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]') txt = strip.sub('', s) return txt def random(string, always=False, bold=False, colors=COLORS): """Selects a color at random from a list.""" colors = list(filter(lambda color: color in COLORS, colors)) or COLORS return ColoredString( choice(colors).upper(), string, always_color=always, bold=bold ) def disable(): """Disables colors.""" global DISABLE_COLOR DISABLE_COLOR = True def enable(): """Enables colors.""" global DISABLE_COLOR DISABLE_COLOR = False def replace_colors(replace_dict): """Replace colors to customize the look under specific background.""" global REPLACE_COLORS assert isinstance(replace_dict, dict) REPLACE_COLORS = {k.upper(): v.upper() for k, v in replace_dict.items()} def reset_replace_colors(): """Reset any set replace colors.""" global REPLACE_COLORS REPLACE_COLORS = {} crayons-0.4.0/setup.cfg0000644000175100001640000000014713721552524015623 0ustar runnerdocker00000000000000[metadata] license_files = LICENSE [bdist_wheel] universal = 1 [egg_info] tag_build = tag_date = 0 crayons-0.4.0/setup.py0000644000175100001640000000304613721552517015517 0ustar runnerdocker00000000000000#!/usr/bin/env python # -*- coding: utf-8 -*- """setup script for module installation.""" import os import sys import codecs from setuptools import setup try: # Python 3 from os import dirname except ImportError: # Python 2 from os.path import dirname here = os.path.abspath(dirname(__file__)) with codecs.open(os.path.join(here, 'README.rst'), encoding='utf-8') as f: long_description = '\n' + f.read() if sys.argv[-1] == "publish": os.system("python setup.py sdist bdist_wheel upload") sys.exit() required = [ 'colorama', ] setup( name='crayons', version='0.4.0', description='TextUI colors for Python.', long_description=long_description, author='Kenneth Reitz', author_email='me@kennethreitz.com', maintainer='Matthew Peveler', maintainer_email='matt.peveler@gmail.com', url='https://github.com/MasterOdin/crayons', py_modules=['crayons'], install_requires=required, license='MIT', classifiers=[ 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy' ], )