mirror of
https://github.com/openSUSE/osc.git
synced 2025-01-01 04:36:13 +01:00
Migrate 'whois/user' command to obs_api.Person
This commit is contained in:
parent
88f7dc517b
commit
474cbd21ce
@ -9182,16 +9182,26 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
"""
|
"""
|
||||||
Show fullname and email of a buildservice user
|
Show fullname and email of a buildservice user
|
||||||
"""
|
"""
|
||||||
|
from . import obs_api
|
||||||
|
from .output import print_msg
|
||||||
|
|
||||||
apiurl = self.get_api_url()
|
apiurl = self.get_api_url()
|
||||||
usernames = opts.user
|
usernames = opts.user
|
||||||
|
|
||||||
if not usernames:
|
if not usernames:
|
||||||
usernames = [conf.config["api_host_options"][apiurl]["user"]]
|
usernames = [conf.config["api_host_options"][apiurl]["user"]]
|
||||||
|
|
||||||
for name in usernames:
|
# remove duplicates
|
||||||
user = get_user_data(apiurl, name, 'login', 'realname', 'email')
|
usernames = list(set(usernames))
|
||||||
if len(user) == 3:
|
|
||||||
print(f"{user[0]}: \"{user[1]}\" <{user[2]}>")
|
users = obs_api.Person.search(apiurl, login=usernames)
|
||||||
|
users_by_login = {i.login: i for i in users}
|
||||||
|
for username in usernames:
|
||||||
|
user = users_by_login.get(username, None)
|
||||||
|
if not user:
|
||||||
|
print_msg(f"User '{username}' does not exist", print_to="warning")
|
||||||
|
continue
|
||||||
|
print(f'{user.login}: "{user.realname}" <{user.email}>')
|
||||||
|
|
||||||
@cmdln.name("create-pbuild-config")
|
@cmdln.name("create-pbuild-config")
|
||||||
@cmdln.alias('cpc')
|
@cmdln.alias('cpc')
|
||||||
|
Loading…
Reference in New Issue
Block a user