Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
lx = lte if x1 == x2 else lt
ly = lte if y1 == y2 else lt
gx = gte if x1 == x2 else gt
gy = gte if x1 == x2 else gt
# Handle unbounded (>) specifiers.
def noop(x, y, z):
return True
if x1 == x2 and o1.startswith('>'):
lx = noop
if y1 == y2 and o2.startswith('>'):
ly = noop
# Check for overlap.
if (gte(x1, y1, True) and ly(x1, y2, True) or
gy(x2, y1, True) and ly(x2, y2, True) or
gte(y1, x1, True) and lx(y1, x2, True) or
gx(y2, x1, True) and lx(y2, x2, True)
):
return 0
if gte(y1, x2, True):
return 1
if gte(x1, y2, True):
return -1
raise AssertionError('Unexpected case comparing version ranges')
if x1 == x2 and o1.startswith('>'):
lx = noop
if y1 == y2 and o2.startswith('>'):
ly = noop
# Check for overlap.
if (gte(x1, y1, True) and ly(x1, y2, True) or
gy(x2, y1, True) and ly(x2, y2, True) or
gte(y1, x1, True) and lx(y1, x2, True) or
gx(y2, x1, True) and lx(y2, x2, True)
):
return 0
if gte(y1, x2, True):
return 1
if gte(x1, y2, True):
return -1
raise AssertionError('Unexpected case comparing version ranges')
gx = gte if x1 == x2 else gt
gy = gte if x1 == x2 else gt
# Handle unbounded (>) specifiers.
def noop(x, y, z):
return True
if x1 == x2 and o1.startswith('>'):
lx = noop
if y1 == y2 and o2.startswith('>'):
ly = noop
# Check for overlap.
if (gte(x1, y1, True) and ly(x1, y2, True) or
gy(x2, y1, True) and ly(x2, y2, True) or
gte(y1, x1, True) and lx(y1, x2, True) or
gx(y2, x1, True) and lx(y2, x2, True)
):
return 0
if gte(y1, x2, True):
return 1
if gte(x1, y2, True):
return -1
raise AssertionError('Unexpected case comparing version ranges')
def noop(x, y, z):
return True
if x1 == x2 and o1.startswith('>'):
lx = noop
if y1 == y2 and o2.startswith('>'):
ly = noop
# Check for overlap.
if (gte(x1, y1, True) and ly(x1, y2, True) or
gy(x2, y1, True) and ly(x2, y2, True) or
gte(y1, x1, True) and lx(y1, x2, True) or
gx(y2, x1, True) and lx(y2, x2, True)
):
return 0
if gte(y1, x2, True):
return 1
if gte(x1, y2, True):
return -1
raise AssertionError('Unexpected case comparing version ranges')