Skip to content

Commit

Permalink
Merge pull request #4 from decodingml/test-pulumni
Browse files Browse the repository at this point in the history
feat: Extend user functionality
  • Loading branch information
iusztinpaul authored Apr 1, 2024
2 parents 6a1b8c1 + 6360290 commit 83c0bf1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 16 additions & 0 deletions course/module-1/lib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from errors import ImproperlyConfigured


def user_to_names(user: str | None) -> tuple[str, str]:
if user is None:
raise ImproperlyConfigured("User name is empty")

name_tokens = user.split(" ")
if len(name_tokens) == 0:
raise ImproperlyConfigured("User name is empty")
elif len(name_tokens) == 1:
first_name, last_name = name_tokens[0], name_tokens[0]
else:
first_name, last_name = " ".join(name_tokens[:-1]), name_tokens[-1]

return first_name, last_name
5 changes: 3 additions & 2 deletions course/module-1/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Any

import lib
from aws_lambda_powertools import Logger
from aws_lambda_powertools.utilities.typing import LambdaContext
from crawlers import GithubCrawler, LinkedInCrawler, MediumCrawler
Expand All @@ -15,8 +16,8 @@


def handler(event, context: LambdaContext) -> dict[str, Any]:

first_name, last_name = event.get("user").split(" ")
first_name, last_name = lib.user_to_names(event.get("user"))

user = UserDocument.get_or_create(first_name=first_name, last_name=last_name)

link = event.get("link")
Expand Down

0 comments on commit 83c0bf1

Please sign in to comment.