Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-progress for openSUSE:Factory checked in at 2021-11-07 22:09:14 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-progress (Old) and /work/SRC/openSUSE:Factory/.python-progress.new.1890 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-progress" Sun Nov 7 22:09:14 2021 rev:2 rq:930002 version:1.6 Changes: -------- --- /work/SRC/openSUSE:Factory/python-progress/python-progress.changes 2019-04-05 12:00:51.974506162 +0200 +++ /work/SRC/openSUSE:Factory/.python-progress.new.1890/python-progress.changes 2021-11-07 22:09:25.687649758 +0100 @@ -1,0 +2,13 @@ +Sun Nov 7 18:16:16 UTC 2021 - Dirk M??ller <dmuel...@suse.com> + +- update to 1.6: + * Add help message to check_tty AttributeError + * ensure hidden cursor is reshown at exit. + * spinner: support formatted messages + * progress: avoid division by zero + * iter: expose the iteration value to the object + * Style change + * Add color support + * Use the formal form everywhere + +------------------------------------------------------------------- Old: ---- progress-1.5.tar.gz New: ---- progress-1.6.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-progress.spec ++++++ --- /var/tmp/diff_new_pack.GSibwL/_old 2021-11-07 22:09:26.151650172 +0100 +++ /var/tmp/diff_new_pack.GSibwL/_new 2021-11-07 22:09:26.155650176 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-progress # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2021 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-progress -Version: 1.5 +Version: 1.6 Release: 0 Summary: Progress bars for Python License: ISC ++++++ progress-1.5.tar.gz -> progress-1.6.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/LICENSE new/progress-1.6/LICENSE --- old/progress-1.5/LICENSE 2012-04-18 13:36:10.000000000 +0200 +++ new/progress-1.6/LICENSE 2020-07-20 14:40:32.000000000 +0200 @@ -1,4 +1,4 @@ -# Copyright (c) 2012 Giorgos Verigakis <veri...@gmail.com> +# Copyright (c) 2012 Georgios Verigakis <veri...@gmail.com> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/PKG-INFO new/progress-1.6/PKG-INFO --- old/progress-1.5/PKG-INFO 2019-03-06 08:26:18.000000000 +0100 +++ new/progress-1.6/PKG-INFO 2021-07-28 08:52:42.000000000 +0200 @@ -1,9 +1,9 @@ Metadata-Version: 1.1 Name: progress -Version: 1.5 +Version: 1.6 Summary: Easy to use progress bars Home-page: http://github.com/verigak/progress/ -Author: Giorgos Verigakis +Author: Georgios Verigakis Author-email: veri...@gmail.com License: ISC Description: Easy progress reporting for Python diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/progress/__init__.py new/progress-1.6/progress/__init__.py --- old/progress-1.5/progress/__init__.py 2019-03-06 08:25:08.000000000 +0100 +++ new/progress-1.6/progress/__init__.py 2021-07-28 08:50:43.000000000 +0200 @@ -1,4 +1,4 @@ -# Copyright (c) 2012 Giorgos Verigakis <veri...@gmail.com> +# Copyright (c) 2012 Georgios Verigakis <veri...@gmail.com> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -24,7 +24,7 @@ from time import time as monotonic -__version__ = '1.5' +__version__ = '1.6' HIDE_CURSOR = '\x1b[?25l' SHOW_CURSOR = '\x1b[?25h' @@ -46,14 +46,19 @@ for key, val in kwargs.items(): setattr(self, key, val) - self._width = 0 + self._max_width = 0 + self._hidden_cursor = False self.message = message if self.file and self.is_tty(): if self.hide_cursor: print(HIDE_CURSOR, end='', file=self.file) - print(self.message, end='', file=self.file) - self.file.flush() + self._hidden_cursor = True + self.writeln('') + + def __del__(self): + if self._hidden_cursor: + print(SHOW_CURSOR, end='', file=self.file) def __getitem__(self, key): if key.startswith('_'): @@ -85,31 +90,30 @@ def start(self): pass - def clearln(self): - if self.file and self.is_tty(): - print('\r\x1b[K', end='', file=self.file) - - def write(self, s): - if self.file and self.is_tty(): - line = self.message + s.ljust(self._width) - print('\r' + line, end='', file=self.file) - self._width = max(self._width, len(s)) - self.file.flush() - def writeln(self, line): if self.file and self.is_tty(): - self.clearln() - print(line, end='', file=self.file) + width = len(line) + if width < self._max_width: + # Add padding to cover previous contents + line += ' ' * (self._max_width - width) + else: + self._max_width = width + print('\r' + line, end='', file=self.file) self.file.flush() def finish(self): if self.file and self.is_tty(): print(file=self.file) - if self.hide_cursor: + if self._hidden_cursor: print(SHOW_CURSOR, end='', file=self.file) + self._hidden_cursor = False def is_tty(self): - return self.file.isatty() if self.check_tty else True + try: + return self.file.isatty() if self.check_tty else True + except AttributeError: + msg = "%s has no attribute 'isatty'. Try setting check_tty=False." % self + raise AttributeError(msg) def next(self, n=1): now = monotonic() @@ -120,10 +124,13 @@ self.update() def iter(self, it): + self.iter_value = None with self: for x in it: + self.iter_value = x yield x self.next() + del self.iter_value def __enter__(self): self.start() @@ -152,6 +159,8 @@ @property def progress(self): + if self.max == 0: + return 0 return min(1, self.index / self.max) @property @@ -171,7 +180,10 @@ except TypeError: pass + self.iter_value = None with self: for x in it: + self.iter_value = x yield x self.next() + del self.iter_value diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/progress/bar.py new/progress-1.6/progress/bar.py --- old/progress-1.5/progress/bar.py 2019-01-29 09:25:41.000000000 +0100 +++ new/progress-1.6/progress/bar.py 2020-07-20 14:39:58.000000000 +0200 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2012 Giorgos Verigakis <veri...@gmail.com> +# Copyright (c) 2012 Georgios Verigakis <veri...@gmail.com> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -19,6 +19,7 @@ import sys from . import Progress +from .colors import color class Bar(Progress): @@ -28,13 +29,14 @@ bar_suffix = '| ' empty_fill = ' ' fill = '#' + color = None def update(self): filled_length = int(self.width * self.progress) empty_length = self.width - filled_length message = self.message % self - bar = self.fill * filled_length + bar = color(self.fill * filled_length, fg=self.color) empty = self.empty_fill * empty_length suffix = self.suffix % self line = ''.join([message, self.bar_prefix, bar, empty, self.bar_suffix, @@ -74,7 +76,7 @@ nempty = self.width - nfull # Number of empty chars message = self.message % self - bar = self.phases[-1] * nfull + bar = color(self.phases[-1] * nfull, fg=self.color) current = self.phases[phase] if phase > 0 else '' empty = self.empty_fill * max(0, nempty - len(current)) suffix = self.suffix % self diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/progress/colors.py new/progress-1.6/progress/colors.py --- old/progress-1.5/progress/colors.py 1970-01-01 01:00:00.000000000 +0100 +++ new/progress-1.6/progress/colors.py 2020-07-20 14:31:21.000000000 +0200 @@ -0,0 +1,79 @@ +# -*- coding: utf-8 -*- + +# Copyright (c) 2020 Georgios Verigakis <veri...@gmail.com> +# +# Permission to use, copy, modify, and distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +from functools import partial + + +COLORS = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', + 'white') +STYLES = ('bold', 'faint', 'italic', 'underline', 'blink', 'blink2', + 'negative', 'concealed', 'crossed') + + +def color(s, fg=None, bg=None, style=None): + sgr = [] + + if fg: + if fg in COLORS: + sgr.append(str(30 + COLORS.index(fg))) + elif isinstance(fg, int) and 0 <= fg <= 255: + sgr.append('38;5;%d' % int(fg)) + else: + raise Exception('Invalid color "%s"' % fg) + + if bg: + if bg in COLORS: + sgr.append(str(40 + COLORS.index(bg))) + elif isinstance(bg, int) and 0 <= bg <= 255: + sgr.append('48;5;%d' % bg) + else: + raise Exception('Invalid color "%s"' % bg) + + if style: + for st in style.split('+'): + if st in STYLES: + sgr.append(str(1 + STYLES.index(st))) + else: + raise Exception('Invalid style "%s"' % st) + + if sgr: + prefix = '\x1b[' + ';'.join(sgr) + 'm' + suffix = '\x1b[0m' + return prefix + s + suffix + else: + return s + + +# Foreground shortcuts +black = partial(color, fg='black') +red = partial(color, fg='red') +green = partial(color, fg='green') +yellow = partial(color, fg='yellow') +blue = partial(color, fg='blue') +magenta = partial(color, fg='magenta') +cyan = partial(color, fg='cyan') +white = partial(color, fg='white') + +# Style shortcuts +bold = partial(color, style='bold') +faint = partial(color, style='faint') +italic = partial(color, style='italic') +underline = partial(color, style='underline') +blink = partial(color, style='blink') +blink2 = partial(color, style='blink2') +negative = partial(color, style='negative') +concealed = partial(color, style='concealed') +crossed = partial(color, style='crossed') diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/progress/counter.py new/progress-1.6/progress/counter.py --- old/progress-1.5/progress/counter.py 2018-09-13 09:08:24.000000000 +0200 +++ new/progress-1.6/progress/counter.py 2020-07-20 14:40:04.000000000 +0200 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2012 Giorgos Verigakis <veri...@gmail.com> +# Copyright (c) 2012 Georgios Verigakis <veri...@gmail.com> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -20,12 +20,16 @@ class Counter(Infinite): def update(self): - self.write(str(self.index)) + message = self.message % self + line = ''.join([message, str(self.index)]) + self.writeln(line) class Countdown(Progress): def update(self): - self.write(str(self.remaining)) + message = self.message % self + line = ''.join([message, str(self.remaining)]) + self.writeln(line) class Stack(Progress): @@ -34,7 +38,9 @@ def update(self): nphases = len(self.phases) i = min(nphases - 1, int(self.progress * nphases)) - self.write(self.phases[i]) + message = self.message % self + line = ''.join([message, self.phases[i]]) + self.writeln(line) class Pie(Stack): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/progress/spinner.py new/progress-1.6/progress/spinner.py --- old/progress-1.5/progress/spinner.py 2018-09-13 09:29:56.000000000 +0200 +++ new/progress-1.6/progress/spinner.py 2020-07-20 14:40:07.000000000 +0200 @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2012 Giorgos Verigakis <veri...@gmail.com> +# Copyright (c) 2012 Georgios Verigakis <veri...@gmail.com> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above @@ -24,7 +24,9 @@ def update(self): i = self.index % len(self.phases) - self.write(self.phases[i]) + message = self.message % self + line = ''.join([message, self.phases[i]]) + self.writeln(line) class PieSpinner(Spinner): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/progress.egg-info/PKG-INFO new/progress-1.6/progress.egg-info/PKG-INFO --- old/progress-1.5/progress.egg-info/PKG-INFO 2019-03-06 08:26:18.000000000 +0100 +++ new/progress-1.6/progress.egg-info/PKG-INFO 2021-07-28 08:52:42.000000000 +0200 @@ -1,9 +1,9 @@ Metadata-Version: 1.1 Name: progress -Version: 1.5 +Version: 1.6 Summary: Easy to use progress bars Home-page: http://github.com/verigak/progress/ -Author: Giorgos Verigakis +Author: Georgios Verigakis Author-email: veri...@gmail.com License: ISC Description: Easy progress reporting for Python diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/progress.egg-info/SOURCES.txt new/progress-1.6/progress.egg-info/SOURCES.txt --- old/progress-1.5/progress.egg-info/SOURCES.txt 2019-03-06 08:26:18.000000000 +0100 +++ new/progress-1.6/progress.egg-info/SOURCES.txt 2021-07-28 08:52:42.000000000 +0200 @@ -5,6 +5,7 @@ test_progress.py progress/__init__.py progress/bar.py +progress/colors.py progress/counter.py progress/spinner.py progress.egg-info/PKG-INFO diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/setup.py new/progress-1.6/setup.py --- old/progress-1.5/setup.py 2017-04-10 13:39:45.000000000 +0200 +++ new/progress-1.6/setup.py 2020-07-20 14:40:18.000000000 +0200 @@ -10,7 +10,7 @@ version=progress.__version__, description='Easy to use progress bars', long_description=open('README.rst').read(), - author='Giorgos Verigakis', + author='Georgios Verigakis', author_email='veri...@gmail.com', url='http://github.com/verigak/progress/', license='ISC', diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/progress-1.5/test_progress.py new/progress-1.6/test_progress.py --- old/progress-1.5/test_progress.py 2018-09-13 08:47:43.000000000 +0200 +++ new/progress-1.6/test_progress.py 2021-07-28 08:49:31.000000000 +0200 @@ -11,6 +11,7 @@ from progress.spinner import (Spinner, PieSpinner, MoonSpinner, LineSpinner, PixelSpinner) from progress.counter import Counter, Countdown, Stack, Pie +from progress.colors import bold def sleep(): @@ -20,9 +21,9 @@ for bar_cls in (Bar, ChargingBar, FillingSquaresBar, FillingCirclesBar): - suffix = '%(index)d/%(max)d [%(elapsed)d / %(eta)d / %(eta_td)s]' + suffix = '%(index)d/%(max)d [%(elapsed)d / %(eta)d / %(eta_td)s] (%(iter_value)s)' bar = bar_cls(bar_cls.__name__, suffix=suffix) - for i in bar.iter(range(200)): + for i in bar.iter(range(200, 400)): sleep() for bar_cls in (IncrementalBar, PixelBar, ShadyBar): @@ -32,8 +33,12 @@ bar.next() sleep() +bar = IncrementalBar(bold('Corolored'), color='green') +for i in bar.iter(range(200)): + sleep() + for spin in (Spinner, PieSpinner, MoonSpinner, LineSpinner, PixelSpinner): - for i in spin(spin.__name__ + ' ').iter(range(100)): + for i in spin(spin.__name__ + ' %(index)d ').iter(range(100)): sleep() for singleton in (Counter, Countdown, Stack, Pie):