-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update sample to follow new structure
- Loading branch information
Showing
7 changed files
with
51 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,15 @@ | ||
from typing import Any, Coroutine | ||
|
||
from sample.use_cases.greet.igreet_output_port import IGreetOutputPort | ||
from src.clapy.outputs import ValidationResult | ||
|
||
|
||
class GreetPresenter(IGreetOutputPort): | ||
|
||
async def present_greeting_async(self, greeting: str) -> Coroutine[Any, Any, None]: | ||
return print(greeting) | ||
async def present_greeting_async(self, greeting: str) -> None: | ||
print(greeting) | ||
|
||
async def present_validation_failure_async(self, validation_failure: ValidationResult) -> None: | ||
print(validation_failure.summary) | ||
|
||
async def present_validation_failure_async(self, validation_failure: Any) -> Coroutine[Any, Any, None]: | ||
return print(validation_failure) | ||
async def present_missing_names_warning_async(self) -> bool: | ||
user_input = input("You only told me one of your names, do you want to continue? Enter 'Y' to continue or 'N' to stop.") | ||
return user_input == 'Y' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,6 @@ | ||
from typing import Generic | ||
from src.clapy.outputs import IOutputPort | ||
from src.clapy.pipeline import IPipe, InputPort | ||
|
||
from src.clapy.generics import TInputPort, TOutputPort | ||
from src.clapy.pipeline import IPipe | ||
|
||
|
||
class NameChecker(IPipe, Generic[TInputPort, TOutputPort]): | ||
class NameChecker(IPipe, InputPort, IOutputPort): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
from src.clapy.pipeline import InputPort | ||
from src.clapy.pipeline import InputPort, required | ||
|
||
|
||
class GreetInputPort(InputPort): | ||
|
||
def __init__(self, name: str): | ||
self.name = name | ||
def __init__(self) -> None: | ||
self._name = None | ||
|
||
@property | ||
@required | ||
def name(self) -> str: | ||
return self._name | ||
|
||
@name.setter | ||
def name(self, value): | ||
self._name = value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
from typing import Any, Coroutine, Union | ||
|
||
from sample.use_cases.greet.greet_input_port import GreetInputPort | ||
from sample.use_cases.greet.igreet_output_port import IGreetOutputPort | ||
from src.clapy.pipeline import Interactor | ||
|
||
|
||
class GreetInteractor(Interactor): | ||
|
||
def execute_async( | ||
self, | ||
input_port: GreetInputPort, | ||
output_port: IGreetOutputPort) -> Coroutine[GreetInputPort, Any, Union[Coroutine, None]]: | ||
return output_port.present_greeting_async(f"Hello {input_port.name}!") | ||
async def execute_async(self, input_port: GreetInputPort, output_port: IGreetOutputPort) -> None: | ||
await output_port.present_greeting_async(f"Hello {input_port.name}!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
from src.clapy.outputs import IValidationOutputPort | ||
from src.clapy.outputs import IOutputPort, IValidationOutputPort | ||
|
||
|
||
class IGreetOutputPort(IValidationOutputPort, ABC): | ||
class IGreetOutputPort(IOutputPort, IValidationOutputPort, ABC): | ||
|
||
@abstractmethod | ||
async def present_greeting_async(self, greeting: str) -> None: | ||
pass | ||
|
||
@abstractmethod | ||
async def present_missing_names_warning_async(self) -> bool: | ||
pass |