Allow Sunday to be specified as weekday 7.

This commit is contained in:
Graham Bell 2012-08-10 17:25:49 -10:00
parent 0b534c4423
commit 1116146ee0

View file

@ -195,15 +195,18 @@ class _Matcher(object):
end = _end
if increment is None:
return set([start])
_assert(_start <= start <= _end,
"range start value %r out of range [%r, %r]", start, _start, _end)
_assert(_start <= end <= _end,
"range end value %r out of range [%r, %r]", end, _start, _end)
_assert(_start <= start <= _end_limit,
"range start value %r out of range [%r, %r]",
start, _start, _end_limit)
_assert(_start <= end <= _end_limit,
"range end value %r out of range [%r, %r]",
end, _start, _end_limit)
_assert(start <= end,
"range start value %r > end value %r", start, end)
return set(range(start, end+1, increment or 1))
_start, _end = _ranges[which]
_end_limit = _end
# wildcards
if entry in ('*', '?'):
if entry == '?':
@ -232,11 +235,20 @@ class _Matcher(object):
"you can only use positive increment values, you provided %r",
increment)
# allow Sunday to be specified as weekday 7
if which == 4:
_end_limit = 7
# handle all of the a,b,c and x-y,a,b entries
good = set()
for it in entry.split(','):
good.update(_parse_piece(it))
# change Sunday to weekday 0
if which == 4 and 7 in good:
good.discard(7)
good.add(0)
return good, _end
class CronTab(object):