From d0b729e78e45cbe9d7ceee2a39e6deee28d4bf03 Mon Sep 17 00:00:00 2001 From: gcarq Date: Sat, 23 Jun 2018 12:28:32 +0200 Subject: [PATCH] implement name property in abstract class --- freqtrade/rpc/api_server.py | 11 ++--------- freqtrade/rpc/rpc.py | 10 +++++----- freqtrade/rpc/telegram.py | 4 ---- 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/freqtrade/rpc/api_server.py b/freqtrade/rpc/api_server.py index 220485141..bfde304bd 100644 --- a/freqtrade/rpc/api_server.py +++ b/freqtrade/rpc/api_server.py @@ -78,17 +78,10 @@ class ApiServer(RPC): logger.exception("Api server failed to start, exception message is:") def cleanup(self) -> None: - # TODO: implement me - raise NotImplementedError - - @property - def name(self) -> str: - # TODO: implement me - raise NotImplementedError + pass def send_msg(self, msg: str) -> None: - # TODO: implement me - raise NotImplementedError + pass """ Define the application methods here, called by app.add_url_rule diff --git a/freqtrade/rpc/rpc.py b/freqtrade/rpc/rpc.py index e86af8a11..c31d46878 100644 --- a/freqtrade/rpc/rpc.py +++ b/freqtrade/rpc/rpc.py @@ -49,15 +49,15 @@ class RPC(object): """ self._freqtrade = freqtrade + @property + def name(self) -> str: + """ Returns the lowercase name of the implementation """ + return self.__class__.__name__.lower() + @abstractmethod def cleanup(self) -> None: """ Cleanup pending module resources """ - @property - @abstractmethod - def name(self) -> str: - """ Returns the lowercase name of this module """ - @abstractmethod def send_msg(self, msg: str) -> None: """ Sends a message to all registered rpc modules """ diff --git a/freqtrade/rpc/telegram.py b/freqtrade/rpc/telegram.py index 90913b4a5..add9968dc 100644 --- a/freqtrade/rpc/telegram.py +++ b/freqtrade/rpc/telegram.py @@ -58,10 +58,6 @@ def authorized_only(command_handler: Callable[[Any, Bot, Update], None]) -> Call class Telegram(RPC): """ This class handles all telegram communication """ - @property - def name(self) -> str: - return "telegram" - def __init__(self, freqtrade) -> None: """ Init the Telegram call, and init the super class RPC