mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-28 10:46:15 +01:00
split the formating rules from get_results
The osc.core.get_results parses the xml and also construct the status field in little bit complicate way. For future csv support it is necessary split the xml parsing and formatting to two functions: * get_package_results - returns a dict containing all important elements * get_results - behave as old implementation, just do a formating only
This commit is contained in:
parent
ebc341e7b1
commit
b17405d9d0
35
osc/core.py
35
osc/core.py
@ -3483,9 +3483,9 @@ def show_prj_results_meta(apiurl, prj):
|
|||||||
return f.readlines()
|
return f.readlines()
|
||||||
|
|
||||||
|
|
||||||
def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[]):
|
def get_package_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[]):
|
||||||
|
""" return a package results as a list of dicts """
|
||||||
r = []
|
r = []
|
||||||
result_line_templ = '%(rep)-20s %(arch)-10s %(status)s'
|
|
||||||
|
|
||||||
f = show_results_meta(apiurl, prj, package, lastbuild, repository, arch)
|
f = show_results_meta(apiurl, prj, package, lastbuild, repository, arch)
|
||||||
root = ET.fromstring(''.join(f))
|
root = ET.fromstring(''.join(f))
|
||||||
@ -3500,21 +3500,32 @@ def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[]):
|
|||||||
rmap['dirty'] = node.get('dirty')
|
rmap['dirty'] = node.get('dirty')
|
||||||
|
|
||||||
statusnode = node.find('status')
|
statusnode = node.find('status')
|
||||||
try:
|
rmap['code'] = statusnode.get('code') if 'code' in statusnode.keys() else ''
|
||||||
rmap['status'] = statusnode.get('code')
|
rmap['details'] = ''
|
||||||
except:
|
|
||||||
# code can be missing when package is too new:
|
|
||||||
rmap['status'] = ''
|
|
||||||
|
|
||||||
if rmap['status'] in ['expansion error', 'broken', 'blocked', 'finished']:
|
if rmap['code'] in ('expansion error', 'broken', 'blocked', 'finished'):
|
||||||
details = statusnode.find('details')
|
details = statusnode.find('details')
|
||||||
if details != None:
|
if details != None:
|
||||||
rmap['status'] += ': ' + details.text
|
rmap['details'] = details.text
|
||||||
|
|
||||||
if rmap['dirty'] == 'true':
|
rmap['dirty'] = rmap['dirty'] == 'true'
|
||||||
rmap['status'] = 'state is outdated (was: %s)' % rmap['status']
|
|
||||||
|
r.append(rmap)
|
||||||
|
return r
|
||||||
|
|
||||||
|
def get_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[]):
|
||||||
|
r = []
|
||||||
|
result_line_templ = '%(rep)-20s %(arch)-10s %(status)s'
|
||||||
|
|
||||||
|
for res in get_package_results(apiurl, prj, package, lastbuild=None, repository=[], arch=[]):
|
||||||
|
res['status'] = res['code']
|
||||||
|
if res['details'] != '':
|
||||||
|
res['status'] += ': %s' % (res['details'], )
|
||||||
|
if res['dirty']:
|
||||||
|
res['status'] = 'state is outdated (was: %s)' % res['status']
|
||||||
|
|
||||||
|
r.append(result_line_templ % res)
|
||||||
|
|
||||||
r.append(result_line_templ % rmap)
|
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=None, name_filter=None, arch=None, repo=None, vertical=None):
|
def get_prj_results(apiurl, prj, hide_legend=False, csv=False, status_filter=None, name_filter=None, arch=None, repo=None, vertical=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user