From 816a982acfe4d92a783435647fb3fcb394491f8d Mon Sep 17 00:00:00 2001 From: Michal Vyskocil Date: Wed, 26 Aug 2009 14:22:54 +0000 Subject: [PATCH] added missing delPerson function do_maintainer relly on delPerson, which did not exists. It is taken from old delMaintainer function with role handling. Fixed also some issues in do_maintainer role handling --- osc/commandline.py | 14 +++++++++----- osc/core.py | 8 ++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/osc/commandline.py b/osc/commandline.py index c0040504..5a7461f9 100755 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -3251,7 +3251,7 @@ Please submit there instead, or use --nodevelproject to force direct submission. if not url.startswith('http'): if not url.startswith('/'): url = '/' + url - url = conf.config['apiurl'] + url + url = conf.config['apiurl'] if opts.headers: opts.headers = dict(opts.headers) @@ -3299,8 +3299,10 @@ Please submit there instead, or use --nodevelproject to force direct submission. maintainers = [] pac = None tree = None - role = opts.role - roles = [ 'bugowner', 'maintainer' ] + if not opts.role: + roles = [ 'bugowner', 'maintainer' ] + else: + roles = [opts.role] if opts.bugowner: roles = [ 'bugowner' ] @@ -3329,9 +3331,11 @@ Please submit there instead, or use --nodevelproject to force direct submission. raise oscerr.WrongArgs('I need at least one argument.') if opts.add: - addPerson(conf.config['apiurl'], prj, pac, opts.add, role) + for role in roles: + addPerson(conf.config['apiurl'], prj, pac, opts.add, role) elif opts.delete: - delPerson(conf.config['apiurl'], prj, pac, opts.delete, role) + for role in roles: + delPerson(conf.config['apiurl'], prj, pac, opts.delete, role) elif opts.devel_project: setDevelProject(conf.config['apiurl'], prj, pac, opts.devel_project) else: diff --git a/osc/core.py b/osc/core.py index 0c011af4..f3fdde38 100755 --- a/osc/core.py +++ b/osc/core.py @@ -3920,7 +3920,11 @@ def addPerson(apiurl, prj, pac, user, role="maintainer"): print "osc: an error occured" def delMaintainer(apiurl, prj, pac, user): - """ delete a maintainer from a package or project """ + # for backward compatibility only + delPerson(apiurl, prj, pac, user) + +def delPerson(apiurl, prj, pac, user, role="maintainer"): + """ delete a person from a package or project """ path = quote_plus(prj), kind = 'prj' if pac: @@ -3934,7 +3938,7 @@ def delMaintainer(apiurl, prj, pac, user): tree = ET.fromstring(''.join(data)) found = False for person in tree.getiterator('person'): - if person.get('userid') == user: + if person.get('userid') == user and person.get('role') == role: tree.remove(person) found = True print "user \'%s\' removed" % user