From 12df2eae066c9edcc4062fda4de60acac2d7bd77 Mon Sep 17 00:00:00 2001 From: Carsten Schabacker Date: Tue, 6 Feb 2024 18:08:40 +0100 Subject: [PATCH] Fix find_account still not finished --- ActiveCollabAPI/ACAuthenticator.py | 7 +++++-- config-example.ini | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ActiveCollabAPI/ACAuthenticator.py b/ActiveCollabAPI/ACAuthenticator.py index 9882667..ed2b2dd 100644 --- a/ActiveCollabAPI/ACAuthenticator.py +++ b/ActiveCollabAPI/ACAuthenticator.py @@ -41,5 +41,8 @@ class ACAuthenticator: return login_res def find_account(self, name): - # FIXME: implement search - return self.accounts[0] + found = list(filter(lambda a: a['user_display_name'] == name, + self.accounts)) + if len(found) == 0: + raise Exception("Account '%s' not found!" % name) + return found[0] diff --git a/config-example.ini b/config-example.ini index 93306e6..b986327 100644 --- a/config-example.ini +++ b/config-example.ini @@ -2,4 +2,4 @@ [LOGIN] username = you@example.com password = very-secret -account_name = "#123456" \ No newline at end of file +account_name = #123456 \ No newline at end of file