summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Crilly <mc@sent.com>2017-03-10 10:03:00 +1000
committerMichael Crilly <mc@sent.com>2017-03-10 10:03:00 +1000
commitde60aef84c4eee3f5dcd6ec3004a2d85db8a0dbf (patch)
tree325bfbc40c614e175aa09f574be353b6e4189817
parent4916e103b0840bf9b9059a655c4b1d376ce060d8 (diff)
downloadcroniter-de60aef84c4eee3f5dcd6ec3004a2d85db8a0dbf.tar.gz
Finding and fixing flake8 violations; adding flake8 as a test dep
-rw-r--r--requirements/test.txt1
-rw-r--r--src/croniter/croniter.py24
2 files changed, 15 insertions, 10 deletions
diff --git a/requirements/test.txt b/requirements/test.txt
index 369ab75..a9cbefe 100644
--- a/requirements/test.txt
+++ b/requirements/test.txt
@@ -5,3 +5,4 @@ tox>=2.4.1
coverage>=4.2
mock>=2.0.0 # For Python 2
coveralls
+flake8 \ No newline at end of file
diff --git a/src/croniter/croniter.py b/src/croniter/croniter.py
index 5dce8eb..7c16d40 100644
--- a/src/croniter/croniter.py
+++ b/src/croniter/croniter.py
@@ -63,7 +63,8 @@ class croniter(object):
bad_length = 'Exactly 5 or 6 columns has to be specified for iterator' \
'expression.'
- def __init__(self, expr_format, start_time=None, ret_type=float, day_or=True):
+ def __init__(self, expr_format, start_time=None, ret_type=float,
+ day_or=True):
self._ret_type = ret_type
self._day_or = day_or
@@ -120,19 +121,20 @@ class croniter(object):
low, high, step = map(int, [low, high, step])
e_list += range(low, high + 1, step)
# other solution
- #try:
+ # try:
# for j in xrange(int(low), int(high) + 1):
# if j % int(step) == 0:
# e_list.append(j)
- #except NameError:
+ # except NameError:
# for j in range(int(low), int(high) + 1):
# if j % int(step) == 0:
# e_list.append(j)
else:
if t.startswith('-'):
raise CroniterBadCronError(
- "[{0}] is not acceptable, negative numbers not allowed".format(
- expr_format))
+ "[{0}] is not acceptable,\
+ negative numbers not allowed".format(
+ expr_format))
if not star_or_int_re.search(t):
t = self._alphaconv(i, t)
@@ -275,7 +277,7 @@ class croniter(object):
offset = len(expanded) == 6 and 1 or 60
dst = now = self._timestamp_to_datetime(now + sign * offset)
- day, month, year = dst.day, dst.month, dst.year
+ month, year = dst.month, dst.year
current_year = now.year
DAYS = self.DAYS
@@ -306,7 +308,7 @@ class croniter(object):
days = DAYS[month - 1]
if month == 2 and self.is_leap(year) is True:
days += 1
- if 'l' in expanded[2] and days==d.day:
+ if 'l' in expanded[2] and days == d.day:
return False, d
if is_prev:
@@ -387,7 +389,7 @@ class croniter(object):
for proc in procs:
(changed, dst) = proc(dst)
if changed:
- day, month, year = dst.day, dst.month, dst.year
+ month, year = dst.month, dst.year
next = True
break
if next:
@@ -433,9 +435,11 @@ class croniter(object):
candidate = candidates[0]
for c in candidates:
# fixed: c < range_val
- # this code will reject all 31 day of month, 12 month, 59 second, 23 hour and so on.
+ # this code will reject all 31 day of month, 12 month, 59 second,
+ # 23 hour and so on.
# if candidates has just a element, this will not harmful.
- # but candidates have multiple elements, then values equal to range_val will rejected.
+ # but candidates have multiple elements, then values equal to
+ # range_val will rejected.
if c <= range_val:
candidate = c
break