Add violation to the list

parent 9f1b5af6
......@@ -39,6 +39,7 @@ class DetailedDependency(object):
self.status = ''
self.suite = ''
self.satisfied = ''
self.violation = ''
self.link = ''
self.debian_name = self.get_debian_name()
......@@ -219,8 +220,9 @@ class DetailedDependency(object):
# Perform comparison
status = True
status = version_satisfy_requirement(gem_requirement, debian_version)
status, violation = version_satisfy_requirement(gem_requirement, debian_version)
self.satisfied = status
self.violation = violation
def debian_status(self, jsoncontent={}):
'''
......
......@@ -44,6 +44,7 @@ def get_operator(requirement):
'''
Splits the operator and version from a requirement string.
'''
print requirement
if requirement == '':
return '>=', '0'
m = re.search("\d", requirement)
......@@ -122,24 +123,32 @@ def version_satisfy_requirement(requirements, input_version):
'''
status = True
for requirement in requirements:
violation = requirement
check, ver = get_operator(requirement)
input_version = LooseVersion(str(input_version))
ver = LooseVersion(str(ver))
status = False
if check == '=' and input_version == ver:
status = True
violation = None
elif check == '<=' and input_version <= ver:
status = True
violation = None
elif check == '<' and input_version < ver:
status = True
violation = None
elif check == '>' and input_version > ver:
status = True
violation = None
elif check == '>=' and input_version >= ver:
status = True
violation = None
elif check == '!=' and input_version != ver:
status = True
violation = None
elif check == '~>':
status = True
violation = None
input_version_int = input_version.version
ver_int = ver.version
n = min(len(input_version_int), len(ver_int)) - 1
......@@ -147,6 +156,7 @@ def version_satisfy_requirement(requirements, input_version):
while partcount < n:
if input_version_int[partcount] != ver_int[partcount]:
status = False
violation = requirement
break
partcount += 1
if partcount < len(input_version_int):
......@@ -155,14 +165,17 @@ def version_satisfy_requirement(requirements, input_version):
intver = ver_int[partcount]
if intdebver < intver:
status = False
violation = requirement
except:
if input_version_int[partcount] < ver_int[partcount]:
status = False
violation = requirement
else:
status = False
violation = requirement
if not status:
break
return status
return status, violation
def least_satisfiable_version(requirement, version_list):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment