Add docstrings to files
This commit is contained in:
@ -1,3 +1,26 @@
|
|||||||
|
"""
|
||||||
|
Functions:
|
||||||
|
add_feed()
|
||||||
|
Add a feed to the reader. This also updates the feed.
|
||||||
|
check_feed()
|
||||||
|
Check a single feed.
|
||||||
|
check_feeds()
|
||||||
|
Check all feeds.
|
||||||
|
send_to_discord()
|
||||||
|
Send entries to Discord.
|
||||||
|
update_feed()
|
||||||
|
Update a feed.
|
||||||
|
|
||||||
|
Classes:
|
||||||
|
IfFeedError
|
||||||
|
Used in add_feed() and update_feed(). If an error, it will return IfFeedError with error=True.
|
||||||
|
If no error, it will return IfFeedError with error=False.
|
||||||
|
|
||||||
|
Exceptions:
|
||||||
|
NoWebhookFoundError
|
||||||
|
Used in send_to_discord(). If no webhook found, it will raise NoWebhookFoundError.
|
||||||
|
"""
|
||||||
|
|
||||||
from discord_webhook import DiscordWebhook
|
from discord_webhook import DiscordWebhook
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from reader import FeedExistsError, FeedNotFoundError, InvalidFeedURLError, ParseError, StorageError
|
from reader import FeedExistsError, FeedNotFoundError, InvalidFeedURLError, ParseError, StorageError
|
||||||
|
@ -1,3 +1,31 @@
|
|||||||
|
"""
|
||||||
|
The main file for the discord-rss-bot.
|
||||||
|
|
||||||
|
This file is used to start the bot.
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
check_feed() -> /check
|
||||||
|
POST - Update a feed.
|
||||||
|
crete_feed() -> /add
|
||||||
|
POST - Create a new feed.
|
||||||
|
favicon() -> /favicon.ico
|
||||||
|
GET - Return the favicon.
|
||||||
|
get_add() -> /add
|
||||||
|
GET - Page for adding a new feed.
|
||||||
|
get_feed() -> /feed
|
||||||
|
GET - Page for a single feed.
|
||||||
|
index() -> /
|
||||||
|
GET - index page.
|
||||||
|
remove_feed() -> /remove
|
||||||
|
POST - Remove a feed.
|
||||||
|
|
||||||
|
create_list_of_webhooks()
|
||||||
|
Create a list with webhooks.
|
||||||
|
make_context_index()
|
||||||
|
Create the needed context for the index page.
|
||||||
|
startup()
|
||||||
|
Runs on startup.
|
||||||
|
"""
|
||||||
import enum
|
import enum
|
||||||
import sys
|
import sys
|
||||||
from functools import cache
|
from functools import cache
|
||||||
@ -60,7 +88,7 @@ def index(request: Request):
|
|||||||
This is the root of the website.
|
This is the root of the website.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
request:
|
request: The request.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
HTMLResponse: The HTML response.
|
HTMLResponse: The HTML response.
|
||||||
@ -188,10 +216,10 @@ async def create_feed(feed_url: str = Form(), webhook_dropdown: str = Form()):
|
|||||||
@app.get("/add", response_class=HTMLResponse)
|
@app.get("/add", response_class=HTMLResponse)
|
||||||
def get_add(request: Request):
|
def get_add(request: Request):
|
||||||
"""
|
"""
|
||||||
This is the root of the website.
|
Page for adding a new feed.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
request:
|
request: The request.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
HTMLResponse: The HTML response.
|
HTMLResponse: The HTML response.
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
"""This module contains functions for reading and writing settings and configuration files.
|
||||||
|
|
||||||
|
Functions:
|
||||||
|
create_settings_file:
|
||||||
|
Create the settings file if it doesn't exist.
|
||||||
|
get_data_dir:
|
||||||
|
Path to the data directory. This is where the database file and config file are stored.
|
||||||
|
get_db_file:
|
||||||
|
Where we store the database file.
|
||||||
|
read_settings_file:
|
||||||
|
Read the settings file and return it as a dict.
|
||||||
|
|
||||||
|
Variables:
|
||||||
|
data_directory:
|
||||||
|
The application directory, defaults to user_data_dir().
|
||||||
|
logger:
|
||||||
|
The logger for this program.
|
||||||
|
"""
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -63,7 +81,7 @@ def get_db_file(custom_db_name: str = "db.sqlite") -> Path:
|
|||||||
return Path(db_file)
|
return Path(db_file)
|
||||||
|
|
||||||
|
|
||||||
def _create_settings_file(settings_file) -> None:
|
def create_settings_file(settings_file) -> None:
|
||||||
"""Create the settings file if it doesn't exist."""
|
"""Create the settings file if it doesn't exist."""
|
||||||
logger.debug(f"Settings file: {settings_file}")
|
logger.debug(f"Settings file: {settings_file}")
|
||||||
|
|
||||||
@ -112,7 +130,7 @@ def read_settings_file(custom_settings_name: str = "settings.toml") -> TOMLDocum
|
|||||||
|
|
||||||
# Create the settings file if it doesn't exist
|
# Create the settings file if it doesn't exist
|
||||||
if not os.path.exists(settings_file):
|
if not os.path.exists(settings_file):
|
||||||
_create_settings_file(settings_file)
|
create_settings_file(settings_file)
|
||||||
|
|
||||||
with open(settings_file, encoding="utf-8") as f:
|
with open(settings_file, encoding="utf-8") as f:
|
||||||
data = parse(f.read())
|
data = parse(f.read())
|
||||||
|
Reference in New Issue
Block a user