From 8276fd8b5e28b996ec8fb4aff5fd9d84e5eb3ff8 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 2 Jan 2025 15:06:09 +0100 Subject: [PATCH 1/2] lowercase email compare When multiple users are found, do email check case-insensitive. Also when not found, log the found email address as a set. --- src/wordpress_markdown_blog_loader/api.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wordpress_markdown_blog_loader/api.py b/src/wordpress_markdown_blog_loader/api.py index 5a05807..74863d8 100644 --- a/src/wordpress_markdown_blog_loader/api.py +++ b/src/wordpress_markdown_blog_loader/api.py @@ -338,10 +338,10 @@ def get_unique_user_by_name(self, name: str, email: Optional[str]) -> "User": if len(users) == 0: raise ValueError(f"author '{name}' not found on {self.endpoint.host}") elif len(users) > 1: - user = next(filter(lambda u: email and u.email == email, users), None) + user = next(filter(lambda u: email and u.email.lower() == email.lower(), users), None) if not user: raise ValueError( - f"Multiple authors named '{name}' found, none with email {email}" + f"Multiple authors named '{name}' found, none with email {email} (possible: { {u.email for u in users} })." ) return users[0] @@ -546,4 +546,4 @@ def get_tag_id_by_name(self, tag: str) -> str: "invalid tag '{}' try one of\n {}".format( tag, ",\n ".join(self.tags.keys()) ) - ) \ No newline at end of file + ) From 87687cb3309ebd396b85ecb4f085839ff16a774b Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 2 Jan 2025 15:14:55 +0100 Subject: [PATCH 2/2] Return found user not just the first entry of the list. --- src/wordpress_markdown_blog_loader/api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wordpress_markdown_blog_loader/api.py b/src/wordpress_markdown_blog_loader/api.py index 74863d8..20686ee 100644 --- a/src/wordpress_markdown_blog_loader/api.py +++ b/src/wordpress_markdown_blog_loader/api.py @@ -343,6 +343,7 @@ def get_unique_user_by_name(self, name: str, email: Optional[str]) -> "User": raise ValueError( f"Multiple authors named '{name}' found, none with email {email} (possible: { {u.email for u in users} })." ) + return user return users[0] def posts(self, query: dict = None) -> Iterator["Post"]: