Skip to content

Commit 146ca33

Browse files
Merge pull request #12 from abij/patch-1
Find unique user based on lowercase email compare
2 parents 3d049d8 + 87687cb commit 146ca33

File tree

1 file changed

+4
-3
lines changed
  • src/wordpress_markdown_blog_loader

1 file changed

+4
-3
lines changed

src/wordpress_markdown_blog_loader/api.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,12 @@ def get_unique_user_by_name(self, name: str, email: Optional[str]) -> "User":
338338
if len(users) == 0:
339339
raise ValueError(f"author '{name}' not found on {self.endpoint.host}")
340340
elif len(users) > 1:
341-
user = next(filter(lambda u: email and u.email == email, users), None)
341+
user = next(filter(lambda u: email and u.email.lower() == email.lower(), users), None)
342342
if not user:
343343
raise ValueError(
344-
f"Multiple authors named '{name}' found, none with email {email}"
344+
f"Multiple authors named '{name}' found, none with email {email} (possible: { {u.email for u in users} })."
345345
)
346+
return user
346347
return users[0]
347348

348349
def posts(self, query: dict = None) -> Iterator["Post"]:
@@ -546,4 +547,4 @@ def get_tag_id_by_name(self, tag: str) -> str:
546547
"invalid tag '{}' try one of\n {}".format(
547548
tag, ",\n ".join(self.tags.keys())
548549
)
549-
)
550+
)

0 commit comments

Comments
 (0)