python-dependency-injector/examples/miniapps/use-cases/example/adapters.py

23 lines
447 B
Python
Raw Normal View History

2020-09-07 19:31:59 +03:00
"""Adapters module."""
import abc
class EmailSender(metaclass=abc.ABCMeta):
@abc.abstractmethod
def send(self, to: str, body: str) -> None:
...
class SmtpEmailSender:
def send(self, to: str, body: str) -> None:
2021-10-01 02:01:31 +03:00
print(f"Sending an email to {to} over SMTP, body=\"{body}\"")
2020-09-07 19:31:59 +03:00
class EchoEmailSender:
def send(self, to: str, body: str) -> None:
2021-10-01 02:01:31 +03:00
print(f"Fake sending an email to {to}, body=\"{body}\"")