Hello community, here is the log from the commit of package python-crayons for openSUSE:Factory checked in at 2019-03-05 12:23:57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-crayons (Old) and /work/SRC/openSUSE:Factory/.python-crayons.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-crayons" Tue Mar 5 12:23:57 2019 rev:3 rq:681480 version:0.2.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-crayons/python-crayons.changes 2018-05-15 10:33:25.448139354 +0200 +++ /work/SRC/openSUSE:Factory/.python-crayons.new.28833/python-crayons.changes 2019-03-05 12:23:59.968865627 +0100 @@ -1,0 +2,8 @@ +Mon Mar 4 14:43:50 UTC 2019 - Ondřej Súkup <mimi...@gmail.com> + +- update to 0.2.0 + * Add crayons.enable() + * color funcs generated from __all__ var + * Disable colors on TERM=dumb + +------------------------------------------------------------------- Old: ---- crayons-0.1.2.tar.gz New: ---- crayons-0.2.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-crayons.spec ++++++ --- /var/tmp/diff_new_pack.SOcu4i/_old 2019-03-05 12:24:00.488865468 +0100 +++ /var/tmp/diff_new_pack.SOcu4i/_new 2019-03-05 12:24:00.492865466 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-crayons # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,22 +12,22 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-crayons -Version: 0.1.2 +Version: 0.2.0 Release: 0 Summary: Colored strings for terminal usage License: MIT -Url: https://github.com/kennethreitz/httpbin Group: Development/Languages/Python +Url: https://github.com/kennethreitz/httpbin Source: https://files.pythonhosted.org/packages/source/c/crayons/crayons-%{version}.tar.gz Source1: LICENSE -BuildRequires: python-rpm-macros BuildRequires: %{python_module setuptools} +BuildRequires: python-rpm-macros Requires: python-colorama BuildArch: noarch %python_subpackages @@ -44,11 +44,9 @@ %install %python_install - %files %{python_files} %license LICENSE %doc README.rst %{python_sitelib}/* - %changelog ++++++ crayons-0.1.2.tar.gz -> crayons-0.2.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crayons-0.1.2/PKG-INFO new/crayons-0.2.0/PKG-INFO --- old/crayons-0.1.2/PKG-INFO 2017-01-24 03:41:20.000000000 +0100 +++ new/crayons-0.2.0/PKG-INFO 2019-02-21 14:36:19.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: crayons -Version: 0.1.2 +Version: 0.2.0 Summary: TextUI colors for Python. Home-page: https://github.com/kennethreitz/crayons Author: Kenneth Reitz @@ -28,12 +28,21 @@ This module is really simple, it gives you colored strings for terminal - usage. Included colors are ``red``, ``green``, ``yellow``, ``blue``, ``black``, ``magenta``, ``magenta``, ``cyan``, ``white``, ``clean``, and ``disable``. + 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. @@ -44,7 +53,7 @@ :: # red is red, white is white. - >>> print '{red} white'.format(red=crayons.red('red')) + >>> print '{} white'.format(crayons.red('red')) red white That's it! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crayons-0.1.2/README.rst new/crayons-0.2.0/README.rst --- old/crayons-0.1.2/README.rst 2017-01-24 03:41:01.000000000 +0100 +++ new/crayons-0.2.0/README.rst 2019-02-21 14:35:22.000000000 +0100 @@ -19,12 +19,21 @@ This module is really simple, it gives you colored strings for terminal -usage. Included colors are ``red``, ``green``, ``yellow``, ``blue``, ``black``, ``magenta``, ``magenta``, ``cyan``, ``white``, ``clean``, and ``disable``. +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. @@ -35,7 +44,7 @@ :: # red is red, white is white. - >>> print '{red} white'.format(red=crayons.red('red')) + >>> print '{} white'.format(crayons.red('red')) red white That's it! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crayons-0.1.2/crayons.egg-info/PKG-INFO new/crayons-0.2.0/crayons.egg-info/PKG-INFO --- old/crayons-0.1.2/crayons.egg-info/PKG-INFO 2017-01-24 03:41:20.000000000 +0100 +++ new/crayons-0.2.0/crayons.egg-info/PKG-INFO 2019-02-21 14:36:19.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: crayons -Version: 0.1.2 +Version: 0.2.0 Summary: TextUI colors for Python. Home-page: https://github.com/kennethreitz/crayons Author: Kenneth Reitz @@ -28,12 +28,21 @@ This module is really simple, it gives you colored strings for terminal - usage. Included colors are ``red``, ``green``, ``yellow``, ``blue``, ``black``, ``magenta``, ``magenta``, ``cyan``, ``white``, ``clean``, and ``disable``. + 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. @@ -44,7 +53,7 @@ :: # red is red, white is white. - >>> print '{red} white'.format(red=crayons.red('red')) + >>> print '{} white'.format(crayons.red('red')) red white That's it! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crayons-0.1.2/crayons.py new/crayons-0.2.0/crayons.py --- old/crayons-0.1.2/crayons.py 2017-01-20 01:26:11.000000000 +0100 +++ new/crayons-0.2.0/crayons.py 2019-02-21 14:35:22.000000000 +0100 @@ -12,16 +12,17 @@ import re import sys -PY3 = sys.version_info[0] >= 3 - import colorama +PY3 = sys.version_info[0] >= 3 + __all__ = ( 'red', 'green', 'yellow', 'blue', 'black', 'magenta', 'cyan', 'white', - 'clean', 'disable' + 'clean', 'disable', 'enable' ) +colorama.init() COLORS = __all__[:-2] if 'get_ipython' in dir(): @@ -34,6 +35,8 @@ else: DISABLE_COLOR = False +if os.getenv("TERM") == "dumb": + DISABLE_COLOR = True class ColoredString(object): """Enhanced string for __len__ operations on Colored output.""" @@ -67,7 +70,11 @@ @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, getattr(colorama.Style, 'NORMAL')) + c = '%s%s%s%s%s' % (getattr(colorama.Fore, self.color), + getattr(colorama.Style, style), + self.s, + colorama.Fore.RESET, + getattr(colorama.Style, 'NORMAL')) if self.always_color: return c @@ -76,7 +83,6 @@ else: return self.s - def __len__(self): return len(self.s) @@ -112,7 +118,7 @@ def clean(s): - strip = re.compile("([^-_a-zA-Z0-9!@#%&=,/'\";:~`\$\^\*\(\)\+\[\]\.\{\}\|\?\<\>\\]+|[^\s]+)") + strip = re.compile(r"([^-_a-zA-Z0-9!@#%&=,/'\";:~`\$\^\*\(\)\+\[\]\.\{\}\|\?\<\>\\]+|[^\s]+)") txt = strip.sub('', str(s)) strip = re.compile(r'\[\d+m') @@ -120,33 +126,24 @@ return txt +_colors = {x: x.upper() for x in __all__[:-3]} +_colors['normal'] = 'RESET' -def black(string, always=False, bold=False): - return ColoredString('BLACK', string, always_color=always, bold=bold) - -def red(string, always=False, bold=False): - return ColoredString('RED', string, always_color=always, bold=bold) - -def green(string, always=False, bold=False): - return ColoredString('GREEN', string, always_color=always, bold=bold) +for key, val in _colors.items(): + function = eval( + 'lambda s, always=False, bold=False: ColoredString("{}", s, always_color=always, bold=bold)'.format(val)) + locals()[key] = function -def yellow(string, always=False, bold=False): - return ColoredString('YELLOW', string, always_color=always, bold=bold) - -def blue(string, always=False, bold=False): - return ColoredString('BLUE', string, always_color=always, bold=bold) - -def magenta(string, always=False, bold=False): - return ColoredString('MAGENTA', string, always_color=always, bold=bold) - -def cyan(string, always=False, bold=False): - return ColoredString('CYAN', string, always_color=always, bold=bold) - -def white(string, always=False, bold=False): - return ColoredString('WHITE', string, always_color=always, bold=bold) +del key, val, _colors, function def disable(): """Disables colors.""" global DISABLE_COLOR DISABLE_COLOR = True + +def enable(): + """Enables colors.""" + global DISABLE_COLOR + + DISABLE_COLOR = False diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crayons-0.1.2/setup.cfg new/crayons-0.2.0/setup.cfg --- old/crayons-0.1.2/setup.cfg 2017-01-24 03:41:20.000000000 +0100 +++ new/crayons-0.2.0/setup.cfg 2019-02-21 14:36:19.000000000 +0100 @@ -1,5 +1,4 @@ [egg_info] tag_build = tag_date = 0 -tag_svn_revision = 0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/crayons-0.1.2/setup.py new/crayons-0.2.0/setup.py --- old/crayons-0.1.2/setup.py 2017-01-24 03:40:18.000000000 +0100 +++ new/crayons-0.2.0/setup.py 2019-02-21 14:35:36.000000000 +0100 @@ -30,7 +30,7 @@ setup( name='crayons', - version='0.1.2', + version='0.2.0', description='TextUI colors for Python.', long_description=long_description, author='Kenneth Reitz',