From 31184071db64682e6908627d038712f481fb6367 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 18 Jul 2019 20:24:59 -0400 Subject: [PATCH] call(Client)Coro: support nested.getattr.retrieval --- src/python/app.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/python/app.py b/src/python/app.py index da99a820..0a4566dc 100644 --- a/src/python/app.py +++ b/src/python/app.py @@ -4,6 +4,7 @@ import asyncio import signal from concurrent.futures import Future +from operator import attrgetter from pathlib import Path from threading import Thread from typing import Any, Coroutine, Dict, List, Optional, Sequence @@ -53,24 +54,18 @@ class App: ) - def call_backend_coro(self, - name: str, - uuid: str, - args: Optional[List[str]] = None) -> None: - self._call_coro( - getattr(self.backend, name)(*args or []), uuid - ) + def call_backend_coro(self, name: str, uuid: str, args: Sequence[str] = () + ) -> None: + self._call_coro(attrgetter(name)(self.backend)(*args), uuid) def call_client_coro(self, account_id: str, name: str, uuid: str, - args: Optional[List[str]] = None) -> None: + args: Sequence[str] = ()) -> None: client = self.backend.clients[account_id] - self._call_coro( - getattr(client, name)(*args or []), uuid - ) + self._call_coro(attrgetter(name)(client)(*args), uuid) def pdb(self, additional_data: Sequence = ()) -> None: