mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
- added verbose option to do_maintainers:
* it basically lists some more information about each maintainer - replaced get_user_email() with get_user_data()
This commit is contained in:
parent
9ce40d4bab
commit
40d2ce205e
@ -1833,6 +1833,8 @@ class Osc(cmdln.Cmdln):
|
||||
|
||||
@cmdln.option('-e', '--email', action='store_true',
|
||||
help='show email addresses instead of user names')
|
||||
@cmdln.option('-v', '--verbose', action='store_true',
|
||||
help='show more information')
|
||||
def do_maintainer(self, subcmd, opts, *args):
|
||||
"""${cmd_name}: Show maintainers of a project/package
|
||||
|
||||
@ -1859,13 +1861,24 @@ class Osc(cmdln.Cmdln):
|
||||
for person in tree.findall('person'):
|
||||
maintainers.append(person.get('userid'))
|
||||
|
||||
if not opts.email:
|
||||
print ', '.join(maintainers)
|
||||
else:
|
||||
if opts.email:
|
||||
emails = []
|
||||
for maintainer in maintainers:
|
||||
emails.append(get_user_email(conf.config['apiurl'], maintainer))
|
||||
user = get_user_data(conf.config['apiurl'], maintainer, 'email')
|
||||
if user != None:
|
||||
emails.append(''.join(user))
|
||||
print ', '.join(emails)
|
||||
elif opts.verbose:
|
||||
userdata = []
|
||||
for maintainer in maintainers:
|
||||
user = get_user_data(conf.config['apiurl'], maintainer, 'realname', 'login', 'email')
|
||||
if user != None:
|
||||
for itm in user:
|
||||
userdata.append(itm)
|
||||
for row in build_table(3, userdata, ['realname', 'userid', 'email\n']):
|
||||
print row
|
||||
else:
|
||||
print ', '.join(maintainers)
|
||||
|
||||
|
||||
|
||||
|
25
osc/core.py
25
osc/core.py
@ -1182,14 +1182,25 @@ def get_user_meta(apiurl, user):
|
||||
return None
|
||||
|
||||
|
||||
def get_user_email(apiurl, user):
|
||||
u = makeurl(apiurl, ['person', quote_plus(user)])
|
||||
def get_user_data(apiurl, user, *tags):
|
||||
"""get specified tags from the user meta"""
|
||||
meta = get_user_meta(apiurl, user)
|
||||
data = []
|
||||
if meta != None:
|
||||
root = ET.fromstring(meta)
|
||||
for tag in tags:
|
||||
try:
|
||||
f = http_GET(u)
|
||||
root = ET.parse(f).getroot()
|
||||
return root.find('email').text
|
||||
except urllib2.HTTPError:
|
||||
print 'user \'%s\' not found' % user
|
||||
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 None
|
||||
return data
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user