From 96e67da70b43c911036cb2dd5a2a05b7e0a27095 Mon Sep 17 00:00:00 2001 From: Scott Bahling Date: Sat, 20 Feb 2016 20:24:51 +0100 Subject: Implement get_build_info and get_nothing_provides --- obsapi/core.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/obsapi/core.py b/obsapi/core.py index f1a27ed..e46e57f 100644 --- a/obsapi/core.py +++ b/obsapi/core.py @@ -351,6 +351,26 @@ class ObsApi(object): api = '/build/{}/{}/_buildconfig'.format(prj, repo) return self.get_xml(api) + def get_build_info(self, prj, pkg, repo, arch): + api = '/build/{}/{}/{}/{}/_buildinfo'.format(prj, repo, arch, pkg) + return self.get_xml(api) + + def get_nothing_provides(self, prj, pkg, repo, arch): + tree = etree.fromstring(self.get_build_info(prj, pkg, repo, arch)) + errors = (tree.xpath('error') or [EMPTY])[0] + nothing_provides = [] + + if errors is None or 'unresolvable' not in errors: + return nothing_provides + + for unresolvable in [u.strip() for + u in errors.split('unresolvable:')[1].split(',')]: + if unresolvable.startswith('nothing provides'): + nothing_provides.append(unresolvable.split( + 'nothing provides ')[1]) + + return nothing_provides + def get_vendor(self, prj, repo=None): ''' Attempt to get the value of the %vendor macro if exists Search build configs from all repos. Take first occurance. -- cgit v1.2.3