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 @@ def __init__(self, expr_format, start_time=None, ret_type=float, day_or=True): 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 @@ def _calc(self, now, expanded, is_prev): 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 @@ def proc_day_of_month(d): 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 @@ def proc_second(d): 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 @@ def _get_prev_nearest_diff(self, x, to_check, range_val): 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