From 90a209e69f455b49c4a642fb2b3288f915fed1dc Mon Sep 17 00:00:00 2001 From: René 'Necoro' Neumann Date: Tue, 3 Oct 2017 22:02:16 +0200 Subject: Basic server implementation --- archivist/utils.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 archivist/utils.py (limited to 'archivist/utils.py') diff --git a/archivist/utils.py b/archivist/utils.py new file mode 100644 index 0000000..391a8fb --- /dev/null +++ b/archivist/utils.py @@ -0,0 +1,25 @@ +from click import MultiCommand + +class ProxyCommand(MultiCommand): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.__proxy = None + + def _get_proxy(self): + raise NotImplementedError("_get_proxy") + + def __load(self): + if self.__proxy is None: + self.__proxy = self._get_proxy() + + def list_commands(self,ctx): + self.__load() + return self.__proxy.list_commands(ctx) + + def get_command(self,ctx,name): + self.__load() + return self.__proxy.get_command(ctx,name) + + def make_context(self, *args, **kwargs): + self.__load() + return self.__proxy.make_context(*args, **kwargs) -- cgit v1.2.3-70-g09d2