From f052eff527bdd666a302a0b93c57fcc7c07e076f Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Sun, 11 May 2014 23:29:50 +0300 Subject: [PATCH] obs: Implement get_srs function Implemented get_srs to get SRs from the project. Optionally SRs can be filtered by package and comma-separated list of statuses. Change-Id: If003f25e1d54742e13cd1c1d1418598ee4baea15 Signed-off-by: Ed Bartosh --- repa/obs.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/repa/obs.py b/repa/obs.py index be052e7..1dd8870 100644 --- a/repa/obs.py +++ b/repa/obs.py @@ -181,3 +181,27 @@ class OBS(OSC): """Set SR state.""" return core.change_request_state(self.apiurl, reqid, state, message=message, force=force) + + def get_srs(self, prj, states=None, pkg=None): + """ + Get SRs for the project (and package). + + Args: + prj (str): OBS project name + states (str): comma-separated list of states, e.g. 'new,accepted' + pkg (str): package name + + Yields: + id, state, description of found SRs + """ + query = 'view=collection&types=submit&project=%s' % prj + if states: + query += '&states=%s' % states + if pkg: + query += '&package=%s' % pkg + url = core.makeurl(self.apiurl, ['request'], query) + + root = ET.parse(self.core_http(core.http_GET, url)) + for sr in root.findall('request'): + yield sr.get('id'), sr.find('state').get('name'), \ + sr.find('description').text -- 2.34.1