Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _compare_ranges(spec1, spec2):
"""Test whether two version specs overlap.
Returns `None` if we cannot determine compatibility,
otherwise return 0 if there is an overlap, 1 if
spec1 is lower/older than spec2, and -1 if spec1
is higher/newer than spec2.
"""
# Test for overlapping semver ranges.
r1 = Range(spec1, True)
r2 = Range(spec2, True)
# If either range is empty, we cannot verify.
if not r1.range or not r2.range:
return
x1 = r1.set[0][0].semver
x2 = r1.set[0][-1].semver
y1 = r2.set[0][0].semver
y2 = r2.set[0][-1].semver
o1 = r1.set[0][0].operator
o2 = r2.set[0][0].operator
# We do not handle (<) specifiers.
if (o1.startswith('<') or o2.startswith('<')):
def _format_compatibility_errors(name, version, errors):
"""Format a message for compatibility errors.
"""
msgs = []
l0 = 10
l1 = 10
for error in errors:
pkg, jlab, ext = error
jlab = str(Range(jlab, True))
ext = str(Range(ext, True))
msgs.append((pkg, jlab, ext))
l0 = max(l0, len(pkg) + 1)
l1 = max(l1, len(jlab) + 1)
msg = '\n"%s@%s" is not compatible with the current JupyterLab'
msg = msg % (name, version)
msg += '\nConflicting Dependencies:\n'
msg += 'JupyterLab'.ljust(l0)
msg += 'Extension'.ljust(l1)
msg += 'Package\n'
for (pkg, jlab, ext) in msgs:
msg += jlab.ljust(l0) + ext.ljust(l1) + pkg + '\n'
return msg
def _format_compatibility_errors(name, version, errors):
"""Format a message for compatibility errors.
"""
msgs = []
l0 = 10
l1 = 10
for error in errors:
pkg, jlab, ext = error
jlab = str(Range(jlab, True))
ext = str(Range(ext, True))
msgs.append((pkg, jlab, ext))
l0 = max(l0, len(pkg) + 1)
l1 = max(l1, len(jlab) + 1)
msg = '\n"%s@%s" is not compatible with the current JupyterLab'
msg = msg % (name, version)
msg += '\nConflicting Dependencies:\n'
msg += 'JupyterLab'.ljust(l0)
msg += 'Extension'.ljust(l1)
msg += 'Package\n'
for (pkg, jlab, ext) in msgs:
msg += jlab.ljust(l0) + ext.ljust(l1) + pkg + '\n'
return msg
def _compare_ranges(spec1, spec2):
"""Test whether two version specs overlap.
Returns `None` if we cannot determine compatibility,
otherwise return 0 if there is an overlap, 1 if
spec1 is lower/older than spec2, and -1 if spec1
is higher/newer than spec2.
"""
# Test for overlapping semver ranges.
r1 = Range(spec1, True)
r2 = Range(spec2, True)
# If either range is empty, we cannot verify.
if not r1.range or not r2.range:
return
x1 = r1.set[0][0].semver
x2 = r1.set[0][-1].semver
y1 = r2.set[0][0].semver
y2 = r2.set[0][-1].semver
o1 = r1.set[0][0].operator
o2 = r2.set[0][0].operator
# We do not handle (<) specifiers.
if (o1.startswith('<') or o2.startswith('<')):
return