Skip to content

Commit 54c871f

Browse files
committed
create getAgentIdentifier method in utils
Return the full agent identifier from a short identifier, name, or confirm full identifier thanks @JonnyWong16
1 parent 165c19f commit 54c871f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

plexapi/utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,3 +378,14 @@ def choose(msg, items, attr): # pragma: no cover
378378

379379
except (ValueError, IndexError):
380380
pass
381+
382+
def getAgentIdentifier(section, agent):
383+
""" Return the full agent identifier from a short identifier, name, or confirm full identifier. """
384+
agents = []
385+
for ag in section.agents():
386+
identifiers = [ag.identifier, ag.shortIdentifier, ag.name]
387+
if agent in identifiers:
388+
return ag.identifier
389+
agents += identifiers
390+
raise NotFound('Couldnt find "%s" in agents list (%s)' %
391+
(agent, ', '.join(agents)))

0 commit comments

Comments
 (0)