Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-crontab for openSUSE:Factory checked in at 2021-08-28 22:29:12 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-crontab (Old) and /work/SRC/openSUSE:Factory/.python-crontab.new.1899 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-crontab" Sat Aug 28 22:29:12 2021 rev:3 rq:914697 version:0.23.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-crontab/python-crontab.changes 2019-09-30 15:58:27.821365964 +0200 +++ /work/SRC/openSUSE:Factory/.python-crontab.new.1899/python-crontab.changes 2021-08-28 22:29:28.057996461 +0200 @@ -1,0 +2,13 @@ +Mon Aug 23 12:52:40 UTC 2021 - John Paul Adrian Glaubitz <adrian.glaub...@suse.com> + +- Update to version 0.23.0 + * Bump version and copyright year + * Added early return option to next function that allows + returning timestamp of next occurence instead of delay. + * Fixed issue with comparing against None + * Update docstring of Crontab.__init__ + * Added compare + * Bump version + * Allow looping ranges + +------------------------------------------------------------------- Old: ---- crontab-0.22.6.tar.gz New: ---- crontab-0.23.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-crontab.spec ++++++ --- /var/tmp/diff_new_pack.L7FWiG/_old 2021-08-28 22:29:28.637997063 +0200 +++ /var/tmp/diff_new_pack.L7FWiG/_new 2021-08-28 22:29:28.641997068 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-crontab # -# 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-crontab -Version: 0.22.6 +Version: 0.23.0 Release: 0 Summary: Python module for parsing and using crontab schedules License: LGPL-2.1-only ++++++ crontab-0.22.6.tar.gz -> crontab-0.23.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parse-crontab-0.22.6/Makefile new/parse-crontab-0.23.0/Makefile --- old/parse-crontab-0.22.6/Makefile 2019-07-08 17:30:41.000000000 +0200 +++ new/parse-crontab-0.23.0/Makefile 2021-04-28 03:25:31.000000000 +0200 @@ -14,6 +14,9 @@ python3.4 -m tests.test_crontab python3.5 -m tests.test_crontab python3.6 -m tests.test_crontab + python3.7 -m tests.test_crontab + python3.8 -m tests.test_crontab + python3.9 -m tests.test_crontab upload: python3.6 setup.py sdist upload diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parse-crontab-0.22.6/README.rst new/parse-crontab-0.23.0/README.rst --- old/parse-crontab-0.22.6/README.rst 2019-07-08 17:30:41.000000000 +0200 +++ new/parse-crontab-0.23.0/README.rst 2021-04-28 03:25:31.000000000 +0200 @@ -1,5 +1,5 @@ -Copyright 2011-2016 Josiah Carlson +Copyright 2011-2021 Josiah Carlson Released under the LGPL license version 2.1 and version 3 (you can choose which you'd like to be bound under). diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parse-crontab-0.22.6/crontab/_crontab.py new/parse-crontab-0.23.0/crontab/_crontab.py --- old/parse-crontab-0.22.6/crontab/_crontab.py 2019-07-08 17:30:41.000000000 +0200 +++ new/parse-crontab-0.23.0/crontab/_crontab.py 2021-04-28 03:25:31.000000000 +0200 @@ -3,7 +3,7 @@ crontab.py Written July 15, 2011 by Josiah Carlson -Copyright 2011-2018 Josiah Carlson +Copyright 2011-2021 Josiah Carlson Released under the GNU LGPL v2.1 and v3 available: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html @@ -15,6 +15,7 @@ from collections import namedtuple from datetime import datetime, timedelta +import random import sys import warnings @@ -180,8 +181,15 @@ raise ValueError(message%args) class _Matcher(object): - __slots__ = 'allowed', 'end', 'any', 'input', 'which', 'split' - def __init__(self, which, entry): + __slots__ = 'allowed', 'end', 'any', 'input', 'which', 'split', 'loop' + def __init__(self, which, entry, loop=False): + """ + input: + `which` - index into the increment / validation lookup tables + `entry` - the value of the column + `loop` - do we loop when we validate / construct counts + (turning 55-5,1 -> 0,1,2,3,4,5,55,56,57,58,59 in a "minutes" column) + """ _assert(0 <= which <= YEAR_OFFSET, "improper number of cron entries specified") self.input = entry.lower() @@ -190,6 +198,7 @@ self.allowed = set() self.end = None self.any = '*' in self.split or '?' in self.split + self.loop = loop for it in self.split: al, en = self._parse_crontab(which, it) @@ -290,16 +299,23 @@ _assert(_start <= end <= _end_limit, "%s range end value %r out of range [%r, %r]", _attribute[which], end, _start, _end_limit) - _assert(start <= end, - "%s range start value %r > end value %r", - _attribute[which], start, end) + if not self.loop: + _assert(start <= end, + "%s range start value %r > end value %r", + _attribute[which], start, end) - if increment: + if increment and not self.loop: next_value = start + increment _assert(next_value <= _end_limit, "first next value %r is out of range [%r, %r]", next_value, start, _end_limit) - return set(range(start, end+1, increment or 1)) + + if start <= end: + return set(range(start, end+1, increment or 1)) + + right = set(range(end, _end_limit + 1, increment or 1)) + first = max(right, default=end + (increment or 1)) % _end_limit + return set(range(first, start+1, increment or 1)) | right _start, _end = _ranges[which] _end_limit = _end @@ -353,26 +369,45 @@ return good, _end +_gv = lambda: str(random.randrange(60)) + + class CronTab(object): - __slots__ = 'matchers', - def __init__(self, crontab): - self.matchers = self._make_matchers(crontab) + __slots__ = 'matchers', 'rs' + def __init__(self, crontab, loop=False, random_seconds=False): + """ + inputs: + `crontab` - crontab specification of "[S=0] Mi H D Mo DOW [Y=*]" + `loop` - do we loop when we validate / construct counts + (turning 55-5,1 -> 0,1,2,3,4,5,55,56,57,58,59 in a "minutes" column) + `random_seconds` - randomly select starting second for tasks + """ + self.rs = random_seconds + self.matchers = self._make_matchers(crontab, loop, random_seconds) - def _make_matchers(self, crontab): + def __eq__(self, other): + if not isinstance(other, CronTab): + return False + match_last = self.matchers[1:] == other.matchers[1:] + return match_last and ((self.rs and other.rs) or (not self.rs and + not other.rs and self.matchers[0] == other.matchers[0])) + + def _make_matchers(self, crontab, loop, random_seconds): ''' This constructs the full matcher struct. ''' crontab = _aliases.get(crontab, crontab) ct = crontab.split() + if len(ct) == 5: - ct.insert(0, '0') + ct.insert(0, _gv() if random_seconds else '0') ct.append('*') elif len(ct) == 6: - ct.insert(0, '0') + ct.insert(0, _gv() if random_seconds else '0') _assert(len(ct) == 7, "improper number of cron entries specified; got %i need 5 to 7"%(len(ct,))) - matchers = [_Matcher(which, entry) for which, entry in enumerate(ct)] + matchers = [_Matcher(which, entry, loop) for which, entry in enumerate(ct)] return Matcher(*matchers) @@ -387,7 +422,7 @@ attr = attr() % 7 return self.matchers[index](attr, dt) - def next(self, now=None, increments=_increments, delta=True, default_utc=WARN_CHANGE): + def next(self, now=None, increments=_increments, delta=True, default_utc=WARN_CHANGE, return_datetime=False): ''' How long to wait in seconds before this crontab entry can next be executed. @@ -444,6 +479,9 @@ "crontab: %r\n" \ "now: %r", ' '.join(m.input for m in self.matchers), now) + if return_datetime: + return future + if not delta: onow = now = datetime(1970, 1, 1) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parse-crontab-0.22.6/setup.py new/parse-crontab-0.23.0/setup.py --- old/parse-crontab-0.22.6/setup.py 2019-07-08 17:30:41.000000000 +0200 +++ new/parse-crontab-0.23.0/setup.py 2021-04-28 03:25:31.000000000 +0200 @@ -10,7 +10,7 @@ setup( name='crontab', - version='0.22.6', + version='0.23.0', description='Parse and use crontab schedules in Python', author='Josiah Carlson', author_email='josiah.carl...@gmail.com', @@ -29,6 +29,9 @@ '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 :: 3.9', ], license='GNU LGPL v2.1', long_description=long_description, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/parse-crontab-0.22.6/tests/test_crontab.py new/parse-crontab-0.23.0/tests/test_crontab.py --- old/parse-crontab-0.22.6/tests/test_crontab.py 2019-07-08 17:30:41.000000000 +0200 +++ new/parse-crontab-0.23.0/tests/test_crontab.py 2021-04-28 03:25:31.000000000 +0200 @@ -217,5 +217,13 @@ self.assertEqual(CronTab('30 1 * * * 2018').next(datetime.datetime(2018, 11, 4, 1, 15, tzinfo=timezone)), 900) self.assertEqual(CronTab('30 1 * * * 2018').next(datetime.datetime(2018, 11, 4, tzinfo=timezone)), 5400) + def test_equal(self): + a = CronTab("3 * 5 6 *") + b = CronTab("3 * 5 6 *") + self.assertEqual(a, b) + a = CronTab("3 * 5 6 *", random_seconds=True) + b = CronTab("3 * 5 6 *") + self.assertNotEqual(a, b) + if __name__ == '__main__': unittest.main()