1
0
mirror of https://github.com/openSUSE/osc.git synced 2024-11-16 00:56:12 +01:00
github.com_openSUSE_osc/osc/commands/person_search.py

52 lines
1.3 KiB
Python
Raw Normal View History

2024-05-21 13:16:49 +02:00
import osc.commandline
class PersonSearchCommand(osc.commandline.OscCommand):
"""
Search a person (user)
"""
name = "search"
parent = "PersonCommand"
def init_arguments(self):
self.add_argument(
"--login",
help="Search by a login.",
)
self.add_argument(
"--login-contains",
metavar="SUBSTR",
help="Search by a substring in a login.",
)
self.add_argument(
"--realname-contains",
metavar="SUBSTR",
help="Search by a substring in a realname.",
)
self.add_argument(
"--email",
help="Search by an email address.",
)
self.add_argument(
"--email-contains",
metavar="SUBSTR",
help="Search by a substring in an email address.",
)
def run(self, args):
from .. import obs_api
persons = obs_api.Person.search(
args.apiurl,
login=args.login,
login__contains=args.login_contains,
realname__contains=args.realname_contains,
email=args.email,
email__contains=args.email_contains,
)
for person in persons:
print(person.to_human_readable_string())
print()