Use Typer instead of platformdirs
This commit is contained in:
		| @@ -55,6 +55,8 @@ def add( | ||||
| @app.command() | ||||
| def stats() -> None: | ||||
|     """Print the number of feeds and entries in the database""" | ||||
|     app_dir = typer.get_app_dir(Settings.APP_NAME) | ||||
|     typer.echo(app_dir) | ||||
|     with closing(make_reader(Settings.db_file)) as reader: | ||||
|         feed_count = reader.get_feed_counts() | ||||
|         entry_count = reader.get_entry_counts() | ||||
| @@ -100,14 +102,14 @@ def check() -> None: | ||||
| @app.command() | ||||
| def backup() -> None: | ||||
|     """Backup the database""" | ||||
|     backup_dir = os.path.join(Settings.data_dir, "backup") | ||||
|     backup_dir = os.path.join(Settings.app_dir, "backup") | ||||
|     os.makedirs(backup_dir, exist_ok=True) | ||||
|  | ||||
|     # Get the current time | ||||
|     current_time = time.strftime("%Y-%m-%d_%H-%M-%S") | ||||
|  | ||||
|     backup_file_location = os.path.join( | ||||
|         Settings.data_dir, "backup", f"db_{current_time}.sqlite" | ||||
|         Settings.app_dir, "backup", f"db_{current_time}.sqlite" | ||||
|     ) | ||||
|     copyfile(Settings.db_file, backup_file_location) | ||||
|  | ||||
|   | ||||
| @@ -1,25 +1,24 @@ | ||||
| import configparser | ||||
| import os | ||||
| import sys | ||||
| from pathlib import Path | ||||
|  | ||||
| from platformdirs import user_data_dir | ||||
| import typer | ||||
|  | ||||
|  | ||||
| class Settings: | ||||
|     data_dir = user_data_dir( | ||||
|         appname="discord-rss-bot",  # The name of application. | ||||
|         appauthor="TheLovinator",  # The name of the app author or distributing body for this application | ||||
|         roaming=True,  # Whether to use the roaming appdata directory on Windows | ||||
|     ) | ||||
|     APP_NAME: str = "discord-rss-bot" | ||||
|  | ||||
|     app_dir = typer.get_app_dir(APP_NAME) | ||||
|  | ||||
|     # Create the data directory if it doesn't exist | ||||
|     os.makedirs(data_dir, exist_ok=True) | ||||
|     os.makedirs(app_dir, exist_ok=True) | ||||
|  | ||||
|     # Store the database file in the data directory | ||||
|     db_file = os.path.join(data_dir, "db.sqlite") | ||||
|     db_file: Path = Path(os.path.join(app_dir, "db.sqlite")) | ||||
|  | ||||
|     # Store the config in the data directory | ||||
|     config_location = os.path.join(data_dir, "config.conf") | ||||
|     config_location: Path = Path(os.path.join(app_dir, "config.conf")) | ||||
|  | ||||
|     if not os.path.isfile(config_location): | ||||
|         # TODO: Add config for db_file and config_location | ||||
|   | ||||
		Reference in New Issue
	
	Block a user