diff --git a/tg/controllers.py b/tg/controllers.py index e608d94..300e3d2 100644 --- a/tg/controllers.py +++ b/tg/controllers.py @@ -427,8 +427,7 @@ class Controller: self.tg.send_video(file_path, chat_id, width, height, duration) def send_file( - self, - send_file_fun: Callable[[str, int], AsyncResult], + self, send_file_fun: Callable[[str, int], AsyncResult], ) -> None: _input = self.view.status.get_input() if _input is None: @@ -552,10 +551,7 @@ class Controller: def _get_user_ids(self, is_multiple: bool = False) -> List[int]: users = self.model.users.get_users() _, cols = self.view.stdscr.getmaxyx() - limit = min( - int(cols / 2), - max(len(user.name) for user in users), - ) + limit = min(int(cols / 2), max(len(user.name) for user in users),) users_out = "\n".join( f"{user.id}\t{user.name:<{limit}} | {user.status}" for user in sorted(users, key=lambda user: user.order) diff --git a/tg/tdlib.py b/tg/tdlib.py index 17b1023..a77223c 100644 --- a/tg/tdlib.py +++ b/tg/tdlib.py @@ -294,50 +294,35 @@ class Tdlib(Telegram): } return self._send_data(data) - def get_basic_group( - self, - basic_group_id: int, - ) -> AsyncResult: + def get_basic_group(self, basic_group_id: int,) -> AsyncResult: data = { "@type": "getBasicGroup", "basic_group_id": basic_group_id, } return self._send_data(data) - def get_basic_group_full_info( - self, - basic_group_id: int, - ) -> AsyncResult: + def get_basic_group_full_info(self, basic_group_id: int,) -> AsyncResult: data = { "@type": "getBasicGroupFullInfo", "basic_group_id": basic_group_id, } return self._send_data(data) - def get_supergroup( - self, - supergroup_id: int, - ) -> AsyncResult: + def get_supergroup(self, supergroup_id: int,) -> AsyncResult: data = { "@type": "getSupergroup", "supergroup_id": supergroup_id, } return self._send_data(data) - def get_supergroup_full_info( - self, - supergroup_id: int, - ) -> AsyncResult: + def get_supergroup_full_info(self, supergroup_id: int,) -> AsyncResult: data = { "@type": "getSupergroupFullInfo", "supergroup_id": supergroup_id, } return self._send_data(data) - def get_secret_chat( - self, - secret_chat_id: int, - ) -> AsyncResult: + def get_secret_chat(self, secret_chat_id: int,) -> AsyncResult: data = { "@type": "getSecretChat", "secret_chat_id": secret_chat_id, diff --git a/tg/utils.py b/tg/utils.py index a8b7d58..65c36d7 100644 --- a/tg/utils.py +++ b/tg/utils.py @@ -85,7 +85,9 @@ def get_file_handler(file_path: str) -> str: return config.DEFAULT_OPEN.format(file_path=shlex.quote(file_path)) caps = get_mailcap() - handler, view = mailcap.findmatch(caps, mtype, filename=file_path) + handler, view = mailcap.findmatch( + caps, mtype, filename=shlex.quote(file_path) + ) if not handler: return config.DEFAULT_OPEN.format(file_path=shlex.quote(file_path)) return handler @@ -102,16 +104,7 @@ def parse_size(size: str) -> int: def humanize_size( num: int, suffix: str = "B", - suffixes: Tuple[str, ...] = ( - "", - "K", - "M", - "G", - "T", - "P", - "E", - "Z", - ), + suffixes: Tuple[str, ...] = ("", "K", "M", "G", "T", "P", "E", "Z",), ) -> str: magnitude = int(math.floor(math.log(num, 1024))) val = num / math.pow(1024, magnitude) diff --git a/tg/views.py b/tg/views.py index 6ecc37a..d4806e2 100644 --- a/tg/views.py +++ b/tg/views.py @@ -280,11 +280,7 @@ class ChatView: class MsgView: - def __init__( - self, - stdscr: window, - model: Model, - ) -> None: + def __init__(self, stdscr: window, model: Model,) -> None: self.model = model self.stdscr = stdscr self.h = 0