Skip to content

Commit

Permalink
DRY per comments in #631
Browse files Browse the repository at this point in the history
Co-authored-by: Sawood Alam <ibnesayeed@gmail.com>
  • Loading branch information
machawk1 and ibnesayeed committed Mar 2, 2020
1 parent a603cf5 commit af4aa1f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions ipwb/replay.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,6 @@ def bin_search(iter, key, datetime=None):
ln = iter.readline()

surtk, datetimeK, rest = ln.split(maxsplit=2)
datetimeK = datetimeK.decode()

matchDegree = getMatchDegree(surt, datetime, surtk, datetimeK)
if matchDegree == MementoMatch.EXACTMATCH:
Expand All @@ -212,7 +211,6 @@ def bin_search(iter, key, datetime=None):
continue

surtk, datetimeK, rest = line.split(maxsplit=2)
datetimeK = datetimeK.decode()

surtk = surtk.rstrip(b"/")
key = key.rstrip(b"/")
Expand All @@ -226,7 +224,6 @@ def bin_search(iter, key, datetime=None):
while nextLine:
surtk, datetimeK, rest = nextLine.split(maxsplit=2)
surtk = surtk.rstrip(b"/")
datetimeK = datetimeK.decode()

matchDegree = getMatchDegree(key, datetime, surtk, datetimeK)
if matchDegree == MementoMatch.RIGHTKEYWRONGDATE:
Expand Down Expand Up @@ -259,6 +256,7 @@ def bin_search(iter, key, datetime=None):

def getMatchDegree(surt, datetime, surtK, datetimeK):
if surt == surtK:
datetimeK = datetimeK.decode()
if datetime is None or datetime is not None and datetime != datetimeK:
return MementoMatch.RIGHTKEYWRONGDATE
if datetime == datetimeK:
Expand Down

0 comments on commit af4aa1f

Please sign in to comment.