Skip to content

Commit

Permalink
updates ValueError message
Browse files Browse the repository at this point in the history
  • Loading branch information
BWMac committed Nov 20, 2023
1 parent d654fff commit 5f25076
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions synapseclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,10 +639,13 @@ def get_user_profile(
freds_profile = syn.get_user_name_profile('fredcommo')
"""
if id:
# For UserProfile
if isinstance(id, collections.abc.Mapping) and "ownerId" in id:
id = id.ownerId
# For TeamMember
elif isinstance(id, TeamMember):
id = id.member.ownerId
# For userName
elif isinstance(id, str):
principals = self._findPrincipals(id)
if len(principals) == 1:
Expand All @@ -653,7 +656,7 @@ def get_user_profile(
id = principal["ownerId"]
break
else: # no break
raise ValueError('Can\'t find user "%s": ' % id)
raise ValueError(f"Can't find user '{id}'")
else:
raise TypeError("id must be a string, UserProfile, or TeamMember")
else:
Expand Down Expand Up @@ -682,7 +685,7 @@ def get_user_profile_by_id(
my_profile = syn.getUserProfile()
freds_profile = syn.getUserProfile('fredcommo')
"""
if not id:
if id is None:
id = ""
uri = f"/userProfile/{id}"
return UserProfile(
Expand Down

0 comments on commit 5f25076

Please sign in to comment.