mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-10 23:17:37 +01:00
Fix incorrect mod name fold in MinetestCheck
This commit is contained in:
parent
e6a7df6144
commit
a123f42291
@ -161,7 +161,7 @@ def updateMetaFromRelease(self, id, path):
|
|||||||
def getMetaPackages(names):
|
def getMetaPackages(names):
|
||||||
return [ MetaPackage.GetOrCreate(x, cache) for x in names ]
|
return [ MetaPackage.GetOrCreate(x, cache) for x in names ]
|
||||||
|
|
||||||
provides = getMetaPackages(tree.fold("name"))
|
provides = getMetaPackages(tree.getModNames())
|
||||||
|
|
||||||
package = release.package
|
package = release.package
|
||||||
package.provides.clear()
|
package.provides.clear()
|
||||||
@ -206,7 +206,7 @@ def getMeta(urlstr, author):
|
|||||||
|
|
||||||
result = {}
|
result = {}
|
||||||
result["name"] = tree.name
|
result["name"] = tree.name
|
||||||
result["provides"] = tree.fold("name")
|
result["provides"] = tree.getModNames()
|
||||||
result["type"] = tree.type.name
|
result["type"] = tree.type.name
|
||||||
|
|
||||||
for key in ["depends", "optional_depends"]:
|
for key in ["depends", "optional_depends"]:
|
||||||
|
@ -144,26 +144,38 @@ class PackageTreeNode:
|
|||||||
|
|
||||||
self.children.append(child)
|
self.children.append(child)
|
||||||
|
|
||||||
|
def getModNames(self):
|
||||||
|
return self.fold("name", type=ContentType.MOD)
|
||||||
|
|
||||||
def fold(self, attr, key=None, acc=None):
|
# attr: Attribute name
|
||||||
if acc is None:
|
# key: Key in attribute
|
||||||
acc = set()
|
# retval: Accumulator
|
||||||
|
# type: Filter to type
|
||||||
if self.meta is None:
|
def fold(self, attr, key=None, retval=None, type=None):
|
||||||
return acc
|
if retval is None:
|
||||||
|
retval = set()
|
||||||
at = getattr(self, attr)
|
|
||||||
value = at if key is None else at.get(key)
|
|
||||||
|
|
||||||
if isinstance(value, list):
|
|
||||||
acc |= set(value)
|
|
||||||
elif value is not None:
|
|
||||||
acc.add(value)
|
|
||||||
|
|
||||||
|
# Iterate through children
|
||||||
for child in self.children:
|
for child in self.children:
|
||||||
child.fold(attr, key, acc)
|
child.fold(attr, key, retval, type)
|
||||||
|
|
||||||
return acc
|
# Filter on type
|
||||||
|
if type and type != self.type:
|
||||||
|
return retval
|
||||||
|
|
||||||
|
# Get attribute
|
||||||
|
at = getattr(self, attr)
|
||||||
|
if not at:
|
||||||
|
return retval
|
||||||
|
|
||||||
|
# Get value
|
||||||
|
value = at if key is None else at.get(key)
|
||||||
|
if isinstance(value, list):
|
||||||
|
retval |= set(value)
|
||||||
|
elif value:
|
||||||
|
retval.add(value)
|
||||||
|
|
||||||
|
return retval
|
||||||
|
|
||||||
def get(self, key):
|
def get(self, key):
|
||||||
return self.meta.get(key)
|
return self.meta.get(key)
|
||||||
|
Loading…
Reference in New Issue
Block a user