Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix wrap-range bug

  • Loading branch information...
commit 867a130a94f27c7913ab9d59e5dc24606d7848ba 1 parent 5c4edcd
@ericpruitt authored U-icebox\User committed
View
3  CHANGELOG
@@ -1,5 +1,8 @@
CHANGELOG
+2010.12.07; Tuesday
+ Fixed bug in which wrap-around ranges sometimes skip values.
+
2010.11.29; Monday
Flawed implementation of the day of the week / day of the month changed
made on 2010.11.15 corrected and "test_dom_either_or_dow" made more
View
3  README.markdown
@@ -26,7 +26,7 @@ Examples
>>> job.check_trigger((2010, 5, 2, 1, 0), utc_offset=-6)
True
-### Simple user-space cron in less than ten lines: ###
+### Simple cron scheduler in less than ten lines: ###
import time
import os
@@ -40,4 +40,3 @@ Examples
os.system(job.comment)
time.sleep(60)
-
View
8 cronex.py
@@ -345,10 +345,8 @@ def parse_atom(parse, minmax):
return set(xrange(prefix, suffix + 1, increment))
else:
# Example: 12-4/2; (12, 12 + n, ..., 12 + m*n) U (n_0, ..., 4)
- top = xrange(prefix, minmax[1] + 1, increment)
- ceilvalue = increment - (minmax[1] - top[-1] - 1)
- bottom = set(xrange(ceilvalue - minmax[0], suffix + 1, increment))
- bottom.update(top)
- return bottom
+ noskips = list(xrange(prefix, minmax[1] + 1))
+ noskips+= list(xrange(minmax[0], suffix + 1))
+ return set(noskips[::increment])
else:
raise ValueError("Atom \"%s\" not in a recognized format." % parse )
View
3  test/test_cronex.py
@@ -99,7 +99,8 @@ def test_parse_atom(self):
(('11-5/3',(1,14)),set([11, 14, 3])),
(('*',(1, 100)), set(xrange(1,101))),
(('*/5',(1,100)), set(xrange(1,101,5))),
- (('666',(1,1000)), set([666]))]
+ (('666',(1,1000)), set([666])),
+ (('21-1',(0,23)), set([21,22,23,0,1]))]
for give_the_function, want_from_function in input_expect:
self.assertEqual(want_from_function,
Please sign in to comment.
Something went wrong with that request. Please try again.