Allow Sunday to be specified as weekday 7.
This commit is contained in:
parent
0b534c4423
commit
1116146ee0
1 changed files with 16 additions and 4 deletions
|
@ -195,15 +195,18 @@ class _Matcher(object):
|
||||||
end = _end
|
end = _end
|
||||||
if increment is None:
|
if increment is None:
|
||||||
return set([start])
|
return set([start])
|
||||||
_assert(_start <= start <= _end,
|
_assert(_start <= start <= _end_limit,
|
||||||
"range start value %r out of range [%r, %r]", start, _start, _end)
|
"range start value %r out of range [%r, %r]",
|
||||||
_assert(_start <= end <= _end,
|
start, _start, _end_limit)
|
||||||
"range end value %r out of range [%r, %r]", end, _start, _end)
|
_assert(_start <= end <= _end_limit,
|
||||||
|
"range end value %r out of range [%r, %r]",
|
||||||
|
end, _start, _end_limit)
|
||||||
_assert(start <= end,
|
_assert(start <= end,
|
||||||
"range start value %r > end value %r", start, end)
|
"range start value %r > end value %r", start, end)
|
||||||
return set(range(start, end+1, increment or 1))
|
return set(range(start, end+1, increment or 1))
|
||||||
|
|
||||||
_start, _end = _ranges[which]
|
_start, _end = _ranges[which]
|
||||||
|
_end_limit = _end
|
||||||
# wildcards
|
# wildcards
|
||||||
if entry in ('*', '?'):
|
if entry in ('*', '?'):
|
||||||
if entry == '?':
|
if entry == '?':
|
||||||
|
@ -232,11 +235,20 @@ class _Matcher(object):
|
||||||
"you can only use positive increment values, you provided %r",
|
"you can only use positive increment values, you provided %r",
|
||||||
increment)
|
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
|
# handle all of the a,b,c and x-y,a,b entries
|
||||||
good = set()
|
good = set()
|
||||||
for it in entry.split(','):
|
for it in entry.split(','):
|
||||||
good.update(_parse_piece(it))
|
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
|
return good, _end
|
||||||
|
|
||||||
class CronTab(object):
|
class CronTab(object):
|
||||||
|
|
Loading…
Reference in a new issue