(Added) os paths for the data and the config by default.

Added if config is missing, then the hint shows its path.
Updated pyproject.toml information.
main
KKlochko 2 years ago
parent 1a4405fbbc
commit 1799f5a3c7

@ -31,3 +31,7 @@
Updated my name to my fullname and release years.
** 1.0.2 <2023-01-15>
Refactor the database class and remove function for the creating file.
** 1.1.1 <2023-02-28>
Added os paths for the data and the config by default.
Added if config is missing, then the hint shows its path.
Updated pyproject.toml information.

@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project]
name = "anitube-simple-notification"
version = "1.0.0"
version = "1.1.1"
authors = [
{ name="Kostiantyn Klochko", email="kostya_klochko@ukr.net" },
]
@ -18,12 +18,13 @@ classifiers = [
"Operating System :: OS Independent",
]
dependencies = [
"requests",
"bs4",
"notify-py",
"rich",
"tomli",
"loguru"
"requests~=2.28.2",
"beautifulsoup4~=4.11.1",
"notify-py~=0.3.39",
"rich~=13.1.0",
"tomli~=2.0.1",
"loguru~=0.5.3",
"platformdirs~=3.0.0"
]
[project.urls]

@ -24,7 +24,7 @@ This module has all for simplify work with the toml configuration file.
from rich.console import Console
import tomli
import os
from pathlib import PosixPath
class Config:
@staticmethod
@ -70,7 +70,7 @@ class Config:
del config["URLS"]
@staticmethod
def get_config(config_path:str, console:Console) -> dict:
def get_config(config_path:PosixPath, console:Console) -> dict:
"""
Read the configuration file and return dict as configuration.
The configuration file must be in the application folder.
@ -81,6 +81,7 @@ class Config:
config = tomli.load(file)
except FileNotFoundError:
console.print(f"[red][ERROR] Please, create configuration file.[/]")
console.print(f"[yellow][ERROR] The configuration file path: {config_path}.[/]")
except tomli.TOMLDecodeError:
console.print(f"[red][ERROR] Please, check configuration file for correctness.[/]")
Config.config_validation_error(config)

@ -25,16 +25,32 @@ from rich.console import Console
from rich.progress import track
import time
import os
import platformdirs
def main():
# Const sections.
# Console initialising
console = Console()
APPNAME = "anitube-simple-notification"
APPAUTHOR = "KKlochko"
CONFIG_NAME = "config.toml"
BASE_DIR = os.path.dirname(__file__)
DB_PATH = os.path.join(BASE_DIR, 'user.db')
POSTERS_PATH = os.path.join(BASE_DIR, 'posters')
CONFIG_PATH = os.path.join(BASE_DIR, 'config.toml')
DATA_DIR = platformdirs.user_data_dir(APPNAME, APPAUTHOR)
DB_PATH = os.path.join(DATA_DIR, 'user.db')
POSTERS_PATH = os.path.join(DATA_DIR, 'posters')
CONFIG_PATH = platformdirs.user_config_path(APPNAME, APPAUTHOR, CONFIG_NAME)
# check for existing of dirs
if not os.path.exists(DATA_DIR):
os.makedirs(DATA_DIR)
if not os.path.exists(CONFIG_PATH):
os.makedirs(CONFIG_PATH)
config = Config.get_config(CONFIG_PATH, console)
# Here you can change testing headers to yours.

@ -27,7 +27,7 @@ from notifypy import Notify
class Notification:
"""The handler of notification."""
def __init__(self, title, message, icon_path=""):
"""Initialising the connection information."""
"""Initialising the notification information."""
self.title, self.message, self.icon_path = title, message, icon_path
def send(self):

Loading…
Cancel
Save