From d688f3b066bebfa41c9106401798ad0e219ed6ab Mon Sep 17 00:00:00 2001 From: Paul Nameless Date: Mon, 11 May 2020 10:35:01 +0800 Subject: [PATCH] Fix black formatting --- tg/controllers/__init__.py | 20 +++++++------------- tg/main.py | 8 +++----- tg/views/__init__.py | 2 +- 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/tg/controllers/__init__.py b/tg/controllers/__init__.py index 2d073d5..f4854db 100644 --- a/tg/controllers/__init__.py +++ b/tg/controllers/__init__.py @@ -46,26 +46,18 @@ class Controller: def send_file(self, send_file_fun, *args, **kwargs): file_path = self.view.status.get_input() if file_path and os.path.isfile(file_path): - chat_id = self.model.chats.id_by_index( - self.model.current_chat - ) + chat_id = self.model.chats.id_by_index(self.model.current_chat) send_file_fun(file_path, chat_id, *args, **kwargs) def send_voice(self): file_path = f"/tmp/voice-{datetime.now()}.oga" with suspend(self.view) as s: - s.call( - config.record_cmd.format(file_path=file_path) - ) + s.call(config.record_cmd.format(file_path=file_path)) resp = self.view.status.get_input( f"Do you want to send recording: {file_path}? [Y/n]" ) - if ( - is_yes(resp) and os.path.isfile(file_path) - ): - chat_id = self.model.chats.id_by_index( - self.model.current_chat - ) + if is_yes(resp) and os.path.isfile(file_path): + chat_id = self.model.chats.id_by_index(self.model.current_chat) duration = get_duration(file_path) waveform = get_waveform(file_path) self.tg.send_voice(file_path, chat_id, duration, waveform) @@ -168,7 +160,9 @@ class Controller: ) width, height = get_video_resolution(file_path) duration = get_duration(file_path) - self.tg.send_video(file_path, chat_id, width, height, duration) + self.tg.send_video( + file_path, chat_id, width, height, duration + ) elif keys == "v": self.send_voice() diff --git a/tg/main.py b/tg/main.py index e511b78..19afd15 100644 --- a/tg/main.py +++ b/tg/main.py @@ -101,10 +101,7 @@ class TelegramApi(Telegram): "@type": "inputMessageVoiceNote", "duration": duration, "waveform": waveform, - "voice_note": { - "@type": "inputFileLocal", - "path": file_path - }, + "voice_note": {"@type": "inputFileLocal", "path": file_path}, }, } return self._send_data(data) @@ -112,7 +109,8 @@ class TelegramApi(Telegram): def main(): def signal_handler(sig, frame): - log.info('You pressed Ctrl+C!') + log.info("You pressed Ctrl+C!") + signal.signal(signal.SIGINT, signal_handler) cfg = config.get_cfg()["DEFAULT"] diff --git a/tg/views/__init__.py b/tg/views/__init__.py index 579b3eb..0db403a 100644 --- a/tg/views/__init__.py +++ b/tg/views/__init__.py @@ -105,7 +105,7 @@ class StatusView: elif chr(key).isprintable(): buff += chr(key) self.win.erase() - line = (msg + buff)[-(self.w-1):] + line = (msg + buff)[-(self.w - 1) :] self.win.addstr(0, 0, line) self.win.clear()