Add meta package selector

This commit is contained in:
rubenwardy
2018-05-27 20:15:35 +01:00
parent 5e4613a6ef
commit 82159d488d
7 changed files with 163 additions and 28 deletions

View File

@@ -414,6 +414,19 @@ class MetaPackage(db.Model):
def ListToSpec(list):
return ",".join([str(x) for x in list])
@staticmethod
def GetOrCreate(name, cache={}):
mp = cache.get(name)
if mp is None:
mp = MetaPackage.query.filter_by(name=name).first()
if mp is None:
mp = MetaPackage(name)
db.session.add(mp)
cache[name] = mp
return mp
@staticmethod
def SpecToList(spec, cache={}):
retval = []
@@ -430,16 +443,7 @@ class MetaPackage(db.Model):
if not pattern.match(x):
continue
mp = cache.get(x)
if mp is None:
mp = MetaPackage.query.filter_by(name=x).first()
if mp is None:
mp = MetaPackage(x)
db.session.add(mp)
cache[x] = mp
retval.append(mp)
retval.append(MetaPackage.GetOrCreate(x, cache))
return retval