]> git.lizzy.rs Git - cheatdb.git/commitdiff
Fix incorrect mod name fold in MinetestCheck
authorrubenwardy <rw@rubenwardy.com>
Sun, 12 Jul 2020 02:09:01 +0000 (03:09 +0100)
committerrubenwardy <rw@rubenwardy.com>
Sun, 12 Jul 2020 02:09:01 +0000 (03:09 +0100)
app/tasks/importtasks.py
app/tasks/minetestcheck/tree.py

index 0568949eba06587b1fd5a4fe69b026cc5acb87d9..1361afe384652b96c7b628956fa76406d721d552 100644 (file)
@@ -161,7 +161,7 @@ def updateMetaFromRelease(self, id, path):
                        def getMetaPackages(names):
                                return [ MetaPackage.GetOrCreate(x, cache) for x in names ]
 
-                       provides = getMetaPackages(tree.fold("name"))
+                       provides = getMetaPackages(tree.getModNames())
 
                        package = release.package
                        package.provides.clear()
@@ -206,7 +206,7 @@ def getMeta(urlstr, author):
 
        result = {}
        result["name"] = tree.name
-       result["provides"] = tree.fold("name")
+       result["provides"] = tree.getModNames()
        result["type"] = tree.type.name
 
        for key in ["depends", "optional_depends"]:
index d078545b31907d108fe78d51c2f2400f0375baaf..66dcbc8f8c0689641f8338b48187c8eee742f8eb 100644 (file)
@@ -144,26 +144,38 @@ class PackageTreeNode:
 
                                self.children.append(child)
 
+       def getModNames(self):
+               return self.fold("name", type=ContentType.MOD)
+
+       # attr: Attribute name
+       # key: Key in attribute
+       # retval: Accumulator
+       # type: Filter to type
+       def fold(self, attr, key=None, retval=None, type=None):
+               if retval is None:
+                       retval = set()
+
+               # Iterate through children
+               for child in self.children:
+                       child.fold(attr, key, retval, type)
 
-       def fold(self, attr, key=None, acc=None):
-               if acc is None:
-                       acc = set()
-
-               if self.meta is None:
-                       return acc
+               # Filter on type
+               if type and type != self.type:
+                       return retval
 
+               # Get attribute
                at = getattr(self, attr)
-               value = at if key is None else at.get(key)
+               if not at:
+                       return retval
 
+               # Get value
+               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)
-
-               for child in self.children:
-                       child.fold(attr, key, acc)
+                       retval |= set(value)
+               elif value:
+                       retval.add(value)
 
-               return acc
+               return retval
 
        def get(self, key):
                return self.meta.get(key)