Skip to content

Commit

Permalink
Partially revert "Fix hashed expressions omitting some entries"
Browse files Browse the repository at this point in the history
Another better fix is coming

This reverts commit 1904782.
  • Loading branch information
kiorky committed Jul 18, 2024
1 parent 7f63f97 commit 83aadb8
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/croniter/croniter.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,20 +1012,15 @@ def __init__(self, cronit):

def do(self, idx, hash_type="h", hash_id=None, range_end=None, range_begin=None):
"""Return a hashed/random integer given range/hash information"""
hours_or_minutes = idx in {0, 1}
if range_end is None:
range_end = self.cron.RANGES[idx][1]
if hours_or_minutes:
range_end += 1
if range_begin is None:
range_begin = self.cron.RANGES[idx][0]
if hash_type == 'r':
crc = random.randint(0, 0xFFFFFFFF)
else:
crc = binascii.crc32(hash_id) & 0xFFFFFFFF
if not hours_or_minutes:
return ((crc >> idx) % (range_end - range_begin + 1)) + range_begin
return ((crc >> idx) % (range_end - range_begin)) + range_begin
return ((crc >> idx) % (range_end - range_begin + 1)) + range_begin

def match(self, efl, idx, expr, hash_id=None, **kw):
return hash_expression_re.match(expr)
Expand Down

0 comments on commit 83aadb8

Please sign in to comment.