mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-11 16:36:14 +01:00
- do_maintainer: fixed support for groups
Ideally, the whole method will be refactored one day...
This commit is contained in:
parent
49ed086d0b
commit
b5d47ebd8c
@ -7054,6 +7054,16 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
${cmd_usage}
|
||||
${cmd_option_list}
|
||||
"""
|
||||
def get_maintainer_data(apiurl, maintainer, verbose=False):
|
||||
tags = ('email',)
|
||||
if maintainer.startswith('group:'):
|
||||
group = maintainer.replace('group:', '')
|
||||
if verbose:
|
||||
return [maintainer] + get_group_data(apiurl, group, 'title', *tags)
|
||||
return get_group_data(apiurl, group, 'email')
|
||||
if verbose:
|
||||
tags = ('login', 'realname', 'email')
|
||||
return get_user_data(apiurl, maintainer, *tags)
|
||||
|
||||
binary = None
|
||||
prj = None
|
||||
@ -7276,7 +7286,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
if opts.email:
|
||||
emails = []
|
||||
for maintainer in maintainers.get(role, []):
|
||||
user = get_user_data(apiurl, maintainer, 'email')
|
||||
user = get_maintainer_data(apiurl, maintainer, verbose=False)
|
||||
if len(user):
|
||||
emails.append(''.join(user))
|
||||
print(indent, end=' ')
|
||||
@ -7284,7 +7294,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
elif opts.verbose:
|
||||
userdata = []
|
||||
for maintainer in maintainers.get(role, []):
|
||||
user = get_user_data(apiurl, maintainer, 'login', 'realname', 'email')
|
||||
user = get_maintainer_data(apiurl, maintainer, verbose=True)
|
||||
userdata.append(user[0])
|
||||
if user[1] != '-':
|
||||
userdata.append("%s <%s>"%(user[1], user[2]))
|
||||
|
30
osc/core.py
30
osc/core.py
@ -4013,26 +4013,30 @@ def get_user_meta(apiurl, user):
|
||||
return None
|
||||
|
||||
|
||||
def get_user_data(apiurl, user, *tags):
|
||||
"""get specified tags from the user meta"""
|
||||
meta = get_user_meta(apiurl, user)
|
||||
def _get_xml_data(meta, *tags):
|
||||
data = []
|
||||
if meta != None:
|
||||
root = ET.fromstring(meta)
|
||||
for tag in tags:
|
||||
try:
|
||||
if root.find(tag).text != None:
|
||||
data.append(root.find(tag).text)
|
||||
else:
|
||||
# tag is empty
|
||||
data.append('-')
|
||||
except AttributeError:
|
||||
# this part is reached if the tags tuple contains an invalid tag
|
||||
print('The xml file for user \'%s\' seems to be broken' % user)
|
||||
return []
|
||||
elm = root.find(tag)
|
||||
if elm is None or elm.text is None:
|
||||
data.append('-')
|
||||
else:
|
||||
data.append(elm.text)
|
||||
return data
|
||||
|
||||
|
||||
def get_user_data(apiurl, user, *tags):
|
||||
"""get specified tags from the user meta"""
|
||||
meta = get_user_meta(apiurl, user)
|
||||
return _get_xml_data(meta, *tags)
|
||||
|
||||
|
||||
def get_group_data(apiurl, group, *tags):
|
||||
meta = get_group(apiurl, group)
|
||||
return _get_xml_data(meta, *tags)
|
||||
|
||||
|
||||
def download(url, filename, progress_obj = None, mtime = None):
|
||||
import tempfile, shutil
|
||||
global BUFSIZE
|
||||
|
Loading…
Reference in New Issue
Block a user