mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-27 18:26:15 +01:00
- get_request_list(): use new search interface
This commit is contained in:
parent
2e011e70d3
commit
52cac96f20
38
osc/core.py
38
osc/core.py
@ -2592,16 +2592,12 @@ def change_request_state(apiurl, reqid, newstate, message='', supersed=''):
|
|||||||
|
|
||||||
|
|
||||||
def get_request_list(apiurl, project, package, req_who='', req_state=('new',), req_type=None, exclude_target_projects=[]):
|
def get_request_list(apiurl, project, package, req_who='', req_state=('new',), req_type=None, exclude_target_projects=[]):
|
||||||
match = ''
|
xpath = ''
|
||||||
if not 'all' in req_state:
|
if not 'all' in req_state:
|
||||||
for state in req_state:
|
for state in req_state:
|
||||||
if len(match):
|
xpath = xpath_join(xpath, 'state/@name=\'%s\'' % state, inner=True)
|
||||||
match += ' or '
|
|
||||||
match += '(state/@name=\'%s\')' % quote_plus(state)
|
|
||||||
if req_who:
|
if req_who:
|
||||||
if len(match):
|
xpath = xpath_join(xpath, '(state/@who=\'%(who)s\' or history/@who=\'%(who)s\')' % {'who': req_who}, op='and')
|
||||||
match += ' and '
|
|
||||||
match += '(state/@who=\'%(who)s\' or history/@who=\'%(who)s\')' % {'who': quote_plus(req_who)}
|
|
||||||
|
|
||||||
# XXX: we cannot use the '|' in the xpath expression because it is not supported
|
# XXX: we cannot use the '|' in the xpath expression because it is not supported
|
||||||
# in the backend
|
# in the backend
|
||||||
@ -2611,33 +2607,25 @@ def get_request_list(apiurl, project, package, req_who='', req_state=('new',), r
|
|||||||
if package:
|
if package:
|
||||||
todo['package'] = package
|
todo['package'] = package
|
||||||
for kind, val in todo.iteritems():
|
for kind, val in todo.iteritems():
|
||||||
if len(match):
|
xpath = xpath_join(xpath, '(action/target/@%(kind)s=\'%(val)s\' or ' \
|
||||||
match += ' and '
|
'action/source/@%(kind)s=\'%(val)s\' or ' \
|
||||||
match += '(action/target/@%(kind)s=\'%(val)s\' or ' \
|
'submit/target/@%(kind)s=\'%(val)s\' or ' \
|
||||||
'action/source/@%(kind)s=\'%(val)s\' or ' \
|
'submit/source/@%(kind)s=\'%(val)s\')' % {'kind': kind, 'val': val}, op='and')
|
||||||
'submit/target/@%(kind)s=\'%(val)s\' or ' \
|
|
||||||
'submit/source/@%(kind)s=\'%(val)s\')' % {'kind': kind, 'val': val}
|
|
||||||
if req_type:
|
if req_type:
|
||||||
if len(match):
|
xpath = xpath_join(xpath, 'action/@type=\'%s\'' % req_type, op='and')
|
||||||
match += ' and '
|
|
||||||
match += '(action/@type=\'%s\')' % req_type
|
|
||||||
for i in exclude_target_projects:
|
for i in exclude_target_projects:
|
||||||
if len(match):
|
xpath = xpath_join(xpath, '(not(action/target/@project=\'%(prj)s\' or ' \
|
||||||
match += ' and '
|
'submit/target/@project=\'%(prj)s\'))' % {'prj': i}, op='and')
|
||||||
match += '(not(action/target/@project=\'%(prj)s\' or ' \
|
|
||||||
'submit/target/@project=\'%(prj)s\'))' % {'prj': quote_plus(i)}
|
|
||||||
|
|
||||||
if conf.config['verbose'] > 1:
|
if conf.config['verbose'] > 1:
|
||||||
print '[ %s ]' % match
|
print '[ %s ]' % xpath
|
||||||
u = makeurl(apiurl, ['search', 'request'], ['match=%s' % match.replace(' ', '%20')])
|
res = search(apiurl, request=xpath)
|
||||||
f = http_GET(u)
|
collection = res['request']
|
||||||
collection = ET.parse(f).getroot()
|
|
||||||
requests = []
|
requests = []
|
||||||
for root in collection.findall('request'):
|
for root in collection.findall('request'):
|
||||||
r = Request()
|
r = Request()
|
||||||
r.read(root)
|
r.read(root)
|
||||||
requests.append(r)
|
requests.append(r)
|
||||||
|
|
||||||
return requests
|
return requests
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user