Remove logging to speed up the program
This commit is contained in:
@ -1,16 +1,13 @@
|
||||
import os
|
||||
from functools import lru_cache
|
||||
|
||||
from loguru import logger
|
||||
from platformdirs import user_data_dir
|
||||
from reader import Entry, Reader, TagNotFoundError, make_reader # type: ignore
|
||||
|
||||
data_dir: str = user_data_dir(appname="discord_rss_bot", appauthor="TheLovinator", roaming=True)
|
||||
os.makedirs(data_dir, exist_ok=True)
|
||||
logger.info(f"Data directory: {data_dir}")
|
||||
|
||||
default_custom_message: str = "{{entry_title}}\n{{entry_link}}"
|
||||
logger.debug(f"Default custom message: {default_custom_message}")
|
||||
|
||||
|
||||
def get_webhook_for_entry(custom_reader: Reader, entry: Entry) -> str:
|
||||
@ -31,10 +28,8 @@ def get_webhook_for_entry(custom_reader: Reader, entry: Entry) -> str:
|
||||
# Is None if not found or error.
|
||||
try:
|
||||
webhook_url: str = str(reader.get_tag(entry.feed_url, "webhook"))
|
||||
logger.debug(f"Webhook for {entry.title}: {webhook_url}")
|
||||
except TagNotFoundError:
|
||||
webhook_url = ""
|
||||
logger.error(f"Could not find webhook for {entry.title}.")
|
||||
|
||||
return webhook_url
|
||||
|
||||
@ -50,10 +45,8 @@ def get_db_location(custom_location: str = "") -> str:
|
||||
The database location.
|
||||
"""
|
||||
# Use the custom location if it is provided.
|
||||
logger.debug(f"Custom location: {custom_location}")
|
||||
db_loc: str = custom_location or os.path.join(data_dir, "db.sqlite")
|
||||
|
||||
logger.debug(f"Database location: {db_loc}")
|
||||
return db_loc
|
||||
|
||||
|
||||
@ -65,10 +58,8 @@ def get_reader(custom_location: str = "") -> Reader:
|
||||
custom_location: The location of the database file.
|
||||
|
||||
"""
|
||||
logger.debug(f"Custom location: {custom_location}")
|
||||
|
||||
db_location: str = get_db_location(custom_location)
|
||||
logger.debug(f"Database location: {db_location}")
|
||||
|
||||
return make_reader(url=db_location)
|
||||
|
||||
@ -91,9 +82,6 @@ def list_webhooks(reader: Reader) -> list[dict[str, str]]:
|
||||
# Check if the tag is named webhooks
|
||||
if tag == "webhooks":
|
||||
webhooks = reader.get_tag((), "webhooks") # type: ignore
|
||||
else:
|
||||
logger.debug(f"Tag {tag} is not webhooks.")
|
||||
break
|
||||
|
||||
logger.debug(f"Webhooks: {webhooks}")
|
||||
return webhooks
|
||||
|
Reference in New Issue
Block a user