Commit 19b5e630 authored by Sandro Knauß's avatar Sandro Knauß Committed by Zen Fu
Browse files

Parse additional constrains.

parent e0c83c15
......@@ -26,7 +26,8 @@ pip:
celery:
url: https://github.com/celery/celery
django:
additional_condition: <2.0
additional_condition:
- <2.0
url: https://github.com/django/django
django-appconf:
url: https://github.com/django-compressor/django-appconf
......
......@@ -33,24 +33,36 @@ class Dependency:
line = line[:line.find(";")].strip()
self.dep = line
first = True
self.constrains=[]
self.constrains=set()
if split:
for part in line.split(","):
m = re.match(r"^(?P<name>[^!=<>]*)\s*((?P<constrain>[!=<>~]+)\s*(?P<version>[0-9][0-9\.]*))?\s*$", part)
m = re.match(r"^(?P<name>[^!=<>]*)\s*(?P<constrains>[!=<>~0-9ab\.dev,]+)?\s*$", part)
if first:
self.name = m.group("name")
first = False
if m.group("constrain"):
self.constrains.append((m.group("constrain"), m.group("version")))
if m.group("constrains"):
for i in self.parse_constrains(m.group("constrains")):
self.constrains.add(i)
else:
m = re.match(r"^(?P<name>[^!=<>]*)\s*(?P<constrains>\((([!=<>~]+)?\s*([0-9][0-9ab\.]*|dev),?)+\))?\s*$", line)
m = re.match(r"^(?P<name>[^!=<>]*)\s*(?P<constrains>\([!=<>~0-9ab\.dev,]+\))?\s*$", line)
self.name = m.group("name")
if m.group("constrains"):
for part in m.group("constrains")[1:-1].split(","):
n = re.match(r"^(?P<constrain>[!=<>~]+)\s*(?P<version>[0-9][0-9ab\.]*|dev)$", part.strip())
self.constrains.append((n.group("constrain"), n.group("version")))
for i in self.parse_constrains(m.group("constrains")[1:-1]):
self.constrains.add(i)
self.name = self.name.lower().strip().replace("_","-")
if self.name in self.config:
if "additional_condition" in self.config[self.name]:
for i in self.config[self.name]["additional_condition"]:
for j in self.parse_constrains(i):
self.constrains.add(j)
def parse_constrains(self, constrains):
for part in constrains.split(","):
n = re.match(r"^(?P<constrain>[!=<>~]+)\s*(?P<version>[0-9][0-9ab\.]*|dev)$", part.strip())
yield (n.group("constrain"), n.group("version"))
def pypi(self):
if self._pypi:
......@@ -90,6 +102,9 @@ class Dependency:
elif c == "<=":
if not Version(version.upstream_version) <= Version(v):
return False
elif c == "<":
if not Version(version.upstream_version) < Version(v):
return False
elif c == "!=":
if not Version(version.upstream_version) != Version(v):
return False
......@@ -121,7 +136,12 @@ class Dependency:
@property
def newest_pip_version(self):
return self.pypi()['info']['version']
pipy_version = self.pypi()['info']['version']
if not self.match(Version(pipy_version)):
versions = filter(lambda i: self.match(Version(i)),self.pypi()['releases'].keys())
sorted_versions = sorted(versions,key=lambda i:Version(i), reverse=True)
return sorted_versions[0]
return pipy_version
@property
def tag(self):
......@@ -294,7 +314,7 @@ def main():
b = repo.commit("weblate-{}".format(args.weblate_version)).tree/"requirements.txt"
b.stream_data(output)
config = yaml.safe_load(pathlib.Path(__file__).with_name("override.yaml").open())
config = yaml.safe_load(pathlib.Path(__file__).with_name("override.yaml").open())
SKIP_LIST = set(config.get('skip'))
PIP_ONLY = set(config.get('require_pip'))
......
Supports Markdown
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