Skip to content

Commit

Permalink
simplify some code
Browse files Browse the repository at this point in the history
  • Loading branch information
kiorky committed Oct 31, 2024
1 parent c225319 commit dcd8b88
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/croniter/croniter.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,7 @@ def all_next(self, ret_type=None, start_time=None, update_current=None):
except CroniterBadDateError:
if self._max_years_btw_matches_explicitly_set:
return
else:
raise
raise

def all_prev(self, ret_type=None, start_time=None, update_current=None):
"""
Expand All @@ -479,8 +478,7 @@ def all_prev(self, ret_type=None, start_time=None, update_current=None):
except CroniterBadDateError:
if self._max_years_btw_matches_explicitly_set:
return
else:
raise
raise

def iter(self, *args, **kwargs):
return self._is_prev and self.all_prev or self.all_next
Expand Down Expand Up @@ -797,10 +795,7 @@ def _get_nth_weekday_of_month(year, month, day_of_week):

@staticmethod
def is_leap(year):
if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0):
return True
else:
return False
return bool(year % 400 == 0 or (year % 4 == 0 and year % 100 != 0))

@classmethod
def value_alias(cls, val, field_index, len_expressions=UNIX_CRON_LEN):
Expand Down Expand Up @@ -1121,8 +1116,7 @@ def expand(
if int(sys.version[0]) >= 3:
trace = _traceback.format_exc()
raise CroniterBadCronError(trace)
else:
raise CroniterBadCronError("{0}".format(exc))
raise CroniterBadCronError("{0}".format(exc))

@classmethod
def _get_low_from_current_date_number(cls, field_index, step, from_timestamp):
Expand Down Expand Up @@ -1157,8 +1151,7 @@ def is_valid(
cls.expand(expression, hash_id=hash_id, second_at_beginning=second_at_beginning)
except CroniterError:
return False
else:
return True
return True

@classmethod
def match(cls, cron_expression, testdate, day_or=True, second_at_beginning=False):
Expand Down

0 comments on commit dcd8b88

Please sign in to comment.