mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-13 17:16:23 +01:00
support attribute default requests and including project attributes in
one request.
This commit is contained in:
parent
b9b8f36925
commit
09a01158de
@ -306,6 +306,10 @@ class Osc(cmdln.Cmdln):
|
||||
|
||||
@cmdln.option('-a', '--attribute', metavar='ATTRIBUTE',
|
||||
help='affect only a given attribute')
|
||||
@cmdln.option('--attribute-defaults', action='store_true',
|
||||
help='include defined attribute defaults')
|
||||
@cmdln.option('--attribute-project', action='store_true',
|
||||
help='include project values, if missing in packages ')
|
||||
@cmdln.option('-F', '--file', metavar='FILE',
|
||||
help='read metadata from FILE, instead of opening an editor. '
|
||||
'\'-\' denotes standard input. ')
|
||||
@ -392,6 +396,8 @@ class Osc(cmdln.Cmdln):
|
||||
package = args[1]
|
||||
else:
|
||||
package = None
|
||||
if opts.attribute_project:
|
||||
sys.exit('--attribute-project works only when also a package is given')
|
||||
if len(args) > 2:
|
||||
subpackage = args[2]
|
||||
else:
|
||||
@ -424,7 +430,7 @@ class Osc(cmdln.Cmdln):
|
||||
elif cmd == 'pkg':
|
||||
sys.stdout.write(''.join(show_package_meta(conf.config['apiurl'], project, package)))
|
||||
elif cmd == 'attribute':
|
||||
sys.stdout.write(''.join(show_attribute_meta(conf.config['apiurl'], project, package, subpackage, opts.attribute)))
|
||||
sys.stdout.write(''.join(show_attribute_meta(conf.config['apiurl'], project, package, subpackage, opts.attribute, opts.attribute_defaults, opts.attribute_project)))
|
||||
elif cmd == 'prjconf':
|
||||
sys.stdout.write(''.join(show_project_conf(conf.config['apiurl'], project)))
|
||||
elif cmd == 'user':
|
||||
|
@ -2015,7 +2015,7 @@ def show_package_meta(apiurl, prj, pac):
|
||||
raise
|
||||
|
||||
|
||||
def show_attribute_meta(apiurl, prj, pac, subpac, attribute):
|
||||
def show_attribute_meta(apiurl, prj, pac, subpac, attribute, with_defaults, with_project):
|
||||
path=[]
|
||||
path.append('source')
|
||||
path.append(prj)
|
||||
@ -2026,7 +2026,12 @@ def show_attribute_meta(apiurl, prj, pac, subpac, attribute):
|
||||
path.append('_attribute')
|
||||
if attribute:
|
||||
path.append(attribute)
|
||||
url = makeurl(apiurl, path)
|
||||
query=[]
|
||||
if with_defaults:
|
||||
query.append("with_default=1")
|
||||
if with_project:
|
||||
query.append("with_project=1")
|
||||
url = makeurl(apiurl, path, query)
|
||||
try:
|
||||
f = http_GET(url)
|
||||
return f.readlines()
|
||||
|
Loading…
Reference in New Issue
Block a user