Whitespace and type mismatch

This commit is contained in:
Davte 2023-04-29 20:56:32 +02:00
parent 3bd1a9b679
commit fb04211e81
Signed by: Davte
GPG Key ID: 70336F92E6814706

View File

@ -3,26 +3,29 @@ import asyncio
import logging import logging
import os.path import os.path
import sys import sys
from typing import Any, Union from typing import Any, Dict, Union
import davtelepot.authorization as authorization import davtelepot.authorization as authorization
import davtelepot.administration_tools as administration_tools import davtelepot.administration_tools as administration_tools
import davtelepot.helper as helper import davtelepot.helper as helper
from davtelepot.bot import Bot from davtelepot.bot import Bot
from davtelepot.utilities import get_cleaned_text, get_secure_key, get_user, json_read, json_write, \ from davtelepot.utilities import (get_cleaned_text, get_secure_key,
line_drawing_unordered_list get_user, json_read, json_write,
line_drawing_unordered_list)
def join_path(*args): def join_path(*args):
return os.path.abspath(os.path.join(*args)) return os.path.abspath(os.path.join(*args))
def dir_path(path): def dir_path(path):
if os.path.isdir(path) and os.access(path, os.W_OK): if os.path.isdir(path) and os.access(path, os.W_OK):
return path return path
else: else:
raise argparse.ArgumentTypeError(f"`{path}` is not a valid path") raise argparse.ArgumentTypeError(f"`{path}` is not a valid path")
def get_cli_arguments() -> dict[str, Any]:
def get_cli_arguments() -> Dict[str, Any]:
default_path = join_path(os.path.dirname(__file__), 'data') default_path = join_path(os.path.dirname(__file__), 'data')
cli_parser = argparse.ArgumentParser( cli_parser = argparse.ArgumentParser(
description='Run a davtelepot-powered Telegram bot from command line.', description='Run a davtelepot-powered Telegram bot from command line.',
@ -57,6 +60,7 @@ def get_cli_arguments() -> dict[str, Any]:
cli_parsed_arguments[key] = join_path(cli_parsed_arguments['path'], default) cli_parsed_arguments[key] = join_path(cli_parsed_arguments['path'], default)
return cli_parsed_arguments return cli_parsed_arguments
def set_loggers(log_file: str = 'davtelepot.log', def set_loggers(log_file: str = 'davtelepot.log',
error_log_file: str = 'davtelepot.errors'): error_log_file: str = 'davtelepot.errors'):
root_logger = logging.getLogger() root_logger = logging.getLogger()
@ -147,9 +151,11 @@ def send_single_message(telegram_bot: Bot):
text = input(f"Write a message for {get_user(records[0], False)}\t\t") text = input(f"Write a message for {get_user(records[0], False)}\t\t")
if input("Should I send it? Y to send, anything else cancel\t\t").lower() == "y": if input("Should I send it? Y to send, anything else cancel\t\t").lower() == "y":
break break
async def send_and_print_message(): async def send_and_print_message():
sent_message = await telegram_bot.send_one_message(chat_id=records[0]['telegram_id'], text=text) sent_message = await telegram_bot.send_one_message(chat_id=records[0]['telegram_id'], text=text)
print(sent_message) print(sent_message)
asyncio.run(send_and_print_message()) asyncio.run(send_and_print_message())
return return