1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-01-12 08:56:13 +01:00

Fix core.get_package_results() to obey 'multibuild_packages' argument

This commit is contained in:
Daniel Mach 2024-06-17 17:56:24 +02:00
parent 5b0fbc43b0
commit 673907ea9f

View File

@ -4164,9 +4164,9 @@ def get_results(apiurl: str, project: str, package: str, verbose=False, printJoi
return r
def get_package_results(apiurl: str, project: str, package: Optional[str] = None, wait=False, *args, **kwargs):
def get_package_results(apiurl: str, project: str, package: Optional[str] = None, wait=False, multibuild_packages: Optional[List[str]] = None, *args, **kwargs):
"""generator that returns a the package results as an xml structure"""
xml = ''
xml = b''
waiting_states = ('blocked', 'scheduled', 'dispatching', 'building',
'signing', 'finished')
while True:
@ -4199,6 +4199,33 @@ def get_package_results(apiurl: str, project: str, package: Optional[str] = None
waiting = True
break
# filter the result according to the specified multibuild_packages (flavors)
if multibuild_packages:
for result in list(root):
for status in list(result):
package = status.attrib["package"]
package_flavor = package.rsplit(":", 1)
# package has flavor, check if the flavor is in multibuild_packages
flavor_match = len(package_flavor) == 2 and package_flavor[1] in multibuild_packages
# package nas no flavor, check if "" is in multibuild_packages
no_flavor_match = len(package_flavor) == 1 and "" in multibuild_packages
if not flavor_match and not no_flavor_match:
# package doesn't match multibuild_packages, remove the corresponding <status> from <result>
result.remove(status)
# remove empty <result> from <resultlist>
if len(result) == 0:
root.remove(result)
if len(root) == 0:
break
xmlindent(root)
xml = ET.tostring(root)
if not wait or not waiting:
break
else: